Not calling functions within a Timer Callback?

"The timer callback function may run in a different thread than your main
program, and so shouldn’t call any functions from within itself. "

Does this mean that no functions (even user defined or standard C functions)
may be called from within a callback ? Only C statements, conditionals (like

  • -, if switch while etc. ) are allowed ?

-Luke

Luke J Crook wrote:

“The timer callback function may run in a different thread than your
main program, and so shouldn’t call any functions from within itself.

Worse, it may run as an interrupt on some operating systems, which further
restricts what you can do.

Does this mean that no functions (even user defined or standard C
functions) may be called from within a callback ? Only C statements,
conditionals (like + -, if switch while etc. ) are allowed ?

SDL functions are not allowed unless otherwise noted.

OS functions may or may not be allowed depending on the OS.

C/C++ standard library functions may or may not be allowed depending on the
implementation.

Shared data (global/static variables) may be read from multiple threads so
long as there is no chance that any thread is writing to it. Alternately, a
mutex may be used to protect access (both read and write) to that data.
Mutexes cannot be used if the timer runs as an interrupt. See the SDL
threading functions.

User-defined functions are allowed, so long as their content follows the
rules given above.

The same rules apply if you create a thread by any other means, including
through the SDL threading functions.–
Rainer Deyke - rainerd at eldwood.com - http://eldwood.com