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

Move GC thread creation to gc.c.

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