moss.ipc
Class MSemaphore

java.lang.Object
  extended by moss.ipc.MSemaphore

public class MSemaphore
extends java.lang.Object

this class implements a "semaphore". Operations are performed based on changing the semaphore's value arbitrarily, not strictly `wait' (-1) and `signal' (+1). However, wait() and signal() methods are still provided, for bits of the kernel that want to use them like that.


Field Summary
static int SEMOP_CREATE
          create a semaphore
static int SEMOP_REMOVE
          remove a semaphore
static int SEMOP_SET
          set (adjust) a semaphore's value
 
Constructor Summary
MSemaphore()
           
 
Method Summary
static void finalinit()
          this is called to perform any final initialisation, in the context of the init-task.
static void init_semaphore()
          this initialises the semaphore handling class
static int semcreate(int key, int value)
          creates a new semaphore
static int semremove(int key)
          removes a semaphore.
static int semset(MProcess current, int key, int value)
          changes a semaphore's value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEMOP_CREATE

public static final int SEMOP_CREATE
create a semaphore

See Also:
Constant Field Values

SEMOP_SET

public static final int SEMOP_SET
set (adjust) a semaphore's value

See Also:
Constant Field Values

SEMOP_REMOVE

public static final int SEMOP_REMOVE
remove a semaphore

See Also:
Constant Field Values
Constructor Detail

MSemaphore

public MSemaphore()
Method Detail

init_semaphore

public static void init_semaphore()
this initialises the semaphore handling class


finalinit

public static void finalinit()
this is called to perform any final initialisation, in the context of the init-task.


semcreate

public static int semcreate(int key,
                            int value)
creates a new semaphore

Parameters:
key - semaphore key
value - initial value of the semaphore. If < 0, the method blocks.
Returns:
0 on success, or < 0 indicating error (key already exists)

semset

public static int semset(MProcess current,
                         int key,
                         int value)
changes a semaphore's value

Parameters:
key - semaphore key
value - change semaphore value by this (+ve or -ve)
Returns:
0 on success, or < 0 indicating error

semremove

public static int semremove(int key)
removes a semaphore. Blocked processes are woken up -- they return with ENOENT

Parameters:
key - semaphore key
Returns:
0 on success, or < 0 indicating error