In this lab your will implement a priority read/write lock library with mutex.
We use a different repo for the DMM lab. Please clone the repo via one of these addresses (depending on if you want HTTPS or SSH authentication):
You need to run the lab on Linux system. We recommend you use the docker we provide (the same xv6 docker) as following commands:
You only need to modify rwlock.c
and rwlock.h
to finish this lab.
To test your solution, please run make test. Each test case (TC) will print out “Test Passed!” or “Test Failed!”. You need to pass all the test cases.
To submit your solution, please run make gradescope, and submit your submission.zip
to gradescope.
It is helpful to understand read/write lock from course slides or chapter 31.5 in OSTEP read/write lock. Here we give the basic logistics of the priority rwlock in this lab.
We provide the structure of read/write lock and basic functions in ‘rwlock.h’.
typedef struct {
pthread_mutex_t mutex;
pthread_cond_t r_cond;
pthread_cond_t w_cond[3];
int r_active;
int w_active[3];
int r_wait;
int w_wait[3];
}rwl;
You will implement five methods that handles the read/write lock behavior.
void rwl_init(rwl *l);
void rwl_rlock(rwl *l);
void rwl_runlock(rwl *l);
void rwl_wlock(rwl *l, int priority);
void rwl_wunlock(rwl *l, int priority);
You can test and grade your rwlock library locally by running
make test