提交 726b49a0 创建 作者: Austin Clements's avatar Austin Clements

Init distrefs as kernel init time

Fixes sharing on distref's lazy init flag
上级 0bfacd12
...@@ -241,23 +241,17 @@ distref_wakeup() ...@@ -241,23 +241,17 @@ distref_wakeup()
void void
distref_check(distributed_refcnt *dr) distref_check(distributed_refcnt *dr)
{ {
static bool initialized;
static spinlock initlock("distref initlock");
if (!initialized) {
acquire(&initlock);
if (!initialized) {
struct proc *t = threadalloc(distref_thread, nullptr);
acquire(&t->lock);
safestrcpy(t->name, "distref_thread", sizeof(t->name));
addrun(t);
release(&t->lock);
initialized = true;
}
release(&initlock);
}
// Add it to the maybe-free list // Add it to the maybe-free list
if (workers.load()->enqueue(dr)) if (workers.load()->enqueue(dr))
distref_wakeup(); distref_wakeup();
} }
void
initdistref()
{
struct proc *t = threadalloc(distref_thread, nullptr);
acquire(&t->lock);
safestrcpy(t->name, "distref_thread", sizeof(t->name));
addrun(t);
release(&t->lock);
}
...@@ -40,6 +40,7 @@ void initidle(void); ...@@ -40,6 +40,7 @@ void initidle(void);
void initcpprt(void); void initcpprt(void);
void initfutex(void); void initfutex(void);
void initcmdline(void); void initcmdline(void);
void initdistref(void);
void idleloop(void); void idleloop(void);
#define IO_RTC 0x70 #define IO_RTC 0x70
...@@ -161,6 +162,7 @@ cmain(u64 mbmagic, u64 mbaddr) ...@@ -161,6 +162,7 @@ cmain(u64 mbmagic, u64 mbaddr)
initsched(); // scheduler run queues initsched(); // scheduler run queues
initidle(); initidle();
initgc(); // gc epochs and threads initgc(); // gc epochs and threads
initdistref(); // distref collector thread
initdisk(); // disk initdisk(); // disk
initbio(); // buffer cache initbio(); // buffer cache
initinode(); // inode cache initinode(); // inode cache
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论