Thread safety

The standard C library is configured by default to not be thread safe, meaning that concurrent threads might overwrite each other's C library static data when they invoke the following functions: printf() (and all standard I/O functions except for sprintf() and sscanf()), strtok(), rand() and srand(). The errno variable is also not thread safe.

There are options to enable overall thread safety (CYGSEM_LIBC_THREAD_SAFETY), as well as more fine-grained thread safety options. These are described in Chapter 16 and Chapter 17.

Note that for thread safety to work at all you must enable kernel support for per-thread data (CYGVAR_KERNEL_THREADS_DATA) and stack limits (CYGFUN_KERNEL_THREADS_STACK_LIMIT).