From 83e17e29456ec9b6d45f4d9f2634eb280c6f414f Mon Sep 17 00:00:00 2001 From: stefan Date: Wed, 19 Apr 2023 20:50:10 -0400 Subject: ticket locks --- sys/include/spinlock.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'sys/include/spinlock.h') diff --git a/sys/include/spinlock.h b/sys/include/spinlock.h index ef81499..82c1585 100644 --- a/sys/include/spinlock.h +++ b/sys/include/spinlock.h @@ -1,15 +1,17 @@ -#ifndef _LOCK_H -#define _LOCK_H +#ifndef _SPINLOCK_H +#define _SPINLOCK_H -struct spinlock { - int locked; - int tp; -}; +/* fifo ticket lock implementation */ -void initlock(struct spinlock *); +typedef struct _spinlock { + int ticket; + int turn; +} spinlock_t; -void acquire(struct spinlock *); +void initlock(spinlock_t *); -void release(struct spinlock *); +void acquire(spinlock_t *); -#endif /* _LOCK_H */ +void release(spinlock_t *); + +#endif /* _SPINLOCK_H */ -- cgit v1.2.3