lab3.1: locks
This commit is contained in:
@@ -37,6 +37,9 @@
|
||||
|
||||
#include <spinlock.h>
|
||||
|
||||
#include "opt-semlock.h"
|
||||
#include "opt-wchanlock.h"
|
||||
|
||||
/*
|
||||
* Dijkstra-style semaphore.
|
||||
*
|
||||
@@ -72,10 +75,19 @@ void V(struct semaphore *);
|
||||
* The name field is for easier debugging. A copy of the name is
|
||||
* (should be) made internally.
|
||||
*/
|
||||
|
||||
struct lock {
|
||||
char *lk_name;
|
||||
volatile struct thread *owner;
|
||||
#if OPT_SEMLOCK
|
||||
struct semaphore *sem;
|
||||
#elif OPT_WCHANLOCK
|
||||
struct spinlock slk;
|
||||
struct wchan *wchan;
|
||||
#else
|
||||
// add what you need here
|
||||
// (don't forget to mark things volatile as needed)
|
||||
#endif
|
||||
};
|
||||
|
||||
struct lock *lock_create(const char *name);
|
||||
|
||||
Reference in New Issue
Block a user