This module manages multi-process semaphores through its proxy
ISemProcessSupport interface. It has a module wide config parameter
Proxy which needs to be bound to an OS specific delegate before
this module can be used.
Here is an example showing how the proxy is bound to an BIOS 6.x specific
delegate.
var SemProcess = xdc.useModule('xdc.runtime.knl.SemProcess');
SemProcess.Proxy = xdc.useModule('ti.sysbios.xdcruntime.SemProcessSupport');
Typically the package containing the delegates have a Settings module that
will bind all
xdc.runtime.knl proxies. The following
example sets up all the xdc.runtime.knl proxies.
proxy SemProcess.Proxy |
|
Proxy that needs to be bound to an OS specific delegate
XDCscript usage |
meta-domain |
// explicit access to the currently bound delegate module
SemProcess.Proxy.abstractInstances$ = false
// use indirect runtime function calls if true
const SemProcess.FOREVER |
|
Used as the timeout value to specify wait forever
XDCscript usage |
meta-domain |
const SemProcess.FOREVER = ~(0);
#define SemProcess_FOREVER (UInt)~(0)
enum SemProcess.Mode |
|
Types of semaphores
XDCscript usage |
meta-domain |
values of type SemProcess.Mode
const SemProcess.Mode_COUNTING;
// Counting semaphore
const SemProcess.Mode_BINARY;
// Binary Semaphore
typedef enum SemProcess_Mode {
SemProcess_Mode_COUNTING,
// Counting semaphore
SemProcess_Mode_BINARY
// Binary Semaphore
} SemProcess_Mode;
enum SemProcess.PendStatus |
|
Error codes returned by Semaphore_pend
XDCscript usage |
meta-domain |
values of type SemProcess.PendStatus
const SemProcess.PendStatus_ERROR;
const SemProcess.PendStatus_TIMEOUT;
const SemProcess.PendStatus_SUCCESS;
typedef enum SemProcess_PendStatus {
SemProcess_PendStatus_ERROR,
SemProcess_PendStatus_TIMEOUT,
SemProcess_PendStatus_SUCCESS
} SemProcess_PendStatus;
metaonly config SemProcess.common$ // module-wide |
|
Common module configuration parameters
XDCscript usage |
meta-domain |
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.
module-wide built-ins |
|
// Get this module's unique id
Bool SemProcess_Module_startupDone( );
// Test if this module has completed startup
// The heap from which this module allocates memory
per-instance object types |
|
typedef struct SemProcess_Object SemProcess_Object;
// Opaque internal representation of an instance object
// Client reference to an instance object
typedef struct SemProcess_Struct SemProcess_Struct;
// Opaque client structure large enough to hold an instance object
// Convert this instance structure pointer into an instance handle
// Convert this instance handle into an instance structure pointer
per-instance config parameters |
|
XDCscript usage |
meta-domain |
var params = new SemProcess.Params;
// Instance config-params object
// Semaphore mode. Default is COUNTING
typedef struct SemProcess_Params {
// Instance config-params structure
// Common per-instance configs
// Semaphore mode. Default is COUNTING
} SemProcess_Params;
// Initialize this config-params structure with supplier-specified defaults before instance creation
config SemProcess.mode // per-instance |
|
Semaphore mode. Default is COUNTING
XDCscript usage |
meta-domain |
var params = new SemProcess.Params;
...
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.
per-instance creation |
|
XDCscript usage |
meta-domain |
var params =
new SemProcess.
Params;
// Allocate instance config-params
params.config = ...
// Assign individual configs
var inst = SemProcess.create( Int count, UInt32 key, params );
// Create an instance-object
// Allocate and initialize a new instance object and return its handle
// Initialize a new instance object inside the provided structure
ARGUMENTS
count
initial semaphore count
key
globally unique key for SysV-style semaphore
params
per-instance config params, or NULL to select default values (target-domain only)
eb
active error-handling block, or NULL to select default policy (target-domain only)
DETAILS
This function creates a new SemProcess object which is initialized to
count. All semaphores created with the same key reference the same
underlying synchronization object and work between processes.
per-instance deletion |
|
// Finalize and free this previously allocated instance object, setting the referenced handle to NULL
// Finalize the instance object inside the provided structure
SemProcess.pend( ) // per-instance |
|
Wait for the semaphore to become available
ARGUMENTS
handle
handle of a previously-created SemProcess instance object
timeout
timeout in microseconds
eb
error block
DETAILS
RETURNS
refer to description above
SemProcess.post( ) // per-instance |
|
Increment the semaphore count
ARGUMENTS
handle
handle of a previously-created SemProcess instance object
eb
error block
RETURNS
true for success, false for error in error block
per-instance convertors |
|
// unconditionally move one level up the inheritance hierarchy
// conditionally move one level down the inheritance hierarchy; NULL upon failure
per-instance built-ins |
|
Int SemProcess_Object_count( );
// The number of statically-created instance objects
// The handle of the i-th statically-created instance object (array == NULL)
// The handle of the first dynamically-created instance object, or NULL
// The handle of the next dynamically-created instance object, or NULL
// The heap used to allocate dynamically-created instance objects
// The label associated with this instance object
// The name of this instance object