Revision e7c4f797 core/src/aos_thread.c
core/src/aos_thread.c | ||
---|---|---|
103 | 103 |
} |
104 | 104 |
#endif /* (AMIROOS_CFG_DBG == true) && (CH_DBG_FILL_THREADS == TRUE) */ |
105 | 105 |
|
106 |
#if ((CH_CFG_USE_REGISTRY == TRUE) || (CH_CFG_USE_THREADHIERARCHY == TRUE)) || defined(__DOXYGEN__) |
|
107 |
|
|
108 |
/** |
|
109 |
* @brief Retrieve the first/root thread in the system. |
|
110 |
* |
|
111 |
* @return Pointer to the first/root thread. |
|
112 |
*/ |
|
113 |
thread_t* aosThreadGetFirst(void) |
|
114 |
{ |
|
115 |
#if (CH_CFG_USE_REGISTRY == TRUE) |
|
116 |
return chRegFirstThread(); |
|
117 |
#elif (CH_CFG_USE_THREADHIERARCHY == TRUE) |
|
118 |
thread_t* tp = chThdGetSelfX(); |
|
119 |
while (tp->parent) { |
|
120 |
tp = tp->parent; |
|
121 |
} |
|
122 |
return tp; |
|
123 |
#endif |
|
124 |
} |
|
125 |
|
|
126 |
/** |
|
127 |
* @brief Retrieve the next thread in the system. |
|
128 |
* |
|
129 |
* @param[in] thread Current thread to retrieve the 'successor' to. |
|
130 |
* |
|
131 |
* @return Pointer to the next thread, or NULL if there are no further threads. |
|
132 |
*/ |
|
133 |
thread_t* aosThreadGetNext(thread_t* thread) |
|
134 |
{ |
|
135 |
aosDbgCheck(thread != NULL); |
|
136 |
|
|
137 |
#if (CH_CFG_USE_REGISTRY == TRUE) |
|
138 |
return chRegNextThread(thread); |
|
139 |
#elif (CH_CFG_USE_THREADHIERARCHY == TRUE) |
|
140 |
if (thread->children != NULL) { |
|
141 |
return thread->children; |
|
142 |
} else { |
|
143 |
while (thread != NULL && thread->sibling == NULL) { |
|
144 |
thread = thread->parent; |
|
145 |
} |
|
146 |
return (thread != NULL) ? thread->sibling : NULL; |
|
147 |
} |
|
148 |
#endif |
|
149 |
} |
|
150 |
|
|
151 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) || (CH_CFG_USE_THREADHIERARCHY == TRUE) */ |
|
152 |
|
|
106 | 153 |
/** @} */ |
Also available in: Unified diff