提交 2c5891f1 创建 作者: Silas Boyd-Wickizer's avatar Silas Boyd-Wickizer

Move GC thread creation to gc.c.

上级 05b2b73c
......@@ -122,10 +122,11 @@ gc(void)
}
void
static void
gc_worker(void *x)
{
struct spinlock wl;
initlock(&wl, "rcu_gc_worker"); // dummy lock
for (;;) {
......@@ -212,4 +213,19 @@ initgc(void)
for (int i = 0; i < NEPOCH; i++)
for (int j = 0; j < NEPOCH; j++)
gc_epoch[i][j].epoch = i;
for (u32 c = 0; c < NCPU; c++) {
struct proc *gcp;
gcp = threadalloc(gc_worker, NULL);
if (gcp == NULL)
panic("threadalloc: gc_worker");
gcp->cpuid = c;
gcp->cpu_pin = 1;
acquire(&gcp->lock);
gcp->state = RUNNABLE;
addrun(gcp);
release(&gcp->lock);
}
}
......@@ -26,6 +26,8 @@ extern void inithz(void);
extern void initwq(void);
extern void initsamp(void);
extern void initpci(void);
extern void initnet(void);
extern void initsched(void);
static volatile int bstate;
......@@ -94,8 +96,9 @@ cmain(u64 mbmagic, u64 mbaddr)
initmp();
initlapic();
initkalloc(mbaddr);
initgc(); // gc epochs
initproc(); // process table
initsched(); // scheduler run queues
initgc(); // gc epochs and threads
initbio(); // buffer cache
initinode(); // inode cache
initdisk(); // disk
......@@ -104,6 +107,7 @@ cmain(u64 mbmagic, u64 mbaddr)
#endif
initsamp();
initpci();
initnet();
cprintf("ncpu %d %lu MHz\n", ncpu, cpuhz / 1000000);
......
......@@ -267,22 +267,6 @@ inituser(void)
addrun(p);
p->state = RUNNABLE;
release(&p->lock);
for (u32 c = 0; c < NCPU; c++) {
extern void gc_worker(void*);
struct proc *gcp;
gcp = threadalloc(gc_worker, NULL);
if (gcp == NULL)
panic("threadalloc: gc_worker");
gcp->cpuid = c;
gcp->cpu_pin = 1;
acquire(&gcp->lock);
gcp->state = RUNNABLE;
addrun(gcp);
release(&gcp->lock);
}
}
void
......@@ -294,8 +278,6 @@ initproc(void)
if (nspid == 0)
panic("pinit");
initsched();
for (c = 0; c < NCPU; c++)
idle[c] = 1;
}
......
void delrun(struct proc*);
void initsched(void);
struct proc* schednext(void);
int steal(void);
void addrun(struct proc*);
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论