rt: Remove the kernel task table

This commit is contained in:
Brian Anderson
2012-03-14 20:55:57 -07:00
parent 1366d65660
commit c414b78afe
3 changed files with 7 additions and 54 deletions

View File

@@ -166,51 +166,11 @@ rust_kernel::fail() {
} }
} }
void rust_task_id
rust_kernel::register_task(rust_task *task) { rust_kernel::generate_task_id() {
uintptr_t new_live_tasks; rust_task_id id = sync::increment(max_task_id);
{ K(srv, id != INTPTR_MAX, "Hit the maximum task id");
scoped_lock with(task_lock); return id;
task->id = max_task_id++;
task_table.put(task->id, task);
new_live_tasks = task_table.count();
}
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);
}
void
rust_kernel::release_task_id(rust_task_id id) {
KLOG_("Releasing task %" PRIdPTR, id);
uintptr_t new_live_tasks;
{
scoped_lock with(task_lock);
task_table.remove(id);
new_live_tasks = task_table.count();
}
KLOG_("Total outstanding tasks: %d", new_live_tasks);
}
rust_task *
rust_kernel::get_task_by_id(rust_task_id id) {
scoped_lock with(task_lock);
rust_task *task = NULL;
// get leaves task unchanged if not found.
task_table.get(id, &task);
if(task) {
if(task->get_ref_count() == 0) {
// FIXME: I don't think this is possible.
// this means the destructor is running, since the destructor
// grabs the kernel lock to unregister the task. Pretend this
// doesn't actually exist.
return NULL;
}
else {
task->ref();
}
}
return task;
} }
rust_port_id rust_port_id

View File

@@ -24,11 +24,8 @@ class rust_kernel {
public: public:
rust_srv *srv; rust_srv *srv;
private: private:
// Protects max_task_id and task_table
lock_and_signal task_lock;
// The next task id // The next task id
rust_task_id max_task_id; rust_task_id max_task_id;
hash_map<rust_task_id, rust_task *> task_table;
// Protects max_port_id and port_table // Protects max_port_id and port_table
lock_and_signal port_lock; lock_and_signal port_lock;
@@ -75,9 +72,7 @@ public:
void win32_require(LPCTSTR fn, BOOL ok); void win32_require(LPCTSTR fn, BOOL ok);
#endif #endif
void register_task(rust_task *task); rust_task_id generate_task_id();
rust_task *get_task_by_id(rust_task_id id);
void release_task_id(rust_task_id tid);
rust_port_id register_port(rust_port *port); rust_port_id register_port(rust_port *port);
rust_port *get_port_by_id(rust_port_id id); rust_port *get_port_by_id(rust_port_id id);

View File

@@ -146,8 +146,6 @@ rust_task_thread::reap_dead_tasks() {
// from the scheduler, which may end up trying to take this lock // from the scheduler, which may end up trying to take this lock
lock.unlock(); lock.unlock();
// Release the task from the kernel so nobody else can get at it
kernel->release_task_id(dead_task->id);
dead_task->delete_all_stacks(); dead_task->delete_all_stacks();
// Deref the task, which may cause it to request us to release it // Deref the task, which may cause it to request us to release it
dead_task->deref(); dead_task->deref();
@@ -316,7 +314,7 @@ rust_task_thread::create_task(rust_task *spawner, const char *name,
newborn_tasks.append(task); newborn_tasks.append(task);
} }
kernel->register_task(task); task->id = kernel->generate_task_id();
return task; return task;
} }