rt: Remove rust_task_user struct

This commit is contained in:
Brian Anderson 2012-02-08 17:46:12 -08:00
parent 1dad32c015
commit d39ea47746
5 changed files with 25 additions and 36 deletions

View file

@ -439,7 +439,7 @@ rust_new_sched(uintptr_t threads) {
extern "C" CDECL rust_task_id
get_task_id() {
rust_task *task = rust_task_thread::get_task();
return task->user.id;
return task->id;
}
static rust_task_id

View file

@ -161,12 +161,12 @@ rust_kernel::register_task(rust_task *task) {
uintptr_t new_live_tasks;
{
scoped_lock with(task_lock);
task->user.id = max_task_id++;
task_table.put(task->user.id, task);
task->id = max_task_id++;
task_table.put(task->id, task);
new_live_tasks = ++live_tasks;
}
K(srv, task->user.id != INTPTR_MAX, "Hit the maximum task id");
KLOG_("Registered task %" PRIdPTR, task->user.id);
K(srv, task->id != INTPTR_MAX, "Hit the maximum task id");
KLOG_("Registered task %" PRIdPTR, task->id);
KLOG_("Total outstanding tasks: %d", new_live_tasks);
}

View file

@ -190,6 +190,8 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
rust_task *spawner, const char *name,
size_t init_stack_sz) :
ref_count(1),
id(0),
notify_enabled(false),
stk(NULL),
runtime_sp(0),
sched(thread->sched),
@ -216,12 +218,8 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
LOGPTR(thread, "new task", (uintptr_t)this);
DLOG(thread, task, "sizeof(task) = %d (0x%x)", sizeof *this, sizeof *this);
assert((void*)this == (void*)&user);
user.notify_enabled = 0;
stk = new_stk(thread, this, init_stack_sz);
user.rust_sp = stk->end;
rust_sp = stk->end;
if (supervisor) {
supervisor->ref();
}
@ -338,7 +336,7 @@ rust_task::start(spawn_fn spawnee_fn,
I(thread, stk->data != NULL);
char *sp = (char *)user.rust_sp;
char *sp = (char *)rust_sp;
sp -= sizeof(spawn_args);
@ -614,14 +612,14 @@ rust_port *rust_task::get_port_by_id(rust_port_id id) {
void
rust_task::notify(bool success) {
// FIXME (1078) Do this in rust code
if(user.notify_enabled) {
rust_task *target_task = kernel->get_task_by_id(user.notify_chan.task);
if(notify_enabled) {
rust_task *target_task = kernel->get_task_by_id(notify_chan.task);
if (target_task) {
rust_port *target_port =
target_task->get_port_by_id(user.notify_chan.port);
target_task->get_port_by_id(notify_chan.port);
if(target_port) {
task_notification msg;
msg.id = user.id;
msg.id = id;
msg.result = !success ? tr_failure : tr_success;
target_port->send(&msg);
@ -715,8 +713,8 @@ rust_task::check_stack_canary() {
void
rust_task::config_notify(chan_handle chan) {
user.notify_enabled = true;
user.notify_chan = chan;
notify_enabled = true;
notify_chan = chan;
}
//

View file

@ -31,16 +31,6 @@ struct frame_glue_fns {
uintptr_t reloc_glue_off;
};
// portions of the task structure that are accessible from the standard
// library. This struct must agree with the std::task::rust_task record.
struct rust_task_user {
rust_task_id id;
intptr_t notify_enabled; // this is way more bits than necessary, but it
// simplifies the alignment.
chan_handle notify_chan;
uintptr_t rust_sp; // Saved sp when not running.
};
// std::lib::task::task_result
typedef unsigned long task_result;
#define tr_success 0
@ -57,10 +47,14 @@ struct task_notification {
struct
rust_task : public kernel_owned<rust_task>, rust_cond
{
rust_task_user user;
RUST_ATOMIC_REFCOUNT();
rust_task_id id;
bool notify_enabled;
chan_handle notify_chan;
uintptr_t rust_sp; // Saved sp when not running.
context ctx;
stk_seg *stk;
uintptr_t runtime_sp; // Runtime sp while task running.

View file

@ -137,7 +137,7 @@ rust_task_thread::reap_dead_tasks() {
for (size_t i = 0; i < dead_tasks_len; ++i) {
rust_task *task = dead_tasks_copy[i];
// Release the task from the kernel so nobody else can get at it
kernel->release_task_id(task->user.id);
kernel->release_task_id(task->id);
// Deref the task, which may cause it to request us to release it
task->deref();
}
@ -151,7 +151,7 @@ rust_task_thread::release_task(rust_task *task) {
// Nobody should have a ref to the task at this point
I(this, task->ref_count == 0);
// Kernel should not know about the task any more
I(this, kernel->get_task_by_id(task->user.id) == NULL);
I(this, kernel->get_task_by_id(task->id) == NULL);
// Now delete the task, which will require using this thread's
// memory region.
delete task;
@ -249,11 +249,9 @@ rust_task_thread::start_main_loop() {
DLOG(this, task,
"activating task %s 0x%" PRIxPTR
", sp=0x%" PRIxPTR
", state: %s",
scheduled_task->name,
(uintptr_t)scheduled_task,
scheduled_task->user.rust_sp,
scheduled_task->state->name);
place_task_in_tls(scheduled_task);
@ -265,11 +263,10 @@ rust_task_thread::start_main_loop() {
DLOG(this, task,
"returned from task %s @0x%" PRIxPTR
" in state '%s', sp=0x%x, worker id=%d" PRIxPTR,
" in state '%s', worker id=%d" PRIxPTR,
scheduled_task->name,
(uintptr_t)scheduled_task,
scheduled_task->state->name,
scheduled_task->user.rust_sp,
id);
reap_dead_tasks();
@ -305,7 +302,7 @@ rust_task_thread::create_task(rust_task *spawner, const char *name,
}
kernel->register_task(task);
return task->user.id;
return task->id;
}
void rust_task_thread::run() {