Skip to content

Pthread Interfaces

NuttX does not support processes in the way that, say, Linux does. NuttX only supports simple threads or tasks running within the same address space. However, NuttX does support the concept of a task group. A task group is the functional analog of a process: It is a group that consists of the main task thread and of all of the pthreads created by the main thread or any of the other pthreads within the task group. Members of a task group share certain resources such as environment variables, file descriptors, FILE streams, sockets, pthread keys and open message queues.

Note

Behavior of features related to task groups depend of NuttX configuration settings. See also theNuttX Taskingpage and theTasks vs. Threads FAQfor additional information on tasks and threads in NuttX.

The following pthread interfaces are supported in some form by NuttX:

pthread control interfaces. Interfaces that allow you to create and manage pthreads.

  • :cpthread_attr_init
  • :cpthread_attr_destroy
  • :cpthread_attr_setschedpolicy
  • :cpthread_attr_getschedpolicy
  • :cpthread_attr_setschedparam
  • :cpthread_attr_getschedparam
  • :cpthread_attr_setinheritsched
  • :cpthread_attr_getinheritsched
  • :cpthread_attr_setstacksize
  • :cpthread_attr_getstacksize
  • :cpthread_create
  • :cpthread_detach
  • :cpthread_exit
  • :cpthread_cancel
  • :cpthread_setcancelstate
  • :cpthread_setcanceltype
  • :cpthread_testcancel
  • :cpthread_cleanup_pop
  • :cpthread_cleanup_push
  • :cpthread_join
  • :cpthread_yield
  • :cpthread_self
  • :cpthread_getschedparam
  • :cpthread_setschedparam

Thread Specific Data. These interfaces can be used to create pthread keys and then to access thread-specific data using these keys. Each task group has its own set of pthread keys. NOTES: (1) pthread keys create in one task group are not accessible in other task groups. (2) The main task thread does not have thread-specific data.

  • :cpthread_key_create
  • :cpthread_setspecific
  • :cpthread_getspecific
  • :cpthread_key_delete

pthread Mutexes.

  • :cpthread_mutexattr_init
  • :cpthread_mutexattr_destroy
  • :cpthread_mutexattr_getpshared
  • :cpthread_mutexattr_setpshared
  • :cpthread_mutexattr_gettype
  • :cpthread_mutexattr_settype
  • :cpthread_mutexattr_getprotocol
  • :cpthread_mutexattr_setprotocol
  • :cpthread_mutex_init
  • :cpthread_mutex_destroy
  • :cpthread_mutex_lock
  • :cpthread_mutex_timedlock
  • :cpthread_mutex_trylock
  • :cpthread_mutex_unlock

Condition Variables.

  • :cpthread_condattr_init
  • :cpthread_condattr_destroy
  • :cpthread_cond_init
  • :cpthread_cond_destroy
  • :cpthread_cond_broadcast
  • :cpthread_cond_signal
  • :cpthread_cond_wait
  • :cpthread_cond_timedwait

Barriers.

  • :cpthread_barrierattr_init
  • :cpthread_barrierattr_destroy
  • :cpthread_barrierattr_setpshared
  • :cpthread_barrierattr_getpshared
  • :cpthread_barrier_init
  • :cpthread_barrier_destroy
  • :cpthread_barrier_wait

Initialization.

  • :cpthread_once

Signals.

  • :cpthread_kill
  • :cpthread_sigmask

No support for the following pthread interfaces is provided by NuttX:

  • pthread_attr_getguardsize. get and set the thread guardsize attribute.
  • pthread_attr_getscope. get and set the contentionscope attribute.
  • pthread_attr_setguardsize. get and set the thread guardsize attribute.
  • pthread_attr_setscope. get and set the contentionscope attribute.
  • pthread_getconcurrency. get and set the level of concurrency.
  • pthread_getcpuclockid. access a thread CPU-time clock.
  • pthread_mutex_getprioceiling. get and set the priority ceiling of a mutex.
  • pthread_mutex_setprioceiling. get and set the priority ceiling of a mutex.
  • pthread_mutexattr_getprioceiling. get and set the prioceiling attribute of the mutex attributes object.
  • pthread_mutexattr_setprioceiling. get and set the prioceiling attribute of the mutex attributes object.
  • pthread_setconcurrency. get and set the level of concurrency.