-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsema.h
More file actions
26 lines (20 loc) · 751 Bytes
/
sema.h
File metadata and controls
26 lines (20 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/****************************************************************************
FILE : sema.h
SUBJECT : Interface to semaphore abstract type.
AUTHOR : (C) Copyright 2012 by Peter C. Chapin <PChapin@vtc.vsc.edu>
This header file specifies the interface to a semphore abstract type.
****************************************************************************/
#ifndef SEMA_H
#define SEMA_H
#include <pthread.h>
// This is our semaphore type.
typedef struct {
pthread_mutex_t lock;
pthread_cond_t non_zero;
int raw_count;
} semaphore_t;
void semaphore_init( semaphore_t *s, int initial_count );
void semaphore_destroy( semaphore_t *s );
void semaphore_up( semaphore_t *s );
void semaphore_down( semaphore_t *s );
#endif