Newer
Older
ubix / src / sys / include / ubixos / spinlock.h
@apwillia apwillia on 19 Sep 2002 490 bytes Scheduler overhaul...
#ifndef _SPINLOCK_H

#define _SPINLOCK_H

typedef struct __SPINLOCK_TYPE 
{
	int count; // for recursion.
	int owner;

	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 spinlockInit(spinlock_t *);
void spinlockDelete(spinlock_t *);

int spinlockLock(spinlock_t *, int);
int spinlockUnlock(spinlock_t *, int);

#endif