interface xdc.runtime.knl.ISemaphore

Interface implemented by all front-end semaphore providers. SemThread and SemProcess. [EXPERIMENTAL]

Semaphores can be used for synchronization and mutual exclusion. [ more ... ]
XDCspec summary sourced in xdc/runtime/knl/ISemaphore.xdc
interface ISemaphore {  ...
// inherits xdc.runtime.IModule
instance:  ...
XDCspec declarations sourced in xdc/runtime/knl/ISemaphore.xdc
package xdc.runtime.knl;
 
interface ISemaphore {
module-wide constants & types
 
    };
 
        PendStatus_ERROR,
        PendStatus_TIMEOUT,
        PendStatus_SUCCESS
    };
module-wide config parameters
 
 
instance:
per-instance config parameters
per-instance functions
}
C synopsis target-domain
#include <xdc/runtime/knl/ISemaphore.h>
per-instance object types
per-instance config parameters
        IInstance_Params *instance;
    } ISemaphore_Params;
 
DETAILS
Semaphores can be used for synchronization and mutual exclusion.
pend() is used to wait for a semaphore. The timeout parameter allows the caller to wait until a timeout, wait indefinitely, or not wait at all. The return value indicates whether or not the wait was successful.
post() is used to signal a semaphore. If no thread is waiting on the semaphore, then post() increments the semaphore count (for binary semaphores, the count is always 0 or 1).
getCount() returns the count of the semaphore.
reset() sets the semaphore count to a given value. There should be no threads waiting on the semaphore when reset() is called.
 
const ISemaphore.FOREVER

Used as the timeout value to specify wait forever

XDCspec declarations sourced in xdc/runtime/knl/ISemaphore.xdc
const UInt FOREVER = ~(0);
 
 
enum ISemaphore.Mode

Types of semaphores

XDCspec declarations sourced in xdc/runtime/knl/ISemaphore.xdc
enum Mode {
    Mode_COUNTING,
    // Counting semaphore
    Mode_BINARY
    // Binary Semaphore
};
 
 
enum ISemaphore.PendStatus

Error codes returned by Semaphore_pend

XDCspec declarations sourced in xdc/runtime/knl/ISemaphore.xdc
enum PendStatus {
    PendStatus_ERROR,
    PendStatus_TIMEOUT,
    PendStatus_SUCCESS
};
 
 
metaonly config ISemaphore.common$  // module-wide

Common module configuration parameters

XDCspec declarations sourced in xdc/runtime/knl/ISemaphore.xdc
metaonly config Types.Common$ common$;
 
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.
 
per-instance object types

C synopsis target-domain
typedef struct ISemaphore_Object *ISemaphore_Handle;
// Client reference to an abstract instance object
 
per-instance config parameters

XDCscript usage meta-domain
var params = new ISemaphore.Params;
// Instance config-params object
    params.mode = ISemaphore.Mode ISemaphore.Mode_COUNTING;
    // Semaphore mode. Default is COUNTING
C synopsis target-domain
typedef struct ISemaphore_Params {
// Instance config-params structure
    IInstance_Params *instance;
    // Common per-instance configs
    ISemaphore_Mode mode;
    // Semaphore mode. Default is COUNTING
} ISemaphore_Params;
 
config ISemaphore.mode  // per-instance

Semaphore mode. Default is COUNTING

XDCspec declarations sourced in xdc/runtime/knl/ISemaphore.xdc
 
DETAILS
When mode is BINARY , the semaphore has only two states, available and unavailable. When mode is COUNTING, the semaphore keeps track of number of times a semaphore is posted.
 
ISemaphore.pend( )  // per-instance

Wait for the semaphore to become available

XDCspec declarations sourced in xdc/runtime/knl/ISemaphore.xdc
Int pend( UInt timeout, Error.Block *eb );
 
ARGUMENTS
timeout — timeout in microseconds
eb — error block
DETAILS
RETURNS
refer to description above
 
ISemaphore.post( )  // per-instance

Increment the semaphore count

XDCspec declarations sourced in xdc/runtime/knl/ISemaphore.xdc
Bool post( Error.Block *eb );
 
ARGUMENTS
eb — error block
RETURNS
true for success, false for error in error block
generated on Thu, 25 Jun 2009 21:46:10 GMT