Changeset aab5e46 in mainline
- Timestamp:
- 2018-11-03T23:32:39Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 790f3a3
- Parents:
- ef1eab7
- Location:
- kernel
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/proc/task.h
ref1eab7 raab5e46 158 158 extern void task_release(task_t *); 159 159 extern task_t *task_find_by_id(task_id_t); 160 extern size_t task_count(void); 161 extern task_t *task_first(void); 162 extern task_t *task_next(task_t *); 160 163 extern errno_t task_kill(task_id_t); 161 164 extern void task_kill_self(bool) __attribute__((noreturn)); -
kernel/generic/include/proc/thread.h
ref1eab7 raab5e46 261 261 extern void thread_destroy(thread_t *, bool); 262 262 extern thread_t *thread_find_by_id(thread_id_t); 263 extern size_t thread_count(void); 264 extern thread_t *thread_first(void); 265 extern thread_t *thread_next(thread_t *); 263 266 extern void thread_update_accounting(bool); 264 267 extern bool thread_exists(thread_t *); -
kernel/generic/src/proc/task.c
ref1eab7 raab5e46 107 107 { 108 108 size_t tasks_left; 109 odlink_t *odlink;110 109 task_t *task; 111 110 … … 128 127 tasks_left = 0; 129 128 130 odlink = odict_first(&tasks); 131 while (odlink != NULL) { 132 task = odict_get_instance(odlink, task_t, ltasks); 133 129 task = task_first(); 130 while (task != NULL) { 134 131 if (task != TASK) { 135 132 tasks_left++; … … 140 137 } 141 138 142 odlink = odict_next(odlink, &tasks);139 task = task_next(task); 143 140 } 144 141 … … 452 449 } 453 450 451 /** Get count of tasks. 452 * 453 * @return Number of tasks in the system 454 */ 455 size_t task_count(void) 456 { 457 assert(interrupts_disabled()); 458 assert(irq_spinlock_locked(&tasks_lock)); 459 460 return odict_count(&tasks); 461 } 462 463 /** Get first task (task with lowest ID). 464 * 465 * @return Pointer to first task or @c NULL if there are none. 466 */ 467 task_t *task_first(void) 468 { 469 odlink_t *odlink; 470 471 assert(interrupts_disabled()); 472 assert(irq_spinlock_locked(&tasks_lock)); 473 474 odlink = odict_first(&tasks); 475 if (odlink == NULL) 476 return NULL; 477 478 return odict_get_instance(odlink, task_t, ltasks); 479 } 480 481 /** Get next task (with higher task ID). 482 * 483 * @param cur Current task 484 * @return Pointer to next task or @c NULL if there are no more tasks. 485 */ 486 task_t *task_next(task_t *cur) 487 { 488 odlink_t *odlink; 489 490 assert(interrupts_disabled()); 491 assert(irq_spinlock_locked(&tasks_lock)); 492 493 odlink = odict_next(&cur->ltasks, &tasks); 494 if (odlink == NULL) 495 return NULL; 496 497 return odict_get_instance(odlink, task_t, ltasks); 498 } 499 454 500 /** Get accounting data of given task. 455 501 * … … 658 704 #endif 659 705 660 odlink_t *odlink;661 706 task_t *task; 662 707 663 odlink = odict_first(&tasks); 664 while (odlink != NULL) { 665 task = odict_get_instance(odlink, task_t, ltasks); 708 task = task_first(); 709 while (task != NULL) { 666 710 task_print(task, additional); 667 odlink = odict_next(odlink, &tasks);711 task = task_next(task); 668 712 } 669 713 -
kernel/generic/src/proc/thread.c
ref1eab7 raab5e46 772 772 void thread_print_list(bool additional) 773 773 { 774 odlink_t *odlink;775 774 thread_t *thread; 776 775 … … 796 795 #endif 797 796 798 odlink = odict_first(&threads); 799 while (odlink != NULL) { 800 thread = odict_get_instance(odlink, thread_t, lthreads); 797 thread = thread_first(); 798 while (thread != NULL) { 801 799 thread_print(thread, additional); 802 odlink = odict_next(odlink, &threads);800 thread = thread_next(thread); 803 801 } 804 802 … … 860 858 thread_t *thread_find_by_id(thread_id_t thread_id) 861 859 { 862 odlink_t *odlink;863 860 thread_t *thread; 864 861 … … 866 863 assert(irq_spinlock_locked(&threads_lock)); 867 864 868 odlink = odict_first(&threads); 869 while (odlink != NULL) { 870 thread = odict_get_instance(odlink, thread_t, lthreads); 865 thread = thread_first(); 866 while (thread != NULL) { 871 867 if (thread->tid == thread_id) 872 868 return thread; 873 869 874 odlink = odict_next(odlink, &threads);870 thread = thread_next(thread); 875 871 } 876 872 877 873 return NULL; 874 } 875 876 /** Get count of threads. 877 * 878 * @return Number of threads in the system 879 */ 880 size_t thread_count(void) 881 { 882 assert(interrupts_disabled()); 883 assert(irq_spinlock_locked(&threads_lock)); 884 885 return odict_count(&threads); 886 } 887 888 /** Get first thread. 889 * 890 * @return Pointer to first thread or @c NULL if there are none. 891 */ 892 thread_t *thread_first(void) 893 { 894 odlink_t *odlink; 895 896 assert(interrupts_disabled()); 897 assert(irq_spinlock_locked(&threads_lock)); 898 899 odlink = odict_first(&threads); 900 if (odlink == NULL) 901 return NULL; 902 903 return odict_get_instance(odlink, thread_t, lthreads); 904 } 905 906 /** Get next thread. 907 * 908 * @param cur Current thread 909 * @return Pointer to next thread or @c NULL if there are no more threads. 910 */ 911 thread_t *thread_next(thread_t *cur) 912 { 913 odlink_t *odlink; 914 915 assert(interrupts_disabled()); 916 assert(irq_spinlock_locked(&threads_lock)); 917 918 odlink = odict_next(&cur->lthreads, &threads); 919 if (odlink == NULL) 920 return NULL; 921 922 return odict_get_instance(odlink, thread_t, lthreads); 878 923 } 879 924 -
kernel/generic/src/sysinfo/stats.c
ref1eab7 raab5e46 246 246 247 247 /* Count the tasks */ 248 size_t count = odict_count(&tasks);248 size_t count = task_count(); 249 249 250 250 if (count == 0) { … … 271 271 /* Gather the statistics for each task */ 272 272 size_t i = 0; 273 odlink_t *odlink = odict_first(&tasks); 274 while (odlink != NULL) { 275 task_t *task = odict_get_instance(odlink, task_t, ltasks); 276 273 task_t *task = task_first(); 274 while (task != NULL) { 277 275 /* Interrupts are already disabled */ 278 276 irq_spinlock_lock(&(task->lock), false); … … 283 281 284 282 irq_spinlock_unlock(&(task->lock), false); 285 odlink = odict_next(odlink, &tasks);283 task = task_next(task); 286 284 } 287 285 … … 336 334 337 335 /* Count the threads */ 338 size_t count = odict_count(&threads);336 size_t count = thread_count(); 339 337 340 338 if (count == 0) { … … 362 360 size_t i = 0; 363 361 364 odlink_t *odlink = odict_first(&threads); 365 while (odlink != NULL) { 366 thread_t *thread = odict_get_instance(odlink, thread_t, 367 lthreads); 368 362 thread_t *thread = thread_first(); 363 while (thread != NULL) { 369 364 /* Interrupts are already disabled */ 370 365 irq_spinlock_lock(&thread->lock, false); … … 376 371 irq_spinlock_unlock(&thread->lock, false); 377 372 378 odlink = odict_next(odlink, &threads);373 thread = thread_next(thread); 379 374 } 380 375 -
kernel/test/mm/falloc2.c
ref1eab7 raab5e46 43 43 #define THREADS 8 44 44 45 static atomic_t thread_c ount;45 static atomic_t thread_cnt; 46 46 static atomic_t thread_fail; 47 47 … … 56 56 "Unable to allocate frames\n", THREAD->tid, CPU->id); 57 57 atomic_inc(&thread_fail); 58 atomic_dec(&thread_c ount);58 atomic_dec(&thread_cnt); 59 59 return; 60 60 } … … 110 110 TPRINTF("Thread #%" PRIu64 " (cpu%u): Exiting\n", 111 111 THREAD->tid, CPU->id); 112 atomic_dec(&thread_c ount);112 atomic_dec(&thread_cnt); 113 113 } 114 114 115 115 const char *test_falloc2(void) 116 116 { 117 atomic_store(&thread_c ount, THREADS);117 atomic_store(&thread_cnt, THREADS); 118 118 atomic_store(&thread_fail, 0); 119 119 … … 128 128 } 129 129 130 while (atomic_load(&thread_c ount) > 0) {130 while (atomic_load(&thread_cnt) > 0) { 131 131 TPRINTF("Threads left: %zu\n", 132 atomic_load(&thread_c ount));132 atomic_load(&thread_cnt)); 133 133 thread_sleep(1); 134 134 }
Note:
See TracChangeset
for help on using the changeset viewer.