00001 00007 /* Embedded XINU, Copyright (C) 2007. All rights reserved. */ 00008 00009 #ifndef _SEM_H_ 00010 #define _SEM_H_ 00011 00012 #include <kernel.h> 00013 #include <queue.h> 00015 /* Semaphore state definitions */ 00016 #define SFREE 0x01 00017 #define SUSED 0x02 00019 /* type definition of "semaphore" */ 00020 typedef ulong semaphore; 00021 00022 /* Semaphore table entry */ 00023 struct sentry 00024 { 00025 char state; 00026 short count; 00027 queue queue; 00028 }; 00029 00030 extern struct sentry semtab[]; 00031 00036 #define isbadsem(s) (((ushort)(s) >= NSEM) || (SFREE == semtab[s].state)) 00037 00038 /* Semaphore function declarations */ 00039 syscall wait(semaphore); 00040 syscall signal(semaphore); 00041 syscall signaln(semaphore, short); 00042 semaphore newsem(short); 00043 syscall freesem(semaphore); 00044 syscall scount(semaphore); 00045 00046 #endif