I have have two .c files (main.c and support.c). Support.c is compiled first and then main.c is compiled and linked with support.o. I have several non-static global variables in support.c.
How are those global variables from support.c stored? If main.c is multithreaded and has two threads calling the functions in support.c, are they sharing those globals, or do they each have their own copy?
A global variable is a global variable, and there’s always just one, no matter in how many pieces you compile and link your program. If multiple threads access global data concurrently, you need to ensure the proper synchronization yourself.
The only way to get a separate copy of a global or block-static variable is to declare it
_Thread_local, which was introduced in C11. Thread-local global variables are initialized when the thread is started, and deallocated when the thread is joined.