12 #define DEFAULT_KEY 85549
38 pthread_mutexattr_t psharedm;
39 pthread_condattr_t psharedc;
41 fd = open(semaphore_name, O_RDWR | O_CREAT, 0666);
43 printf(
"%s : fd open failed\n", semaphore_name);
47 (void) pthread_mutexattr_init(&psharedm);
48 (void) pthread_mutexattr_setpshared(&psharedm,
49 PTHREAD_PROCESS_SHARED);
50 (void) pthread_condattr_init(&psharedc);
51 (void) pthread_condattr_setpshared(&psharedc,
52 PTHREAD_PROCESS_SHARED);
54 PROT_READ | PROT_WRITE, MAP_SHARED,
58 (void) pthread_mutex_init(&semap->
lock, &psharedm);
59 (void) pthread_cond_init(&semap->
nonzero, &psharedc);
73 fd = open(semaphore_name, O_RDWR, 0666);
77 PROT_READ | PROT_WRITE, MAP_SHARED,
void semaphore_close(semaphore_t *semap)
Definition: shared_memory-modify.hh:84
semaphore_t * semaphore_open(char *semaphore_name)
Definition: shared_memory-modify.hh:68
semaphore_t * semaphore_create(char *semaphore_name, unsigned qs)
Definition: shared_memory-modify.hh:34
Definition: shared_memory-modify.hh:22
unsigned queue_size
Definition: shared_memory-modify.hh:27
pthread_cond_t nonzero
Definition: shared_memory-modify.hh:24
pthread_mutex_t lock
Definition: shared_memory-modify.hh:23
unsigned tail
Definition: shared_memory-modify.hh:26
unsigned count
Definition: shared_memory-modify.hh:28
unsigned head
Definition: shared_memory-modify.hh:25
Definition: shared_memory-modify.hh:14
char * buf
Definition: shared_memory-modify.hh:16
uint32_t chunk_offset
Definition: shared_memory-modify.hh:18
uint32_t chunk_index
Definition: shared_memory-modify.hh:17
bool commit
Definition: shared_memory-modify.hh:19
uint64_t chunk_size
Definition: shared_memory-modify.hh:15