Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.


From Texas Instruments Wiki
Jump to: navigation, search

A function is thread safe if it can safely be invoked again while another instance of the function in another thread or process is active.

The concept of thread-safety requires multiple (semi-)independent threads of execution. If there is only one thread involved, the issue is reentrancy. A function could be reentrant but not thread-safe, or vice versa. The ideal would to be both reentrant and thread-safe.


The program state is the value of all of memory, especially global variables. The program state also includes the function call stack, as well as the dynamic memory pool.

A thread is a single flow of control through a program. It has its own stack. In a single-threaded environment, there is only one thread and one stack. The C standard assumes a single-threaded environment. A multi-threaded environment has several threads, each with its own stack. These threads operate independently. When two more more threads need to access the program state, the user must take special precautions to avoid race conditions and to make sure the program state is not corrupted.

Types of threads

  • nested function calls
  • interrupt handlers
  • signal handlers (though the C signal function)
  • lightweight threads (OpenMP, BIOS, POSIX)
  • heavyweight threads (multiple CPUs)
  • processes (Unix, Windows)
  • coprocessors (including DMA)
  •  ?