Changeset ff14c520 in mainline
- Timestamp:
- 2006-03-16T22:31:39Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 93165be
- Parents:
- 37c57f2
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/sparc64/src/sparc64.c
r37c57f2 rff14c520 58 58 * Create thread that reads characters from OFW's input. 59 59 */ 60 t = thread_create(kofwinput, NULL, TASK, 0 );60 t = thread_create(kofwinput, NULL, TASK, 0, "kofwinput"); 61 61 if (!t) 62 62 panic("cannot create kofwinput\n"); … … 66 66 * Create thread that polls keyboard. 67 67 */ 68 t = thread_create(kkbdpoll, NULL, TASK, 0 );68 t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll"); 69 69 if (!t) 70 70 panic("cannot create kkbdpoll\n"); -
generic/include/proc/task.h
r37c57f2 rff14c520 38 38 struct task { 39 39 SPINLOCK_DECLARE(lock); 40 char *name; 40 41 link_t th_head; /**< List of threads contained in this task. */ 41 42 link_t tasks_link; /**< Link to other tasks within the system. */ … … 53 54 54 55 extern void task_init(void); 55 extern task_t *task_create(as_t *as );56 extern task_t *task_run_program(void * program_addr);56 extern task_t *task_create(as_t *as, char *name); 57 extern task_t *task_run_program(void *program_addr, char *name); 57 58 58 59 #endif -
generic/include/proc/thread.h
r37c57f2 rff14c520 60 60 #define X_STOLEN (1<<1) 61 61 62 /** Thread structure. There is one per thread. */ 62 63 struct thread { 64 char *name; 65 63 66 link_t rq_link; /**< Run queue link. */ 64 67 link_t wq_link; /**< Wait queue link. */ … … 126 129 127 130 extern void thread_init(void); 128 extern thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags );131 extern thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name); 129 132 extern void thread_ready(thread_t *t); 130 133 extern void thread_exit(void); -
generic/src/main/kinit.c
r37c57f2 rff14c520 81 81 * Just a beautification. 82 82 */ 83 if ((t = thread_create(kmp, NULL, TASK, 0 ))) {83 if ((t = thread_create(kmp, NULL, TASK, 0, "kmp"))) { 84 84 spinlock_lock(&t->lock); 85 85 t->flags |= X_WIRED; … … 106 106 for (i = 0; i < config.cpu_count; i++) { 107 107 108 if ((t = thread_create(kcpulb, NULL, TASK, 0 ))) {108 if ((t = thread_create(kcpulb, NULL, TASK, 0, "kcpulb"))) { 109 109 spinlock_lock(&t->lock); 110 110 t->flags |= X_WIRED; … … 127 127 * Create kernel console. 128 128 */ 129 if ((t = thread_create(kconsole, "kconsole", TASK, 0 )))129 if ((t = thread_create(kconsole, "kconsole", TASK, 0, "kconsole"))) 130 130 thread_ready(t); 131 131 else … … 143 143 panic("init[%d].addr is not frame aligned", i); 144 144 145 utask = task_run_program((void *) init.tasks[i].addr );145 utask = task_run_program((void *) init.tasks[i].addr, "USPACE"); 146 146 if (utask) { 147 147 if (!ipc_phone_0) -
generic/src/main/main.c
r37c57f2 rff14c520 197 197 * Create kernel task. 198 198 */ 199 k = task_create(AS_KERNEL );199 k = task_create(AS_KERNEL, "KERNEL"); 200 200 if (!k) 201 201 panic("can't create kernel task\n"); … … 204 204 * Create the first thread. 205 205 */ 206 t = thread_create(kinit, NULL, k, 0 );206 t = thread_create(kinit, NULL, k, 0, "kinit"); 207 207 if (!t) 208 208 panic("can't create kinit thread\n"); -
generic/src/proc/scheduler.c
r37c57f2 rff14c520 618 618 * let's not be interrupted */ 619 619 ipl = interrupts_disable(); 620 printf("Scheduler dump:\n");621 620 for (cpu=0;cpu < config.cpu_count; cpu++) { 622 621 … … 625 624 626 625 spinlock_lock(&cpus[cpu].lock); 627 printf("cpu%d: nrdy: %d, needs_relink:%d\n",628 cpus[cpu].id, atomic_get(&cpus[cpu].nrdy), cpus[cpu].needs_relink);626 printf("cpu%d: address=%P, nrdy=%d, needs_relink=%d\n", 627 cpus[cpu].id, &cpus[cpu], atomic_get(&cpus[cpu].nrdy), cpus[cpu].needs_relink); 629 628 630 629 for (i=0; i<RQ_COUNT; i++) { -
generic/src/proc/task.c
r37c57f2 rff14c520 63 63 * 64 64 * @param as Task's address space. 65 * @param name Symbolic name. 65 66 * 66 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 72 ipl_t ipl; … … 79 80 list_initialize(&ta->tasks_link); 80 81 ta->as = as; 82 ta->name = name; 81 83 82 84 … … 102 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 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 113 as_t *as; … … 120 125 } 121 126 122 task = task_create(as );127 task = task_create(as, name); 123 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 /* … … 149 154 t = list_get_instance(cur, task_t, tasks_link); 150 155 spinlock_lock(&t->lock); 151 printf(" Task: %Q ActiveCalls: %d", t->taskid,152 156 printf("%s: address=%P, taskid=%Q, as=%P, ActiveCalls: %d", 157 t->name, t, t->taskid, t->as, atomic_get(&t->active_calls)); 153 158 for (i=0; i < IPC_MAX_PHONES; i++) { 154 159 if (t->phones[i].callee) -
generic/src/proc/thread.c
r37c57f2 rff14c520 249 249 * @param task Task to which the thread belongs. 250 250 * @param flags Thread flags. 251 * @param name Symbolic name. 251 252 * 252 253 * @return New thread's structure on success, NULL on failure. 253 254 * 254 255 */ 255 thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags )256 thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name) 256 257 { 257 258 thread_t *t; … … 280 281 interrupts_restore(ipl); 281 282 283 t->name = name; 282 284 t->thread_code = func; 283 285 t->thread_arg = arg; … … 410 412 for (cur=threads_head.next; cur!=&threads_head; cur=cur->next) { 411 413 t = list_get_instance(cur, thread_t, threads_link); 412 printf("Thr: %d(%s) ", t->tid, thread_states[t->state]); 414 printf("%s: address=%P, tid=%d, state=%s, task=%P, code=%P, stack=%P, cpu=", 415 t->name, t, t->tid, thread_states[t->state], t->task, t->thread_code, t->kstack); 413 416 if (t->cpu) 414 417 printf("cpu%d ", t->cpu->id); 418 else 419 printf("none"); 415 420 printf("\n"); 416 421 } -
test/fpu/fpu1/test.c
r37c57f2 rff14c520 144 144 } 145 145 146 147 146 void test(void) 148 147 { … … 156 155 157 156 for (i=0; i<THREADS/2; i++) { 158 if (!(t = thread_create(e, NULL, TASK, 0 )))157 if (!(t = thread_create(e, NULL, TASK, 0, "e"))) 159 158 panic("could not create thread\n"); 160 159 thread_ready(t); 161 if (!(t = thread_create(pi, NULL, TASK, 0 )))160 if (!(t = thread_create(pi, NULL, TASK, 0, "pi"))) 162 161 panic("could not create thread\n"); 163 162 thread_ready(t); … … 173 172 printf("Test passed.\n"); 174 173 } 175 176 /*177 static void pi(void *data)178 {179 #undef PI_10e8180 #define PI_10e8 3141592181 182 183 int i;184 double lpi, pi;185 double n, ab, ad;186 187 188 printf("pi test\n");189 190 waitq_sleep(&can_start);191 192 193 for (i = 0; i<ATTEMPTS; i++) {194 lpi = -1;195 pi = 0;196 197 for (n=2, ab = sqrt(2); lpi != pi; n *= 2, ab = ad) {198 double sc, cd;199 200 sc = sqrt(1 - (ab*ab/4));201 cd = 1 - sc;202 ad = sqrt(ab*ab/4 + cd*cd);203 lpi = pi;204 pi = 2 * n * ad;205 }206 207 atomic_inc(&threads_ok);208 if((int)(1000000*pi)!=PI_10e8)209 panic("tid%d: pi*10e6=%d\n", THREAD->tid, (int) 1000000*pi);210 }211 212 printf("tid%d: pi*10e6=%d\n", THREAD->tid, (int) 1000000*pi);213 }214 */ -
test/fpu/mips1/test.c
r37c57f2 rff14c520 113 113 114 114 for (i=0; i<THREADS/2; i++) { 115 if (!(t = thread_create(testit1, (void *)((__native)i*2), TASK, 0 )))115 if (!(t = thread_create(testit1, (void *)((__native)i*2), TASK, 0, "testit1"))) 116 116 panic("could not create thread\n"); 117 117 thread_ready(t); 118 if (!(t = thread_create(testit2, (void *)((__native)i*2+1), TASK, 0 )))118 if (!(t = thread_create(testit2, (void *)((__native)i*2+1), TASK, 0, "testit2"))) 119 119 panic("could not create thread\n"); 120 120 thread_ready(t); -
test/fpu/sse1/test.c
r37c57f2 rff14c520 113 113 114 114 for (i=0; i<THREADS/2; i++) { 115 if (!(t = thread_create(testit1, (void *)((__native)i*2), TASK, 0 )))115 if (!(t = thread_create(testit1, (void *)((__native)i*2), TASK, 0, "testit1"))) 116 116 panic("could not create thread\n"); 117 117 thread_ready(t); 118 if (!(t = thread_create(testit2, (void *)((__native)i*2+1), TASK, 0 )))118 if (!(t = thread_create(testit2, (void *)((__native)i*2+1), TASK, 0, "testit2"))) 119 119 panic("could not create thread\n"); 120 120 thread_ready(t); -
test/mm/falloc2/test.c
r37c57f2 rff14c520 45 45 #define THREADS 8 46 46 47 static void thread(void * arg);47 static void falloc(void * arg); 48 48 static void failed(void); 49 49 50 50 static atomic_t thread_count; 51 51 52 void thread(void * arg)52 void falloc(void * arg) 53 53 { 54 54 int status, order, run, allocated, i; … … 108 108 for (i = 0; i < THREADS; i++) { 109 109 thread_t * thrd; 110 thrd = thread_create( thread, NULL, TASK, 0);110 thrd = thread_create(falloc, NULL, TASK, 0, "falloc"); 111 111 if (thrd) 112 112 thread_ready(thrd); -
test/mm/slab1/test.c
r37c57f2 rff14c520 109 109 semaphore_t thr_sem; 110 110 111 static void thread(void *data)111 static void slabtest(void *data) 112 112 { 113 113 int offs = (int)(__native) data; … … 139 139 semaphore_initialize(&thr_sem,0); 140 140 for (i=0; i<THREADS; i++) { 141 if (!(t = thread_create( thread, (void *)(__native)i, TASK, 0)))141 if (!(t = thread_create(slabtest, (void *)(__native)i, TASK, 0, "slabtest"))) 142 142 panic("could not create thread\n"); 143 143 thread_ready(t); -
test/mm/slab2/test.c
r37c57f2 rff14c520 123 123 #define THREADS 8 124 124 125 static void thread(void *priv)125 static void slabtest(void *priv) 126 126 { 127 127 void *data=NULL, *new; … … 189 189 semaphore_initialize(&thr_sem,0); 190 190 for (i=0; i<THREADS; i++) { 191 if (!(t = thread_create( thread, NULL, TASK, 0)))191 if (!(t = thread_create(slabtest, NULL, TASK, 0, "slabtest"))) 192 192 panic("could not create thread\n"); 193 193 thread_ready(t); -
test/synch/rwlock2/test.c
r37c57f2 rff14c520 75 75 rwlock_read_lock(&rwlock); 76 76 77 thrd = thread_create(writer, NULL, TASK, 0 );77 thrd = thread_create(writer, NULL, TASK, 0, "writer"); 78 78 if (thrd) 79 79 thread_ready(thrd); -
test/synch/rwlock3/test.c
r37c57f2 rff14c520 78 78 79 79 for (i=0; i<4; i++) { 80 thrd = thread_create(reader, NULL, TASK, 0 );80 thrd = thread_create(reader, NULL, TASK, 0, "reader"); 81 81 if (thrd) 82 82 thread_ready(thrd); -
test/synch/rwlock4/test.c
r37c57f2 rff14c520 138 138 printf("Creating %d readers\n", k); 139 139 for (i=0; i<k; i++) { 140 thrd = thread_create(reader, NULL, TASK, 0 );140 thrd = thread_create(reader, NULL, TASK, 0, "reader"); 141 141 if (thrd) 142 142 thread_ready(thrd); … … 148 148 printf("Creating %d writers\n", k); 149 149 for (i=0; i<k; i++) { 150 thrd = thread_create(writer, NULL, TASK, 0 );150 thrd = thread_create(writer, NULL, TASK, 0, "writer"); 151 151 if (thrd) 152 152 thread_ready(thrd); -
test/synch/rwlock5/test.c
r37c57f2 rff14c520 96 96 for (j=0; j<(READERS+WRITERS)/2; j++) { 97 97 for (k=0; k<i; k++) { 98 thrd = thread_create(reader, NULL, TASK, 0 );98 thrd = thread_create(reader, NULL, TASK, 0, "reader"); 99 99 if (thrd) 100 100 thread_ready(thrd); … … 103 103 } 104 104 for (k=0; k<(4-i); k++) { 105 thrd = thread_create(writer, NULL, TASK, 0 );105 thrd = thread_create(writer, NULL, TASK, 0, "writer"); 106 106 if (thrd) 107 107 thread_ready(thrd); -
test/synch/semaphore1/test.c
r37c57f2 rff14c520 100 100 for (j=0; j<(CONSUMERS+PRODUCERS)/2; j++) { 101 101 for (k=0; k<i; k++) { 102 thrd = thread_create(consumer, NULL, TASK, 0 );102 thrd = thread_create(consumer, NULL, TASK, 0, "consumer"); 103 103 if (thrd) 104 104 thread_ready(thrd); … … 107 107 } 108 108 for (k=0; k<(4-i); k++) { 109 thrd = thread_create(producer, NULL, TASK, 0 );109 thrd = thread_create(producer, NULL, TASK, 0, "producer"); 110 110 if (thrd) 111 111 thread_ready(thrd); -
test/synch/semaphore2/test.c
r37c57f2 rff14c520 108 108 printf("Creating %d consumers\n", k); 109 109 for (i=0; i<k; i++) { 110 thrd = thread_create(consumer, NULL, TASK, 0 );110 thrd = thread_create(consumer, NULL, TASK, 0, "consumer"); 111 111 if (thrd) 112 112 thread_ready(thrd); -
test/thread/thread1/test.c
r37c57f2 rff14c520 40 40 #define THREADS 5 41 41 42 static void thread (void *data)42 static void threadtest(void *data) 43 43 { 44 44 while(1) … … 55 55 56 56 for (i=0; i<THREADS; i++) { 57 if (!(t = thread_create(thread , NULL, TASK, 0)))57 if (!(t = thread_create(threadtest, NULL, TASK, 0, "threadtest"))) 58 58 panic("could not create thread\n"); 59 59 thread_ready(t);
Note:
See TracChangeset
for help on using the changeset viewer.