eCos Reference Manual
Prev | Chapter 8. C and math library overview | Next

# Thread safety

The ISO C library has configuration options that control thread safety, i.e. working behavior if multiple threads call the same function at the same time.

The following functionality has to be configured correctly, or used carefully in a multi-threaded environment:

- `mblen()`

- `mbtowc()`

- `wctomb()`

- `printf()` (and all standard I/O functions except for `sprintf()` and `sscanf()`

- `strtok()`

- `rand()` and `srand()`

- `signal()` and `raise()`

- `asctime()` , `ctime()` , `gmtime()` , and `localtime()`

- the `errno` variable

- the `environ` variable

- date and time settings

In some cases, to make eCos development easier, functions are provided (as specified by POSIX 1003.1) that define re-entrant alternatives, i.e. `rand_r()`, `strtok_r()`, `asctime_r()`, `ctime_r()`, `gmtime_r()`, and `localtime_r()`. In other cases, configuration options are provided that control either locking of functions or their shared data, such as with standard I/O streams, or by using per-thread data, such as with the `errno` variable.

In some other cases, like the setting of date and time, no re-entrant or thread-safe alternative or configuration is provided as it is simply not a worthwhile addition (date and time should rarely need to be set.)

Prev | Home | Next
Some implementation details | Up | C library startup