C-chat
synchronization.h
Go to the documentation of this file.
1 
6 #ifndef C_CHAT_SYNCHRONIZATION_H
7 #define C_CHAT_SYNCHRONIZATION_H
8 
13 typedef struct Mutex {
14  void* info;
15 } Mutex;
16 
21 typedef struct ReadWriteLock {
22  Mutex writeLock;
23  Mutex readLock;
24  int* readCount;
26 
33 
43 void acquireMutex(Mutex mutex);
44 
52 void releaseMutex(Mutex mutex);
53 
61 void destroyMutex(Mutex mutex);
62 
76 
86 void acquireRead(ReadWriteLock lock);
87 
97 void acquireWrite(ReadWriteLock lock);
98 
106 void releaseRead(ReadWriteLock lock);
107 
115 void releaseWrite(ReadWriteLock lock);
116 
128 
129 #endif //C_CHAT_SYNCHRONIZATION_H
destroyMutex
void destroyMutex(Mutex mutex)
Destroys the given mutex.
releaseWrite
void releaseWrite(ReadWriteLock lock)
Releases write lock on the given read/write lock.
Definition: synchronization.c:42
ReadWriteLock
A read/write lock to synchronize resource access.
Definition: synchronization.h:21
releaseRead
void releaseRead(ReadWriteLock lock)
Releases read lock on the given read/write lock.
Definition: synchronization.c:27
acquireRead
void acquireRead(ReadWriteLock lock)
Acquires read lock on the given read/write lock.
Definition: synchronization.c:16
createReadWriteLock
ReadWriteLock createReadWriteLock()
Creates a read/write lock.
Definition: synchronization.c:6
createMutex
Mutex createMutex()
Creates a mutex.
releaseMutex
void releaseMutex(Mutex mutex)
Releases the given mutex.
acquireMutex
void acquireMutex(Mutex mutex)
Acquires the given mutex.
acquireWrite
void acquireWrite(ReadWriteLock lock)
Acquires write lock on the given read/write lock.
Definition: synchronization.c:38
destroyReadWriteLock
void destroyReadWriteLock(ReadWriteLock lock)
Destroys the given read/write lock.
Definition: synchronization.c:46
Mutex
A semaphore allowing mutual exclusion.
Definition: synchronization.h:13