#include <kernel.h>
#include <queue.h>
Go to the source code of this file.
Data Structures | |
struct | sentry |
Defines | |
#define | SFREE 0x01 |
#define | SUSED 0x02 |
#define | isbadsem(s) (((ushort)(s) >= NSEM) || (SFREE == semtab[s].state)) |
Typedefs | |
typedef ulong | semaphore |
Functions | |
syscall | wait (semaphore) |
syscall | signal (semaphore) |
syscall | signaln (semaphore, short) |
semaphore | newsem (short) |
syscall | freesem (semaphore) |
syscall | scount (semaphore) |
Variables | |
struct sentry | semtab [] |
Definition in file semaphore.h.
isbadsem - check validity of reqested semaphore id and state
s | id number to test |
Definition at line 36 of file semaphore.h.
Referenced by freesem(), scount(), signal(), signaln(), test_deltaQueue(), test_procQueue(), test_semaphore(), test_semaphore2(), test_semaphore3(), test_semaphore4(), and wait().
#define SFREE 0x01 |
< queue.h must define # of sem queues this semaphore is free
Definition at line 16 of file semaphore.h.
Referenced by allocsem(), freesem(), and sysinit().
#define SUSED 0x02 |
Definition at line 20 of file semaphore.h.
syscall freesem | ( | semaphore | sem | ) |
freesem - deallocate a semaphore. Reset the semaphore count, releasing any processes in the waiting queue. Deallocate entry in global semaphore table.
sem | id of semaphore to be released |
Definition at line 21 of file freesem.c.
References sentry::count, dequeue(), disable(), isbadsem, nonempty, OK, sentry::queue, ready(), RESCHED_NO, restore(), semtab, SFREE, sentry::state, and SYSERR.
Referenced by test_deltaQueue(), test_procQueue(), test_semaphore(), test_semaphore2(), test_semaphore3(), and test_semaphore4().
semaphore newsem | ( | short | count | ) |
newsem - allocate and initialize a new semaphore.
count | - number of resources available without waiting. example: count = 1 for mutual exclusion lock |
Definition at line 20 of file newsem.c.
References allocsem(), sentry::count, disable(), restore(), semtab, and SYSERR.
Referenced by test_deltaQueue(), test_procQueue(), test_semaphore(), test_semaphore2(), test_semaphore3(), test_semaphore4(), and uartInit().
syscall scount | ( | semaphore | sem | ) |
scount - return a semaphore count
sem | id of semaphore to query |
Definition at line 17 of file scount.c.
References isbadsem, semtab, and SYSERR.
Referenced by uartRead(), and uartWrite().
syscall signal | ( | semaphore | sem | ) |
signal - signal a semaphore, releasing one waiting process, and block
sem | id of semaphore to signal |
Definition at line 18 of file signal.c.
References sentry::count, dequeue(), disable(), isbadsem, OK, sentry::queue, ready(), RESCHED_YES, restore(), semtab, and SYSERR.
Referenced by test_semaphore(), test_semaphore2(), and test_semaphore3().
syscall signaln | ( | semaphore | sem, | |
short | count | |||
) |
signaln - signal a semaphore n times, releasing n waiting processes, non-blocking
sem | id of semaphore to signal | |
count | number of times to signal |
Definition at line 20 of file signaln.c.
References sentry::count, dequeue(), disable(), isbadsem, OK, sentry::queue, ready(), RESCHED_NO, restore(), semtab, and SYSERR.
Referenced by uartIntr().
syscall wait | ( | semaphore | sem | ) |
wait - make current process wait on a semaphore
sem | semaphore for which to wait |
Definition at line 19 of file wait.c.
References sentry::count, currpid, disable(), enqueue(), isbadsem, OK, proctab, PRWAIT, sentry::queue, resched(), restore(), pentry::sem, semtab, pentry::state, and SYSERR.
Referenced by test_semWaiter(), uartRead(), and uartWrite().
Definition at line 40 of file initialize.c.
Referenced by allocsem(), freesem(), kill(), newsem(), scount(), signal(), signaln(), sysinit(), test_checkSemCount(), test_deltaQueue(), test_procQueue(), and wait().