Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1158 → Rev 1159

/kernel/trunk/generic/include/proc/task.h
31,6 → 31,7
 
#include <typedefs.h>
#include <synch/spinlock.h>
#include <adt/btree.h>
#include <adt/list.h>
#include <ipc/ipc.h>
 
39,9 → 40,8
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 */
task_id_t taskid; /**< Unique identity of task */
 
/* IPC stuff */
answerbox_t answerbox; /**< Communication endpoint */
50,7 → 50,7
};
 
extern spinlock_t tasks_lock;
extern link_t tasks_head;
extern btree_t tasks_btree;
 
extern void task_init(void);
extern task_t *task_create(as_t *as, char *name);
/kernel/trunk/generic/src/proc/task.c
35,6 → 35,7
#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>
42,7 → 43,7
#include <elf.h>
 
SPINLOCK_INITIALIZE(tasks_lock);
LIST_INITIALIZE(tasks_head);
btree_t tasks_btree;
static task_id_t task_counter = 0;
 
/** Initialize tasks
53,6 → 54,7
void task_init(void)
{
TASK = NULL;
btree_create(&tasks_btree);
}
 
 
76,7 → 78,6
 
spinlock_initialize(&ta->lock, "task_ta_lock");
list_initialize(&ta->th_head);
list_initialize(&ta->tasks_link);
ta->as = as;
ta->name = name;
 
92,7 → 93,7
spinlock_lock(&tasks_lock);
 
ta->taskid = ++task_counter;
list_append(&ta->tasks_link, &tasks_head);
btree_insert(&tasks_btree, (__native) ta, (void *) ta, NULL);
 
spinlock_unlock(&tasks_lock);
interrupts_restore(ipl);
151,25 → 152,33
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_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 (i=0; i < IPC_MAX_PHONES; i++) {
if (t->phones[i].callee)
printf(" Ph(%d): %P ", i,t->phones[i].callee);
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];
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);
}
printf("\n");
spinlock_unlock(&t->lock);
}
printf("\n");
spinlock_unlock(&t->lock);
}
 
spinlock_unlock(&tasks_lock);