Rev 1060 | Rev 1066 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1060 | Rev 1062 | ||
|---|---|---|---|
| Line 60... | Line 60... | ||
| 60 | /** Create new task |
60 | /** Create new task |
| 61 | * |
61 | * |
| 62 | * Create new task with no threads. |
62 | * Create new task with no threads. |
| 63 | * |
63 | * |
| 64 | * @param as Task's address space. |
64 | * @param as Task's address space. |
| - | 65 | * @param name Symbolic name. |
|
| 65 | * |
66 | * |
| 66 | * @return New task's structure |
67 | * @return New task's structure |
| 67 | * |
68 | * |
| 68 | */ |
69 | */ |
| 69 | task_t *task_create(as_t *as) |
70 | task_t *task_create(as_t *as, char *name) |
| 70 | { |
71 | { |
| 71 | ipl_t ipl; |
72 | ipl_t ipl; |
| 72 | task_t *ta; |
73 | task_t *ta; |
| 73 | int i; |
74 | int i; |
| 74 | 75 | ||
| Line 76... | Line 77... | ||
| 76 | 77 | ||
| 77 | spinlock_initialize(&ta->lock, "task_ta_lock"); |
78 | spinlock_initialize(&ta->lock, "task_ta_lock"); |
| 78 | list_initialize(&ta->th_head); |
79 | list_initialize(&ta->th_head); |
| 79 | list_initialize(&ta->tasks_link); |
80 | list_initialize(&ta->tasks_link); |
| 80 | ta->as = as; |
81 | ta->as = as; |
| - | 82 | ta->name = name; |
|
| 81 | 83 | ||
| 82 | 84 | ||
| 83 | ipc_answerbox_init(&ta->answerbox); |
85 | ipc_answerbox_init(&ta->answerbox); |
| 84 | for (i=0; i < IPC_MAX_PHONES;i++) |
86 | for (i=0; i < IPC_MAX_PHONES;i++) |
| 85 | ipc_phone_init(&ta->phones[i]); |
87 | ipc_phone_init(&ta->phones[i]); |
| Line 99... | Line 101... | ||
| 99 | return ta; |
101 | return ta; |
| 100 | } |
102 | } |
| 101 | 103 | ||
| 102 | /** Create new task with 1 thread and run it |
104 | /** Create new task with 1 thread and run it |
| 103 | * |
105 | * |
| - | 106 | * @param programe_addr Address of program executable image. |
|
| - | 107 | * @param name Program name. |
|
| - | 108 | * |
|
| 104 | * @return Task of the running program or NULL on error |
109 | * @return Task of the running program or NULL on error |
| 105 | */ |
110 | */ |
| 106 | task_t * task_run_program(void *program_addr) |
111 | task_t * task_run_program(void *program_addr, char *name) |
| 107 | { |
112 | { |
| 108 | as_t *as; |
113 | as_t *as; |
| 109 | as_area_t *a; |
114 | as_area_t *a; |
| 110 | int rc; |
115 | int rc; |
| 111 | thread_t *t; |
116 | thread_t *t; |
| Line 117... | Line 122... | ||
| 117 | if (rc != EE_OK) { |
122 | if (rc != EE_OK) { |
| 118 | as_free(as); |
123 | as_free(as); |
| 119 | return NULL; |
124 | return NULL; |
| 120 | } |
125 | } |
| 121 | 126 | ||
| 122 | task = task_create(as); |
127 | task = task_create(as, name); |
| 123 | t = thread_create(uinit, (void *)((elf_header_t *)program_addr)->e_entry, |
128 | t = thread_create(uinit, (void *)((elf_header_t *)program_addr)->e_entry, |
| 124 | task, THREAD_USER_STACK); |
129 | task, 0, "uinit"); |
| 125 | 130 | ||
| 126 | /* |
131 | /* |
| 127 | * Create the data as_area. |
132 | * Create the data as_area. |
| 128 | */ |
133 | */ |
| 129 | a = as_area_create(as, AS_AREA_READ | AS_AREA_WRITE, PAGE_SIZE, USTACK_ADDRESS); |
134 | a = as_area_create(as, AS_AREA_READ | AS_AREA_WRITE, PAGE_SIZE, USTACK_ADDRESS); |
| Line 146... | Line 151... | ||
| 146 | spinlock_lock(&tasks_lock); |
151 | spinlock_lock(&tasks_lock); |
| 147 | 152 | ||
| 148 | for (cur=tasks_head.next; cur!=&tasks_head; cur=cur->next) { |
153 | for (cur=tasks_head.next; cur!=&tasks_head; cur=cur->next) { |
| 149 | t = list_get_instance(cur, task_t, tasks_link); |
154 | t = list_get_instance(cur, task_t, tasks_link); |
| 150 | spinlock_lock(&t->lock); |
155 | spinlock_lock(&t->lock); |
| 151 | printf("Task: %Q ActiveCalls: %d", t->taskid, |
156 | printf("%s: address=%P, taskid=%Q, as=%P, ActiveCalls: %d", |
| 152 | atomic_get(&t->active_calls)); |
157 | t->name, t, t->taskid, t->as, atomic_get(&t->active_calls)); |
| 153 | for (i=0; i < IPC_MAX_PHONES; i++) { |
158 | for (i=0; i < IPC_MAX_PHONES; i++) { |
| 154 | if (t->phones[i].callee) |
159 | if (t->phones[i].callee) |
| 155 | printf(" Ph(%d): %P ", i,t->phones[i].callee); |
160 | printf(" Ph(%d): %P ", i,t->phones[i].callee); |
| 156 | } |
161 | } |
| 157 | printf("\n"); |
162 | printf("\n"); |