-
Notifications
You must be signed in to change notification settings - Fork 1
/
rwlock.h
45 lines (35 loc) · 1.09 KB
/
rwlock.h
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/****************************************************************************
FILE : rwlock.h
LAST REVISED : 2007-11-22
SUBJECT : Reader/writer locks.
PROGRAMMER : (C) Copyright 2007 by Peter C. Chapin
This file contains the declaration of several functions that allow for
reader/writer locks. The function names should be fairly self-explanatory.
Please send comments or bug reports pertaining to this file to
Peter C. Chapin
Electrical and Computer Engineering Technology
Vermont Technical College
Randolph Center, VT 05061
Peter.Chapin@vtc.vsc.edu
****************************************************************************/
#ifndef RWLOCK_H
#define RWLOCK_H
#include <pthread.h>
typedef struct {
pthread_mutex_t mutex;
pthread_mutex_t wrt;
int readcount;
} rw_lock;
#ifdef __cplusplus
extern "C" {
#endif
void rw_init ( rw_lock * );
void rw_destroy ( rw_lock * );
void read_lock ( rw_lock * );
void read_unlock ( rw_lock * );
void write_lock ( rw_lock * );
void write_unlock( rw_lock * );
#ifdef __cplusplus
}
#endif
#endif