Mercurial > hg > Gears > GearsAgda
view src/synchronizedQueue/synchronizedQueueContext.h @ 52:83ee9c75115a
Add pthread_cond_wait & pthread_cond_signal to synchronizedQueue.c
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 02 Jun 2015 14:17:07 +0900 |
parents | 1b71266af056 |
children | 4283b87ddbf4 |
line wrap: on
line source
/* Context definition for synchronized queue example */ #include <pthread.h> #define ALLOCATE_SIZE 1000 enum Code { Code1, Code2, Code3, Code4, Code5, Code6, Code7, Allocator, Sender, Put, Receiver, Get, Exit, ThreadExit, }; enum UniqueData { Allocate, Queue, Counter, }; struct Context { int codeNum; __code (**code) (struct Context *); void* heap_start; void* heap; long dataSize; int dataNum; union Data* head; union Data** data; }; union Data { long count; struct Queue { union Data* first; union Data* last; int count; pthread_mutex_t mutex; pthread_cond_t cond; } queue; struct Element { int value; union Data* next; } element; struct Allocate { long size; enum Code next; enum Code after_put; enum Code after_get; enum Code after_fail; } allocate; };