I’m new to pthread and mutex lock. I used them before but in a single file (main.c that creates the threads and locks are in the same file as functions and memory that use the locks). How to define mutex lock in C files that depend on each other? Ideally, I wish not to change the current structure.
main.c // create threads, include `file1.h`
file1.h
file1.c // include `file1.h` and `lib.h`, extern a memory defined in `lib.c`
lib.h
lib.c // include `lib.h`, contain functions that malloc and dealloc memory, which need to be accessed by many threads