ВУЗ:
Составители:
239
int full;
pthread_mutex_t mx;
pthead_cond_t cond;
int data;
void *writer(void *)
{
while(1)
{
int t= write_to_buffer ();
pthread_mutex_lock(&mx)
while(full) {
pthread_cond_wait(&cond, &mx);
}
data=t;
full=1;
pthread_cond_signal(&mx);
pthread_mutex_unlock(&mx);
}
return NULL;
}
void * reader(void *)
{
while (1)
{
int t;
pthread_mutex_lock(&mx);
while (!full)
{
pthread_cond_wait(&cond, &mx);
}
t=data;
full=0;
Страницы
- « первая
- ‹ предыдущая
- …
- 237
- 238
- 239
- 240
- 241
- …
- следующая ›
- последняя »
