Changeset aab5e46 in mainline for kernel/generic/src/proc/thread.c
- Timestamp:
- 2018-11-03T23:32:39Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 790f3a3
- Parents:
- ef1eab7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.