"statically allocated"是什么意思?
What is the meaning of "statically allocated"?
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.
我知道动态分配。 "statically allocated"是什么意思?
我这里的问题是理解"statically"分配的意思。我发布手册页中的引述只是为了提供上下文。
静态分配意味着变量是在编译时分配的,而不是在运行时分配的。在 C 中,这可以是文件范围内的全局变量或函数中的 static
变量。
这里有一个很好的概述:
http://en.wikipedia.org/wiki/Static_memory_allocation
堆栈上的变量(即没有static
关键字的函数中的局部变量)在调用函数时分配,有时在递归调用函数时分配多次。所以它们在概念上不同于静态内存分配(每个程序只发生一次)。
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.
我知道动态分配。 "statically allocated"是什么意思?
我这里的问题是理解"statically"分配的意思。我发布手册页中的引述只是为了提供上下文。
静态分配意味着变量是在编译时分配的,而不是在运行时分配的。在 C 中,这可以是文件范围内的全局变量或函数中的 static
变量。
这里有一个很好的概述: http://en.wikipedia.org/wiki/Static_memory_allocation
堆栈上的变量(即没有static
关键字的函数中的局部变量)在调用函数时分配,有时在递归调用函数时分配多次。所以它们在概念上不同于静态内存分配(每个程序只发生一次)。