CS350 COS
COS
Loading...
Searching...
No Matches
semaphore.h
Go to the documentation of this file.
1
2#ifndef __SEMAPHORE_H__
3#define __SEMAPHORE_H__
4
5#include <sys/queue.h>
6#include <sys/spinlock.h>
7
8#define SEMAPHORE_NAMELEN 32
9
10struct Thread;
11
12typedef struct Semaphore
13{
16 int count;
17 TAILQ_HEAD(SemaThreadQueue,Thread) waiters;
18 LIST_ENTRY(Semaphore) semaphoreList;
20
21void Semaphore_Init(Semaphore *sema, int count, const char *name);
24// bool TimedAcquire(Semaphore *sema, uint64_t timeout);
27
28#endif /* __SEMAPHORE_H__ */
29
void Semaphore_Release(Semaphore *sema)
Definition: semaphore.c:72
void Semaphore_Destroy(Semaphore *sema)
Definition: semaphore.c:39
bool Semaphore_TryAcquire(Semaphore *sema)
Definition: semaphore.c:89
void Semaphore_Acquire(Semaphore *sema)
Definition: semaphore.c:49
void Semaphore_Init(Semaphore *sema, int count, const char *name)
#define SEMAPHORE_NAMELEN
Definition: semaphore.h:8
TAILQ_HEAD(SemaThreadQueue, Thread) waiters
Spinlock lock
Definition: semaphore.h:14
int count
Definition: semaphore.h:16
char name[SEMAPHORE_NAMELEN]
Definition: semaphore.h:15
LIST_ENTRY(Semaphore) semaphoreList
Definition: thread.h:31