aboutsummaryrefslogtreecommitdiff
path: root/src/lib9/rendez-pthread.c
blob: 2d08e0c3f345cd8d77e50ad80e0b320a7f883166 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <u.h>
#include <pthread.h>
#include <libc.h>

void
_procsleep(_Procrend *rend)
{
//print("sleep %p %d\n", rend, getpid());
	pthread_cond_init(&rend->cond, 0);
	rend->asleep = 1;
	while(rend->asleep)
		pthread_cond_wait(&rend->cond, &rend->l->mutex);
	pthread_cond_destroy(&rend->cond);
}

void
_procwakeup(_Procrend *rend)
{
//print("wakeup %p\n", rend);
	rend->asleep = 0;
	pthread_cond_signal(&rend->cond);
}