Subversion Repositories HelenOS

Compare Revisions

Regard whitespace Rev 1159 → Rev 1158

/kernel/trunk/generic/include/proc/task.h
31,7 → 31,6
 
#include <typedefs.h>
#include <synch/spinlock.h>
#include <adt/btree.h>
#include <adt/list.h>
#include <ipc/ipc.h>
 
40,6 → 39,7
SPINLOCK_DECLARE(lock);
char *name;
link_t th_head; /**< List of threads contained in this task. */
link_t tasks_link; /**< Link to other tasks within the system. */
as_t *as; /**< Address space. */
task_id_t taskid; /**< Unique identity of task */
 
50,7 → 50,7
};
 
extern spinlock_t tasks_lock;
extern btree_t tasks_btree;
extern link_t tasks_head;
 
extern void task_init(void);
extern task_t *task_create(as_t *as, char *name);
/kernel/trunk/generic/src/proc/task.c
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);