From a0d6941b2ef689302dce37d1a864fd4213a0a559 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Sun, 13 Feb 2022 17:13:17 -0700 Subject: Implement generic lock --- include/util/lock.h | 12 ++++++++++++ include/util/mutex.h | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 include/util/lock.h (limited to 'include/util') diff --git a/include/util/lock.h b/include/util/lock.h new file mode 100644 index 0000000..78add88 --- /dev/null +++ b/include/util/lock.h @@ -0,0 +1,12 @@ +#ifndef UTIL_LOCK_H +#define UTIL_LOCK_H + +#include + +struct Lock { + unsigned long pid; +} __attribute__((packed, aligned(4))); + +struct Lock* create_lock(void); + +#endif diff --git a/include/util/mutex.h b/include/util/mutex.h index 907fe5b..61237b8 100644 --- a/include/util/mutex.h +++ b/include/util/mutex.h @@ -8,10 +8,12 @@ #define CORE3_PID 4 #define FIRST_AVAIL_PID CORE3_PID+1 +// PID field is first so that it can be treated +// as a lock struct Mutex { - void* addr; unsigned long pid; -} __attribute__((packed, aligned(4)));; + void* addr; +} __attribute__((packed, aligned(4))); struct Mutex* create_mutex(void* addr); -- cgit v1.2.1