35,7 → 35,6 |
#include <synch/spinlock.h> |
#include <arch.h> |
#include <panic.h> |
#include <adt/btree.h> |
#include <adt/list.h> |
#include <ipc/ipc.h> |
#include <memstr.h> |
43,7 → 42,7 |
#include <elf.h> |
|
SPINLOCK_INITIALIZE(tasks_lock); |
btree_t tasks_btree; |
LIST_INITIALIZE(tasks_head); |
static task_id_t task_counter = 0; |
|
/** Initialize tasks |
54,7 → 53,6 |
void task_init(void) |
{ |
TASK = NULL; |
btree_create(&tasks_btree); |
} |
|
|
78,6 → 76,7 |
|
spinlock_initialize(&ta->lock, "task_ta_lock"); |
list_initialize(&ta->th_head); |
list_initialize(&ta->tasks_link); |
ta->as = as; |
ta->name = name; |
|
93,7 → 92,7 |
spinlock_lock(&tasks_lock); |
|
ta->taskid = ++task_counter; |
btree_insert(&tasks_btree, (__native) ta, (void *) ta, NULL); |
list_append(&ta->tasks_link, &tasks_head); |
|
spinlock_unlock(&tasks_lock); |
interrupts_restore(ipl); |
152,34 → 151,26 |
void task_print_list(void) |
{ |
link_t *cur; |
task_t *t; |
ipl_t ipl; |
int i; |
|
/* Messing with thread structures, avoid deadlock */ |
ipl = interrupts_disable(); |
spinlock_lock(&tasks_lock); |
|
for (cur = tasks_btree.leaf_head.next; cur != &tasks_btree.leaf_head; cur = cur->next) { |
btree_node_t *node; |
int i; |
|
node = list_get_instance(cur, btree_node_t, leaf_link); |
for (i = 0; i < node->keys; i++) { |
task_t *t; |
int j; |
|
t = (task_t *) node->value[i]; |
|
for (cur=tasks_head.next; cur!=&tasks_head; cur=cur->next) { |
t = list_get_instance(cur, task_t, tasks_link); |
spinlock_lock(&t->lock); |
printf("%s: address=%P, taskid=%Q, as=%P, ActiveCalls: %d", |
t->name, t, t->taskid, t->as, atomic_get(&t->active_calls)); |
for (j=0; j < IPC_MAX_PHONES; j++) { |
if (t->phones[j].callee) |
printf(" Ph(%d): %P ", j, t->phones[j].callee); |
for (i=0; i < IPC_MAX_PHONES; i++) { |
if (t->phones[i].callee) |
printf(" Ph(%d): %P ", i,t->phones[i].callee); |
} |
printf("\n"); |
spinlock_unlock(&t->lock); |
} |
} |
|
spinlock_unlock(&tasks_lock); |
interrupts_restore(ipl); |