diff --git a/src/sys/include/ubixos/spinlock.h b/src/sys/include/ubixos/spinlock.h new file mode 100755 index 0000000..83e9861 --- /dev/null +++ b/src/sys/include/ubixos/spinlock.h @@ -0,0 +1,29 @@ +#ifndef _SPINLOCK_H + +#define _SPINLOCK_H + +typedef struct +{ + int ticket[16]; // allow up to 16 CPUs. + int choiceInProgress[16]; + + int deleteInProgress; + +} spinlock_t; + +enum spinlock_returns +{ + SPINLOCK_SUCCESS, + SPINLOCK_FAIL_DELETING +} + +spinlock_t * spinlockCreate(); +void spinlockDelete(spinlock_t *); + +int spinlockLock(spinlock_t *, int); +int spinlockUnlock(spinlock_t *, int); + +#endif + + +