lab3.1: locks

This commit is contained in:
2020-05-28 15:27:02 +02:00
parent 1b82f81d8c
commit 8fcc6b0ea4
4 changed files with 78 additions and 5 deletions

View File

@@ -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);