POSIX Threads for Embedded and Real-Time Developers

An important POSIX® concept is the distinction between “threads” and “processes.”

threads00a

Threads are schedulable entities that run within a process. (Visit here if you missed our introduction to POSIX processes.) Each process will have one main thread, and it may also have several more threads which share the address space of the process invoked via pthread_create(). A POSIX system call will refer to a process ID or to a thread ID—these IDs are not interchangeable.

Note that some operating systems simply refer to “tasks” instead of distinguishing between “threads” and “processes.” Such an operating system probably does not support the POSIX standard, and would not be able to run calls which refer to a process (such as signals).

How POSIX Threads Work

  • A thread is a flow-of-control that runs within a process context.
  • Threads in the same process share the same virtual address space. They can communicate and share data
    using globals.
  • Threads are the running entities of LynxOS®.
  • Threads do not have a parent-child relationship with each other.
  • Any thread created within a process can terminate itself or can read the exit status of any other thread.
  • Exception: If any thread calls exit(), the process terminates. All threads in the process are then terminated.
  • Each process has its own protected address space. Communications between processes require kernel services.

Lynx Software Technologies also supports kernel threads and has been awarded a patent for its unique approach to handling hardware events in a real-time environment. Learn how LynxOS patented technology speeds handling of hardware events for real-time systems.

POSIX thread-exit functions
Function Main
Thread
Other
Threads
return(), }
or pthread_exit()
All die This thread dies
exit() or _exit() All die All die