Desktop/xinu_mips-1.0.2.tar/xinu_mips-1.0.2/include/semaphore.h File Reference

#include <kernel.h>
#include <queue.h>

Include dependency graph for semaphore.h:

This graph shows which files directly or indirectly include this file:

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 []


Detailed Description

isbadsem

Id
semaphore.h 226 2007-07-12 01:18:27Z mschul

Definition in file semaphore.h.


Define Documentation

#define isbadsem (  )     (((ushort)(s) >= NSEM) || (SFREE == semtab[s].state))

isbadsem - check validity of reqested semaphore id and state

Parameters:
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

this semaphore is used

Definition at line 17 of file semaphore.h.

Referenced by allocsem().


Typedef Documentation

typedef ulong semaphore

Definition at line 20 of file semaphore.h.


Function Documentation

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.

Parameters:
sem id of semaphore to be released
Returns:
OK on success, SYSERR on failure

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.

Parameters:
count - number of resources available without waiting. example: count = 1 for mutual exclusion lock
Returns:
new semaphore id on success, SYSERR on failure

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

Parameters:
sem id of semaphore to query
Returns:
count from semtab entry on success, SYSERR on failure

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

Parameters:
sem id of semaphore to signal
Returns:
OK on success, SYSERR on failure

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

Parameters:
sem id of semaphore to signal
count number of times to signal
Returns:
OK on success, SYSERR on failure

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

Parameters:
sem semaphore for which to wait
Returns:
OK on success, SYSERR on failure

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().


Variable Documentation

struct sentry semtab[]


Generated on Thu Oct 9 22:34:41 2008 for xinu by  doxygen 1.5.5