28 lines
700 B
C
28 lines
700 B
C
/*
|
|
* 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;
|
|
}
|