-
Notifications
You must be signed in to change notification settings - Fork 0
/
locks.h
33 lines (31 loc) · 881 Bytes
/
locks.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
struct ticketlock {
int now_serving,next_ticket;
};
struct rwlock{
struct ticketlock mutex,rw_mutex;
int count;
};
struct rwlock2{
struct ticketlock mutex,rw_mutex,r_mutex;
int count;
};
int sys_ticketlockinit();
int sys_ticketlocktest();
int sys_rwinit();
int sys_rwtest();
//ticket lock
void init_ticket(struct ticketlock *lock);
void acquire_ticket(struct ticketlock *lock);
void release_ticket(struct ticketlock *lock);
//rw lock
void init_rw(struct rwlock *lock);
void acquire_writer(struct rwlock *lock);
void release_writer(struct rwlock *lock);
void acquire_reader(struct rwlock *lock);
void release_reader(struct rwlock *lock);
//rw lock2
void init_rw2(struct rwlock2 *lock);
void acquire_writer2(struct rwlock2 *lock);
void release_writer2(struct rwlock2 *lock);
void acquire_reader2(struct rwlock2 *lock);
void release_reader2(struct rwlock2 *lock);