http://linux.die.net/man/3/pthread_mutex_init
In cases where default mutex attributes are appropriate, the macro PTHREAD_MUTEX_INITIALIZER can be used to initialize mutexes that are statically allocated. The effect shall be equivalent to dynamic initialization by a call to pthread_mutex_init() with parameter attr specified as NULL, except that no error checks are performed.
I know about dynamic allocation. What is the meaning of "statically allocated"?
My question here is to understand the meaning of "statically" allocated. I posted the quote from the man page to provide a context, only.
Statically allocated means that the variable is allocated at compile-time, not at run-time. In C, this can be a global variable at the file scope or a static
variable in a function.
A good overview is found here: http://en.wikipedia.org/wiki/Static_memory_allocation
Variables on the stack (i.e., local variables in functions that do not have the static
keyword) are allocated when the function is called, sometimes multiple times when a function is called recursively. So they are conceptually different from static memory allocation (which only happens once per program).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With