module xdc.runtime.knl.Semaphore

Provides semaphore services when an ISemaphore.Handle is available

An application can isolate itself from ISemaphore implementations by using this module. The application must first obtain an ISemaphore.Handle. It make get such a handle by directly calling SemThread.create or SemProcess.create. Then the application can use the generic APIs provided by this module.
C synopsis target-domain sourced in xdc/runtime/knl/Semaphore.xdc
 
const Semaphore_FOREVER

Used as the timeout value to specify wait forever

C synopsis target-domain
#define Semaphore_FOREVER (UInt)ISemaphore.FOREVER
 
 
enum Semaphore_PendStatus

Error codes returned by Semaphore_pend

C synopsis target-domain
typedef enum Semaphore_PendStatus {
    Semaphore_PendStatus_ERROR,
    Semaphore_PendStatus_TIMEOUT,
    Semaphore_PendStatus_SUCCESS
} Semaphore_PendStatus;
 
 
Semaphore_pend()  // module-wide

Wait for the semaphore to have a nonzero count, then decrement it

C synopsis target-domain
Int Semaphore_pend(ISemaphore_Handle sem, UInt timeout, Error_Block *eb);
 
ARGUMENTS
sem — ISemaphore.Handle to be used
timeout — timeout in microseconds
eb — Pointer to Error.Block
DETAILS
RETURNS
status returned. (refer to above description)
 
Semaphore_post()  // module-wide

Increment the semaphore count

C synopsis target-domain
Bool Semaphore_post(ISemaphore_Handle sem, Error_Block *eb);
 
ARGUMENTS
sem — ISemaphore.Handle to be used
eb — Pointer to Error.Block
RETURNS
true for success, false for error in Error block.
Module-Wide Built-Ins

C synopsis target-domain
Types_ModuleId Semaphore_Module_id();
// Get this module's unique id
 
Bool Semaphore_Module_startupDone();
// Test if this module has completed startup
 
IHeap_Handle Semaphore_Module_heap();
// The heap from which this module allocates memory
 
Bool Semaphore_Module_hasMask();
// Test whether this module has a diagnostics mask
 
Bits16 Semaphore_Module_getMask();
// Returns the diagnostics mask for this module
 
Void Semaphore_Module_setMask(Bits16 mask);
// Set the diagnostics mask for this module
 
XDCscript usage meta-domain sourced in xdc/runtime/knl/Semaphore.xdc
var Semaphore = xdc.useModule('xdc.runtime.knl.Semaphore');
local proxy modules
        Semaphore.Proxy.delegate$ = ISemaphore.Module null
        Semaphore.Proxy.abstractInstances$ = false
module-wide constants & types
 
        const Semaphore.PendStatus_ERROR;
        const Semaphore.PendStatus_TIMEOUT;
        const Semaphore.PendStatus_SUCCESS;
module-wide config parameters
 
 
proxy Semaphore.Proxy

Proxy used for optimization

XDCscript usage meta-domain
Semaphore.Proxy = ISemaphore.Module null
// some delegate module inheriting the ISemaphore interface
    Semaphore.Proxy.delegate$ = ISemaphore.Module null
    // explicit access to the currently bound delegate module
    Semaphore.Proxy.abstractInstances$ = false
    // use indirect runtime function calls if true
 
DETAILS
If ALL ISemaphore.Handles were created using the same module (e.g SemProcess) then setting this Proxy to SemProcess and setting Semaphore.Proxy.abstractInstances$ = false, Semaphore APIs can have better performance.
 
const Semaphore.FOREVER

Used as the timeout value to specify wait forever

XDCscript usage meta-domain
const Semaphore.FOREVER = ISemaphore.FOREVER;
 
C SYNOPSIS
 
enum Semaphore.PendStatus

Error codes returned by Semaphore_pend

XDCscript usage meta-domain
values of type Semaphore.PendStatus
    const Semaphore.PendStatus_ERROR;
    const Semaphore.PendStatus_TIMEOUT;
    const Semaphore.PendStatus_SUCCESS;
 
C SYNOPSIS
 
metaonly config Semaphore.common$  // module-wide

Common module configuration parameters

XDCscript usage meta-domain
Semaphore.common$ = Types.Common$ undefined;
 
DETAILS
All modules have this configuration parameter. Its name contains the '$' character to ensure it does not conflict with configuration parameters declared by the module. This allows new configuration parameters to be added in the future without any chance of breaking existing modules.
generated on Thu, 01 Mar 2012 16:58:45 GMT