Esempio n. 1
0
void G_init_counter(struct Counter *c, int v)
{
#ifdef HAVE_PTHREAD_H
    make_mutex();
#endif
    c->value = v;
}
//Semaphore functions
Semaphore *make_semaphore (int value) {
  Semaphore *semaphore = check_malloc (sizeof(Semaphore));
  semaphore->value = value;
  semaphore->wakeups = 0;
  semaphore->mutex = make_mutex ();
  semaphore->cond = make_cond ();
  return semaphore;
}
Esempio n. 3
0
int G_is_initialized(int *p)
{
    if (*p)
	return 1;

#ifdef HAVE_PTHREAD_H
    make_mutex();
    pthread_mutex_lock(&mutex);

    if (*p) {
	pthread_mutex_unlock(&mutex);
	return 1;
    }
#endif
    return 0;
}