Misc clean up

上级 3a046d90
...@@ -9,7 +9,7 @@ struct padded_length { ...@@ -9,7 +9,7 @@ struct padded_length {
struct uwq : public referenced, public rcu_freed { struct uwq : public referenced, public rcu_freed {
static uwq* alloc(vmap* vmap, filetable *ftable); static uwq* alloc(vmap* vmap, filetable *ftable);
bool haswork(); bool haswork();
int trywork(); bool trywork();
void* buffer(); void* buffer();
void setuentry(uptr uentry); void setuentry(uptr uentry);
......
// //
// XXX // XXX
// - vmap doesn't need to be rcu_freed anymore
// - workers should have a uwq // - workers should have a uwq
// - pin workers // - pin workers
...@@ -43,7 +42,7 @@ uwq_trywork(void) ...@@ -43,7 +42,7 @@ uwq_trywork(void)
uwq* uwq = p->uwq; uwq* uwq = p->uwq;
if (uwq->haswork()) { if (uwq->haswork()) {
if (uwq->trywork() == 1) if (uwq->trywork())
return 1; return 1;
// XXX(sbw) start a worker thread.. // XXX(sbw) start a worker thread..
break; break;
...@@ -130,24 +129,21 @@ uwq::haswork(void) ...@@ -130,24 +129,21 @@ uwq::haswork(void)
return false; return false;
} }
int bool
uwq::trywork(void) uwq::trywork(void)
{ {
struct proc* p; struct proc* p;
p = getworker(); p = getworker();
if (p == nullptr) if (p == nullptr)
return -1; return false;
// XXX(sbw) filetable, etc
p->cpuid = mycpuid(); p->cpuid = mycpuid();
acquire(&p->lock); acquire(&p->lock);
addrun(p); addrun(p);
release(&p->lock); release(&p->lock);
cprintf("trying to run..\n"); return true;
return 1;
} }
void void
...@@ -183,9 +179,9 @@ uwq::allocworker(void) ...@@ -183,9 +179,9 @@ uwq::allocworker(void)
return nullptr; return nullptr;
safestrcpy(p->name, "uwq_worker", sizeof(p->name)); safestrcpy(p->name, "uwq_worker", sizeof(p->name));
// finishproc will drop these refs
vmap_->incref(); vmap_->incref();
ftable_->incref(); ftable_->incref();
// finishproc will drop these refs
p->vmap = vmap_; p->vmap = vmap_;
p->ftable = ftable_; p->ftable = ftable_;
...@@ -205,7 +201,6 @@ uwq::allocworker(void) ...@@ -205,7 +201,6 @@ uwq::allocworker(void)
ustack_ += (UWQSTACKPAGES*PGSIZE); ustack_ += (UWQSTACKPAGES*PGSIZE);
p->tf->rsp = stacktop - 8; p->tf->rsp = stacktop - 8;
cprintf("stacktop %lx\n", stacktop);
p->tf->rip = uentry; p->tf->rip = uentry;
p->tf->cs = UCSEG | 0x3; p->tf->cs = UCSEG | 0x3;
p->tf->ds = UDSEG | 0x3; p->tf->ds = UDSEG | 0x3;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论