Changeset 0f4f1b2 in mainline
- Timestamp:
- 2024-01-15T17:10:27Z (10 months ago)
- Branches:
- master
- Children:
- e82879c
- Parents:
- a064d4f
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-15 16:37:22)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-15 17:10:27)
- Location:
- kernel
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia64/src/drivers/ski.c
ra064d4f r0f4f1b2 258 258 259 259 instance->srlnin = srlnin; 260 thread_ ready(instance->thread);260 thread_start(instance->thread); 261 261 262 262 sysinfo_set_item_val("kbd", NULL, true); -
kernel/arch/sparc64/src/drivers/niagara.c
ra064d4f r0f4f1b2 253 253 254 254 instance->srlnin = srln; 255 thread_ ready(instance->thread);255 thread_start(instance->thread); 256 256 } 257 257 } -
kernel/genarch/src/kbrd/kbrd.c
ra064d4f r0f4f1b2 200 200 201 201 instance->sink = sink; 202 thread_ ready(instance->thread);202 thread_start(instance->thread); 203 203 204 204 return &instance->raw; -
kernel/genarch/src/kbrd/kbrd_at.c
ra064d4f r0f4f1b2 198 198 199 199 instance->sink = sink; 200 thread_ ready(instance->thread);200 thread_start(instance->thread); 201 201 202 202 return &instance->raw; -
kernel/genarch/src/srln/srln.c
ra064d4f r0f4f1b2 156 156 157 157 instance->sink = sink; 158 thread_ ready(instance->thread);158 thread_start(instance->thread); 159 159 160 160 return &instance->raw; -
kernel/generic/include/proc/thread.h
ra064d4f r0f4f1b2 185 185 extern void thread_wire(thread_t *, cpu_t *); 186 186 extern void thread_attach(thread_t *, task_t *); 187 extern void thread_start(thread_t *); 187 188 extern void thread_ready(thread_t *); 188 189 extern void thread_exit(void) __attribute__((noreturn)); … … 242 243 extern errno_t thread_join(thread_t *); 243 244 extern errno_t thread_join_timeout(thread_t *, uint32_t, unsigned int); 245 extern void thread_detach(thread_t *); 244 246 245 247 extern void thread_yield(void); -
kernel/generic/src/console/cmd.c
ra064d4f r0f4f1b2 1004 1004 printf("cpu%u: ", i); 1005 1005 thread_wire(thread, &cpus[i]); 1006 thread_ ready(thread_ref(thread));1006 thread_start(thread); 1007 1007 thread_join(thread); 1008 1008 } else -
kernel/generic/src/ipc/kbox.c
ra064d4f r0f4f1b2 246 246 } 247 247 248 task->kb.thread = thread_ref(kb_thread);249 thread_ ready(kb_thread);248 task->kb.thread = kb_thread; 249 thread_start(kb_thread); 250 250 } 251 251 -
kernel/generic/src/main/kinit.c
ra064d4f r0f4f1b2 122 122 123 123 thread_wire(thread, &cpus[0]); 124 thread_ ready(thread_ref(thread));124 thread_start(thread); 125 125 thread_join(thread); 126 126 … … 135 135 if (thread != NULL) { 136 136 thread_wire(thread, &cpus[i]); 137 thread_ready(thread); 137 thread_start(thread); 138 thread_detach(thread); 138 139 } else 139 140 log(LF_OTHER, LVL_ERROR, … … 151 152 thread = thread_create(kload, NULL, TASK, THREAD_FLAG_NONE, 152 153 "kload"); 153 if (thread != NULL) 154 thread_ready(thread); 155 else 154 if (thread != NULL) { 155 thread_start(thread); 156 thread_detach(thread); 157 } else { 156 158 log(LF_OTHER, LVL_ERROR, "Unable to create kload thread"); 159 } 157 160 158 161 #ifdef CONFIG_KCONSOLE … … 163 166 thread = thread_create(kconsole_thread, NULL, TASK, 164 167 THREAD_FLAG_NONE, "kconsole"); 165 if (thread != NULL) 166 thread_ready(thread); 167 else 168 if (thread != NULL) { 169 thread_start(thread); 170 thread_detach(thread); 171 } else { 168 172 log(LF_OTHER, LVL_ERROR, 169 173 "Unable to create kconsole thread"); 174 } 170 175 } 171 176 #endif /* CONFIG_KCONSOLE */ -
kernel/generic/src/main/main.c
ra064d4f r0f4f1b2 282 282 if (!kinit_thread) 283 283 panic("Cannot create kinit thread."); 284 thread_ready(kinit_thread); 284 thread_start(kinit_thread); 285 thread_detach(kinit_thread); 285 286 286 287 /* -
kernel/generic/src/proc/program.c
ra064d4f r0f4f1b2 212 212 void program_ready(program_t *prg) 213 213 { 214 thread_ready(prg->main_thread); 214 thread_start(prg->main_thread); 215 thread_detach(prg->main_thread); 215 216 prg->main_thread = NULL; 216 217 } -
kernel/generic/src/proc/thread.c
ra064d4f r0f4f1b2 234 234 } 235 235 236 /** Start a thread that wasn't started yet since it was created. 237 * 238 * @param thread A reference to the newly created thread. 239 */ 240 void thread_start(thread_t *thread) 241 { 242 assert(thread->state == Entering); 243 thread_ready(thread_ref(thread)); 244 } 245 236 246 /** Make thread ready 237 247 * … … 696 706 errno_t thread_join_timeout(thread_t *thread, uint32_t usec, unsigned int flags) 697 707 { 708 assert(thread != NULL); 709 698 710 if (thread == THREAD) 699 711 return EINVAL; … … 712 724 713 725 return rc; 726 } 727 728 void thread_detach(thread_t *thread) 729 { 730 thread_put(thread); 714 731 } 715 732 -
kernel/test/mm/falloc2.c
ra064d4f r0f4f1b2 43 43 #define THREADS 8 44 44 45 static atomic_size_t thread_cnt;46 45 static atomic_size_t thread_fail; 47 46 … … 56 55 "Unable to allocate frames\n", THREAD->tid, CPU->id); 57 56 atomic_inc(&thread_fail); 58 atomic_dec(&thread_cnt);59 57 return; 60 58 } … … 108 106 TPRINTF("Thread #%" PRIu64 " (cpu%u): Exiting\n", 109 107 THREAD->tid, CPU->id); 110 atomic_dec(&thread_cnt);111 108 } 112 109 113 110 const char *test_falloc2(void) 114 111 { 115 atomic_store(&thread_cnt, THREADS);116 112 atomic_store(&thread_fail, 0); 113 114 thread_t *threads[THREADS] = { }; 117 115 118 116 for (unsigned int i = 0; i < THREADS; i++) { … … 123 121 break; 124 122 } 125 thread_ready(thrd); 123 thread_start(thrd); 124 threads[i] = thrd; 126 125 } 127 126 128 while (atomic_load(&thread_cnt) > 0) { 129 TPRINTF("Threads left: %zu\n", 130 atomic_load(&thread_cnt)); 131 thread_sleep(1); 127 for (unsigned int i = 0; i < THREADS; i++) { 128 if (threads[i] != NULL) 129 thread_join(threads[i]); 130 131 TPRINTF("Threads left: %u\n", THREADS - i - 1); 132 132 } 133 133 -
kernel/test/mm/slab1.c
ra064d4f r0f4f1b2 121 121 static void *thr_data[THREADS][THR_MEM_COUNT]; 122 122 static slab_cache_t *thr_cache; 123 static semaphore_t thr_sem;124 123 125 124 static void slabtest(void *data) … … 142 141 143 142 TPRINTF("Thread #%" PRIu64 " finished\n", THREAD->tid); 144 145 semaphore_up(&thr_sem);146 143 } 147 144 148 145 static void testthreads(void) 149 146 { 150 thread_t *t;151 int i;152 153 147 thr_cache = slab_cache_create("thread_cache", THR_MEM_SIZE, 0, NULL, NULL, 154 148 SLAB_CACHE_NOMAGAZINE); 155 149 156 semaphore_initialize(&thr_sem, 0); 157 for (i = 0; i < THREADS; i++) { 158 if (!(t = thread_create(slabtest, (void *) (sysarg_t) i, TASK, THREAD_FLAG_NONE, "slabtest"))) { 150 thread_t *threads[THREADS] = { }; 151 152 for (int i = 0; i < THREADS; i++) { 153 threads[i] = thread_create(slabtest, (void *) (sysarg_t) i, 154 TASK, THREAD_FLAG_NONE, "slabtest"); 155 if (threads[i]) { 156 thread_start(threads[i]); 157 } else { 159 158 TPRINTF("Could not create thread %d\n", i); 160 } else 161 thread_ready(t); 159 } 162 160 } 163 161 164 for (i = 0; i < THREADS; i++) 165 semaphore_down(&thr_sem); 162 for (int i = 0; i < THREADS; i++) { 163 if (threads[i] != NULL) 164 thread_join(threads[i]); 165 } 166 166 167 167 slab_cache_destroy(thr_cache); -
kernel/test/mm/slab2.c
ra064d4f r0f4f1b2 127 127 128 128 static slab_cache_t *thr_cache; 129 static semaphore_t thr_sem;130 129 static condvar_t thread_starter; 131 130 static mutex_t starter_mutex; … … 188 187 if (!test_quiet) 189 188 slab_print_list(); 190 191 semaphore_up(&thr_sem);192 189 } 193 190 … … 198 195 * then release everything, then again allocate, then release 199 196 */ 200 thread_t *t;201 int i;202 197 203 198 TPRINTF("Running stress test with size %d\n", size); … … 207 202 208 203 thr_cache = slab_cache_create("thread_cache", size, 0, NULL, NULL, 0); 209 semaphore_initialize(&thr_sem, 0); 210 for (i = 0; i < THREADS; i++) { 211 if (!(t = thread_create(slabtest, NULL, TASK, THREAD_FLAG_NONE, "slabtest"))) { 204 205 thread_t *threads[THREADS] = { }; 206 207 for (int i = 0; i < THREADS; i++) { 208 threads[i] = thread_create(slabtest, NULL, 209 TASK, THREAD_FLAG_NONE, "slabtest"); 210 if (threads[i]) { 211 thread_start(threads[i]); 212 } else { 212 213 TPRINTF("Could not create thread %d\n", i); 213 } else214 thread_ready(t);215 } 214 } 215 } 216 216 217 thread_sleep(1); 217 218 condvar_broadcast(&thread_starter); 218 219 219 for (i = 0; i < THREADS; i++) 220 semaphore_down(&thr_sem); 220 for (int i = 0; i < THREADS; i++) { 221 if (threads[i] != NULL) 222 thread_join(threads[i]); 223 } 221 224 222 225 slab_cache_destroy(thr_cache); -
kernel/test/synch/semaphore1.c
ra064d4f r0f4f1b2 89 89 thrd = thread_create(consumer, NULL, TASK, 90 90 THREAD_FLAG_NONE, "consumer"); 91 if (thrd) 92 thread_ready(thrd); 93 else 91 if (thrd) { 92 thread_start(thrd); 93 thread_detach(thrd); 94 } else { 94 95 TPRINTF("could not create consumer %d\n", i); 96 } 95 97 } 96 98 for (k = 0; k < (4 - i); k++) { 97 99 thrd = thread_create(producer, NULL, TASK, 98 100 THREAD_FLAG_NONE, "producer"); 99 if (thrd) 100 thread_ready(thrd); 101 else 101 if (thrd) { 102 thread_start(thrd); 103 thread_detach(thrd); 104 } else { 102 105 TPRINTF("could not create producer %d\n", i); 106 } 103 107 } 104 108 } -
kernel/test/synch/semaphore2.c
ra064d4f r0f4f1b2 92 92 thrd = thread_create(consumer, NULL, TASK, 93 93 THREAD_FLAG_NONE, "consumer"); 94 if (thrd) 95 thread_ready(thrd); 96 else 94 if (thrd) { 95 thread_start(thrd); 96 thread_detach(thrd); 97 } else { 97 98 TPRINTF("Error creating thread\n"); 99 } 98 100 } 99 101 -
kernel/test/thread/thread1.c
ra064d4f r0f4f1b2 38 38 39 39 static atomic_bool finish; 40 static atomic_size_t threads_finished;41 40 42 41 static void threadtest(void *data) … … 46 45 thread_usleep(100000); 47 46 } 48 atomic_inc(&threads_finished);49 47 } 50 48 51 49 const char *test_thread1(void) 52 50 { 53 unsigned int i; 54 size_t total = 0; 51 atomic_store(&finish, true); 55 52 56 atomic_store(&finish, true); 57 atomic_store(&threads_finished, 0); 53 thread_t *threads[THREADS] = { }; 58 54 59 for (i = 0; i < THREADS; i++) { 60 thread_t *t; 61 if (!(t = thread_create(threadtest, NULL, TASK, 62 THREAD_FLAG_NONE, "threadtest"))) { 55 for (int i = 0; i < THREADS; i++) { 56 threads[i] = thread_create(threadtest, NULL, 57 TASK, THREAD_FLAG_NONE, "threadtest"); 58 59 if (threads[i]) { 60 thread_start(threads[i]); 61 } else { 63 62 TPRINTF("Could not create thread %d\n", i); 64 63 break; 65 64 } 66 thread_ready(t);67 total++;68 65 } 69 66 … … 72 69 73 70 atomic_store(&finish, false); 74 while (atomic_load(&threads_finished) < total) { 75 TPRINTF("Threads left: %zu\n", total - atomic_load(&threads_finished)); 76 thread_sleep(1); 71 72 for (int i = 0; i < THREADS; i++) { 73 if (threads[i] != NULL) 74 thread_join(threads[i]); 75 76 TPRINTF("Threads left: %d\n", THREADS - i - 1); 77 77 } 78 78
Note:
See TracChangeset
for help on using the changeset viewer.