Lines Matching refs:thread
49 osi_thread_t *thread; member
59 osi_thread_t *thread; member
149 osi_thread_t *thread = start->thread; in osi_thread_run() local
156 osi_sem_take(&thread->work_sem, OSI_SEM_MAX_TIMEOUT); in osi_thread_run()
158 if (thread->stop) { in osi_thread_run()
163 while (!thread->stop && idx < thread->work_queue_num) { in osi_thread_run()
164 if (osi_thead_work_queue_get(thread->work_queues[idx], &item) == true) { in osi_thread_run()
174 thread->thread_handle = NULL; in osi_thread_run()
175 osi_sem_give(&thread->stop_sem); in osi_thread_run()
180 static int osi_thread_join(osi_thread_t *thread, uint32_t wait_ms) in osi_thread_join() argument
182 assert(thread != NULL); in osi_thread_join()
183 return osi_sem_take(&thread->stop_sem, wait_ms); in osi_thread_join()
186 static void osi_thread_stop(osi_thread_t *thread) in osi_thread_stop() argument
190 assert(thread != NULL); in osi_thread_stop()
193 thread->stop = true; in osi_thread_stop()
194 osi_sem_give(&thread->work_sem); in osi_thread_stop()
197 ret = osi_thread_join(thread, 1000); //wait 1000ms in osi_thread_stop()
200 if (ret != 0 && thread->thread_handle) { in osi_thread_stop()
201 vTaskDelete(thread->thread_handle); in osi_thread_stop()
217 osi_thread_t *thread = (osi_thread_t *)osi_calloc(sizeof(osi_thread_t)); in osi_thread_create() local
218 if (thread == NULL) { in osi_thread_create()
222 thread->stop = false; in osi_thread_create()
223 …thread->work_queues = (struct work_queue **)osi_calloc(sizeof(struct work_queue *) * work_queue_nu… in osi_thread_create()
224 if (thread->work_queues == NULL) { in osi_thread_create()
227 thread->work_queue_num = work_queue_num; in osi_thread_create()
229 for (int i = 0; i < thread->work_queue_num; i++) { in osi_thread_create()
231 thread->work_queues[i] = osi_work_queue_create(queue_len); in osi_thread_create()
232 if (thread->work_queues[i] == NULL) { in osi_thread_create()
237 ret = osi_sem_new(&thread->work_sem, 1, 0); in osi_thread_create()
242 ret = osi_sem_new(&thread->stop_sem, 1, 0); in osi_thread_create()
247 start_arg.thread = thread; in osi_thread_create()
253 …if (xTaskCreatePinnedToCore(osi_thread_run, name, stack_size, &start_arg, priority, &thread->threa… in osi_thread_create()
260 return thread; in osi_thread_create()
264 if (thread) { in osi_thread_create()
269 if (thread->thread_handle) { in osi_thread_create()
270 vTaskDelete(thread->thread_handle); in osi_thread_create()
273 for (int i = 0; i < thread->work_queue_num; i++) { in osi_thread_create()
274 if (thread->work_queues && thread->work_queues[i]) { in osi_thread_create()
275 osi_work_queue_delete(thread->work_queues[i]); in osi_thread_create()
276 thread->work_queues[i] = NULL; in osi_thread_create()
280 if (thread->work_queues) { in osi_thread_create()
281 osi_free(thread->work_queues); in osi_thread_create()
282 thread->work_queues = NULL; in osi_thread_create()
285 if (thread->work_sem) { in osi_thread_create()
286 osi_sem_free(&thread->work_sem); in osi_thread_create()
289 if (thread->stop_sem) { in osi_thread_create()
290 osi_sem_free(&thread->stop_sem); in osi_thread_create()
293 osi_free(thread); in osi_thread_create()
299 void osi_thread_free(osi_thread_t *thread) in osi_thread_free() argument
301 if (!thread) in osi_thread_free()
304 osi_thread_stop(thread); in osi_thread_free()
306 for (int i = 0; i < thread->work_queue_num; i++) { in osi_thread_free()
307 if (thread->work_queues[i]) { in osi_thread_free()
308 osi_work_queue_delete(thread->work_queues[i]); in osi_thread_free()
309 thread->work_queues[i] = NULL; in osi_thread_free()
313 if (thread->work_queues) { in osi_thread_free()
314 osi_free(thread->work_queues); in osi_thread_free()
315 thread->work_queues = NULL; in osi_thread_free()
318 if (thread->work_sem) { in osi_thread_free()
319 osi_sem_free(&thread->work_sem); in osi_thread_free()
322 if (thread->stop_sem) { in osi_thread_free()
323 osi_sem_free(&thread->stop_sem); in osi_thread_free()
327 osi_free(thread); in osi_thread_free()
330 bool osi_thread_post(osi_thread_t *thread, osi_thread_func_t func, void *context, int queue_idx, ui… in osi_thread_post() argument
332 assert(thread != NULL); in osi_thread_post()
335 if (queue_idx >= thread->work_queue_num) { in osi_thread_post()
344 if (osi_thead_work_queue_put(thread->work_queues[queue_idx], &item, timeout) == false) { in osi_thread_post()
348 osi_sem_give(&thread->work_sem); in osi_thread_post()
353 bool osi_thread_set_priority(osi_thread_t *thread, int priority) in osi_thread_set_priority() argument
355 assert(thread != NULL); in osi_thread_set_priority()
357 vTaskPrioritySet(thread->thread_handle, priority); in osi_thread_set_priority()
361 const char *osi_thread_name(osi_thread_t *thread) in osi_thread_name() argument
363 assert(thread != NULL); in osi_thread_name()
365 return pcTaskGetName(thread->thread_handle); in osi_thread_name()
368 int osi_thread_queue_wait_size(osi_thread_t *thread, int wq_idx) in osi_thread_queue_wait_size() argument
370 if (wq_idx < 0 || wq_idx >= thread->work_queue_num) { in osi_thread_queue_wait_size()
374 return (int)(osi_thead_work_queue_len(thread->work_queues[wq_idx])); in osi_thread_queue_wait_size()
402 bool osi_event_bind(struct osi_event* event, osi_thread_t *thread, int queue_idx) in osi_event_bind() argument
404 if (event == NULL || event->thread != NULL) { in osi_event_bind()
408 if (thread == NULL || queue_idx >= thread->work_queue_num) { in osi_event_bind()
412 event->thread = thread; in osi_event_bind()
431 assert(event != NULL && event->thread != NULL); in osi_thread_post_event()
432 assert(event->queue_idx >= 0 && event->queue_idx < event->thread->work_queue_num); in osi_thread_post_event()
442 …ret = osi_thread_post(event->thread, osi_thread_generic_event_handler, event, event->queue_idx, ti… in osi_thread_post_event()