MCPcopy Create free account
hub / github.com/apache/nuttx / work_queue_create

Function work_queue_create

sched/wqueue/kwork_thread.c:401–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

399 ****************************************************************************/
400
401FAR struct kwork_wqueue_s *work_queue_create(FAR const char *name,
402 int priority,
403 FAR void *stack_addr,
404 int stack_size, int nthreads)
405{
406 FAR struct kwork_wqueue_s *wqueue;
407 int ret;
408
409 if (nthreads < 1)
410 {
411 return NULL;
412 }
413
414 /* Allocate a new work queue */
415
416 wqueue = kmm_zalloc(sizeof(struct kwork_wqueue_s) +
417 nthreads * sizeof(struct kworker_s));
418 if (wqueue == NULL)
419 {
420 return NULL;
421 }
422
423 /* Initialize the work queue structure */
424
425 list_initialize(&wqueue->expired);
426 list_initialize(&wqueue->pending);
427 wqueue->timer.func = NULL;
428 nxsem_init(&wqueue->sem, 0, 0);
429 nxsem_init(&wqueue->exsem, 0, 0);
430 wqueue->nthreads = nthreads;
431 spin_lock_init(&wqueue->lock);
432
433 /* Create the work queue thread pool */
434
435 ret = work_thread_create(name, priority, stack_addr, stack_size, wqueue);
436 if (ret < 0)
437 {
438 kmm_free(wqueue);
439 return NULL;
440 }
441
442 return wqueue;
443}
444
445/****************************************************************************
446 * Name: work_queue_free

Callers 3

up_irqinitializeFunction · 0.85
irq_get_wqueueFunction · 0.85
rpmsgdev_server_initFunction · 0.85

Calls 4

kmm_zallocFunction · 0.85
nxsem_initFunction · 0.85
work_thread_createFunction · 0.85
kmm_freeFunction · 0.85

Tested by

no test coverage detected