•  Back 
  •  GEMDOS Function Reference 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  %About 
  •  Show info about hypertext 
  •  View a new file 
Topic       : The ATARI Compendium
Author      : Scott Sanders / JAY Software
Version     : 1.25 (20/6/2003)
Subject     : Documentation
Nodes       : 1117
Index Size  : 32614
HCP-Version : 6
Compiled on : Atari
@charset    : UTF-8
@lang       : en
@default    : 
@help       : %About
@options    : +g -i -t4 +y +z
@width      : 100
View Ref-FilePsemaphore()                                                         GEMDOS

Syntax

LONG Psemaphore( mode, id, timeout )
WORD mode;
LONG id;
LONG timeout;

Function      Psemaphore() creates a semaphore which may only be accessed
              by one process at a time.

Opcode        308 (0x134)

Availability  Available when a 'MiNT' cookie with a version of at least
              0.92 exists.

Parameters    mode specifies the mode of the operation which affects the
              other two parameters as follows:

              Name       mode   Meaning

              SEM_CREATE   0    Create a semaphore with called id and
                                grant ownership to the calling process.
                                timeout is ignored.

              SEM_DESTROY  1    Destroy the semaphore called id. This only
                                succeeds if the semaphore is owned by the
                                caller. timeout is ignored.

              SEM_LOCK     2    Request ownership of semaphore id. The
                                process will wait for the semaphore to
                                become available for timeout milliseconds
                                and then return. If timeout value of 0
                                will force the call to return immediately
                                whether or not the semaphore is available.
                                A timeout value of -1 will cause the call
                                to wait indefinitely.

              SEM_UNLOCK   3    Release ownership of semaphore id. The
                                caller must be the current owner of the
                                semaphore to release control. timeout is
                                ignore.

Binding       move.l   timeout,-(sp)
              move.l   id,-(sp)
              move.w   mode,-(sp)
              move.w   #$134,-(sp)
              trap     #1
              lea      12(sp),sp

Return Value  Psemaphore() returns a 0 if successful, ERROR (-1) if the
              process requested a semaphore it already owned, or
              a negative GEMDOS error code.

Comments      If your process is waiting for ownership of a semaphore and
              it is destroyed by another process, an ERANGE (-64) error
              will result. Any semaphores owned by a process when it
              terminates are released but not deleted.