VxWorks Reference Manual : Libraries

semSmLib

NAME

semSmLib - shared memory semaphore library (VxMP Option)

ROUTINES

semBSmCreate( ) - create and initialize a shared memory binary semaphore (VxMP Option)
semCSmCreate( ) - create and initialize a shared memory counting semaphore (VxMP Option)

DESCRIPTION

This library provides the interface to VxWorks shared memory binary and counting semaphores. Once a shared memory semaphore is created, the generic semaphore-handling routines provided in semLib are used to manipulate it. Shared memory binary semaphores are created using semBSmCreate( ). Shared memory counting semaphores are created using semCSmCreate( ).

Shared memory binary semaphores are used to: (1) control mutually exclusive access to multiprocessor-shared data structures, or (2) synchronize multiple tasks running in a multiprocessor system. For general information about binary semaphores, see the manual entry semBLib.

Shared memory counting semaphores are used for guarding multiple instances of a resource used by multiple CPUs. For general information about shared counting semaphores, see the manual entry for semCLib.

For information about the generic semaphore-handling routines, see the manual entry for semLib.

MEMORY REQUIREMENTS

The semaphore structure is allocated from a dedicated shared memory partition.

The shared semaphore dedicated shared memory partition is initialized by the shared memory objects master CPU. The size of this partition is defined by the maximum number of shared semaphores, defined by SM_OBJ_MAX_SEM in the configuration header file.

This memory partition is common to shared binary and counting semaphores, thus SM_OBJ_MAX_SEM must be set to the sum total of binary and counting semaphores to be used in the system.

RESTRICTIONS

Shared memory semaphores differ from local semaphores in the following ways:

Interrupt Use. 1

Shared semaphores may not be given, taken, or flushed at interrupt level.

Deletion. 1

There is no way to delete a shared semaphore and free its associated shared memory. Attempts to delete a shared semaphore return ERROR and set errno to S_smObjLib_NO_OBJECT_DESTROY.

Queuing Style. 1

The shared semaphore queuing style specified when the semaphore is created must be FIFO.

INTERRUPT LATENCY

Internally, interrupts are locked while manipulating shared semaphore data structures, thus increasing the interrupt latency.

CONFIGURATION

Before routines in this library can be called, the shared memory object facility must be initialized by calling usrSmObjInit( ), which is found in src/config/usrSmObj.c. This is done automatically from the root task, usrRoot( ), in usrConfig.c when the configuration macro INCLUDE_SM_OBJ is defined.

AVAILABILITY

This module is distributed as a component of the unbundled shared memory support option, VxMP.

INCLUDE FILES

semSmLib.h

SEE ALSO

semSmLib, semLib, semBLib, semCLib, smObjLib, semShow, usrSmObjInit( ), VxWorks Programmer's Guide: Shared Memory Objects, Basic OS


Libraries : Routines

semBSmCreate( )

NAME

semBSmCreate( ) - create and initialize a shared memory binary semaphore (VxMP Option)

SYNOPSIS

SEM_ID semBSmCreate
    (
    int         options,     /* semaphore options */
    SEM_B_STATE initialState /* initial semaphore state */
    )

DESCRIPTION

This routine allocates and initializes a shared memory binary semaphore. The semaphore is initialized to an initialState of either SEM_FULL (available) or SEM_EMPTY (not available). The shared semaphore structure is allocated from the shared semaphore dedicated memory partition.

The semaphore ID returned by this routine can be used directly by the generic semaphore-handling routines in semLib -- semGive( ), semTake( ), and semFlush( ) -- and the show routines, such as show( ) and semShow( ).

The queuing style for blocked tasks is set by options; the only supported queuing style for shared memory semaphores is first-in-first-out, selected by SEM_Q_FIFO.

Before this routine can be called, the shared memory objects facility must be initialized (see semSmLib).

The maximum number of shared memory semaphores (binary plus counting) that can be created is SM_OBJ_MAX_SEM.

AVAILABILITY

This routine is distributed as a component of the unbundled shared memory support option, VxMP.

RETURNS

The semaphore ID, or NULL if memory cannot be allocated from the shared semaphore dedicated memory partition.

ERRNO

S_memLib_NOT_ENOUGH_MEMORY, S_semLib_INVALID_QUEUE_TYPE,
       S_semLib_INVALID_STATE, S_smObjLib_LOCK_TIMEOUT

SEE ALSO

semSmLib, semLib, semBLib, smObjLib, semShow


Libraries : Routines

semCSmCreate( )

NAME

semCSmCreate( ) - create and initialize a shared memory counting semaphore (VxMP Option)

SYNOPSIS

SEM_ID semCSmCreate
    (
    int options,     /* semaphore options */
    int initialCount /* initial semaphore count */
    )

DESCRIPTION

This routine allocates and initializes a shared memory counting semaphore. The initial count value of the semaphore (the number of times the semaphore should be taken before it can be given) is specified by initialCount.

The semaphore ID returned by this routine can be used directly by the generic semaphore-handling routines in semLib -- semGive( ), semTake( ) and semFlush( ) -- and the show routines, such as show( ) and semShow( ).

The queuing style for blocked tasks is set by options; the only supported queuing style for shared memory semaphores is first-in-first-out, selected by SEM_Q_FIFO.

Before this routine can be called, the shared memory objects facility must be initialized (see semSmLib).

The maximum number of shared memory semaphores (binary plus counting) that can be created is SM_OBJ_MAX_SEM.

AVAILABILITY

This routine is distributed as a component of the unbundled shared memory support option, VxMP.

RETURNS

The semaphore ID, or NULL if memory cannot be allocated from the shared semaphore dedicated memory partition.

ERRNO

S_memLib_NOT_ENOUGH_MEMORY, S_semLib_INVALID_QUEUE_TYPE,
       S_smObjLib_LOCK_TIMEOUT

SEE ALSO

semSmLib, semLib, semCLib, smObjLib, semShow