Hailin
2013-03-28 10:34:22 +08:00
commit a5ec64177d
55 changed files with 6183 additions and 0 deletions

27
cond_static.c Normal file
View File

@@ -0,0 +1,27 @@
/*
* cond_static.c
*
* Demonstrate static initialization of a condition variable.
*/
#include <pthread.h>
#include "errors.h"
/*
* Declare a structure, with a mutex and condition variable,
* statically initialized. This is the same as using
* pthread_mutex_init and pthread_cond_init, with the default
* attributes.
*/
typedef struct my_struct_tag {
pthread_mutex_t mutex; /* Protects access to value */
pthread_cond_t cond; /* Signals change to value */
int value; /* Access protected by mutex */
} my_struct_t;
my_struct_t data = {
PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0};
int main (int argc, char *argv[])
{
return 0;
}