module xdc.runtime.knl.SemThread

SemThread Manager. [EXPERIMENTAL]

This module manages semaphores through its proxy ISemThreadSupport 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. [ more ... ]
XDCspec summary sourced in xdc/runtime/knl/SemThread.xdc
module SemThread {  ...
    // inherits xdc.runtime.IModule
instance:  ...
C synopsis target-domain
#include <xdc/runtime/knl/SemThread.h>
module-wide constants & types
 
    typedef enum SemThread_Mode// Types of semaphores {
    } SemThread_Mode;
 
        SemThread_PendStatus_ERROR,
        SemThread_PendStatus_TIMEOUT,
module-wide built-ins
per-instance object types
 
per-instance config parameters
        IInstance_Params *instance;
    } SemThread_Params;
 
per-instance creation
per-instance deletion
per-instance functions
per-instance convertors
per-instance built-ins
 
XDCscript usage meta-domain
var SemThread = xdc.useModule('xdc.runtime.knl.SemThread');
local proxy modules
        SemThread.Proxy.delegate$ = ISemThreadSupport.Module null
        SemThread.Proxy.abstractInstances$ = false
module-wide constants & types
 
    values of type SemThread.Mode// Types of semaphores
 
        const SemThread.PendStatus_ERROR;
        const SemThread.PendStatus_TIMEOUT;
        const SemThread.PendStatus_SUCCESS;
module-wide config parameters
per-instance config parameters
    var params = new SemThread.Params// Instance config-params object;
per-instance creation
    var inst = SemThread.create// Create an instance-object( Int count, params );
 
XDCspec declarations sourced in xdc/runtime/knl/SemThread.xdc
package xdc.runtime.knl;
 
module SemThread inherits ISemaphore {
local proxy modules
    proxy Proxy inherits ISemThreadSupport;
module-wide constants & types
 
    };
 
        PendStatus_ERROR,
        PendStatus_TIMEOUT,
        PendStatus_SUCCESS
    };
module-wide config parameters
 
 
instance:
per-instance config parameters
per-instance creation
    create// Create an instance-object( Int count );
per-instance functions
}
DETAILS
This module manages semaphores through its proxy ISemThreadSupport 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 SemThread = xdc.useModule('xdc.runtime.knl.SemThread'); SemThread.Proxy = xdc.useModule('ti.sysbios.xdcruntime.SemThreadSupport');
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.
xdc.useModule("ti.sysbios.xdcruntime.Settings");
 
proxy SemThread.Proxy

Proxy that needs to be bound to an OS specific delegate

XDCscript usage meta-domain
SemThread.Proxy = ISemThreadSupport.Module null
// some delegate module inheriting the ISemThreadSupport interface
    SemThread.Proxy.delegate$ = ISemThreadSupport.Module null
    // explicit access to the currently bound delegate module
    SemThread.Proxy.abstractInstances$ = false
    // use indirect runtime function calls if true
 
 
const SemThread.FOREVER

Used as the timeout value to specify wait forever

XDCscript usage meta-domain
const SemThread.FOREVER = ~(0);
C synopsis target-domain
#define SemThread_FOREVER (UInt)~(0)
 
 
enum SemThread.Mode

Types of semaphores

XDCscript usage meta-domain
values of type SemThread.Mode
    const SemThread.Mode_COUNTING;
    // Counting semaphore
    const SemThread.Mode_BINARY;
    // Binary Semaphore
C synopsis target-domain
typedef enum SemThread_Mode {
    SemThread_Mode_COUNTING,
    // Counting semaphore
    SemThread_Mode_BINARY
    // Binary Semaphore
} SemThread_Mode;
 
 
enum SemThread.PendStatus

Error codes returned by Semaphore_pend

XDCscript usage meta-domain
values of type SemThread.PendStatus
    const SemThread.PendStatus_ERROR;
    const SemThread.PendStatus_TIMEOUT;
    const SemThread.PendStatus_SUCCESS;
C synopsis target-domain
typedef enum SemThread_PendStatus {
    SemThread_PendStatus_ERROR,
    SemThread_PendStatus_TIMEOUT,
    SemThread_PendStatus_SUCCESS
} SemThread_PendStatus;
 
 
metaonly config SemThread.common$  // module-wide

Common module configuration parameters

XDCscript usage meta-domain
SemThread.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.
 
module-wide built-ins

C synopsis target-domain
Types_ModuleId SemThread_Module_id( );
// Get this module's unique id
 
Bool SemThread_Module_startupDone( );
// Test if this module has completed startup
IHeap_Handle SemThread_Module_heap( );
// The heap from which this module allocates memory
 
 
per-instance object types

C synopsis target-domain
typedef struct SemThread_Object SemThread_Object;
// Opaque internal representation of an instance object
 
typedef SemThread_Object *SemThread_Handle;
// Client reference to an instance object
 
typedef struct SemThread_Struct SemThread_Struct;
// Opaque client structure large enough to hold an instance object
 
SemThread_Handle SemThread_handle( SemThread_Struct *structP );
// Convert this instance structure pointer into an instance handle
 
SemThread_Struct *SemThread_struct( SemThread_Handle handle );
// Convert this instance handle into an instance structure pointer
 
per-instance config parameters

XDCscript usage meta-domain
var params = new SemThread.Params;
// Instance config-params object
    params.mode = ISemaphore.Mode ISemaphore.Mode_COUNTING;
    // Semaphore mode. Default is COUNTING
C synopsis target-domain
typedef struct SemThread_Params {
// Instance config-params structure
    IInstance_Params *instance;
    // Common per-instance configs
    ISemaphore_Mode mode;
    // Semaphore mode. Default is COUNTING
} SemThread_Params;
 
Void SemThread_Params_init( SemThread_Params *params );
// Initialize this config-params structure with supplier-specified defaults before instance creation
 
config SemThread.mode  // per-instance

Semaphore mode. Default is COUNTING

XDCscript usage meta-domain
var params = new SemThread.Params;
  ...
C synopsis target-domain
struct SemThread_Params {
      ...
    ISemaphore_Mode mode;
 
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 SemThread.Params;
// Allocate instance config-params
params.config =   ...
// Assign individual configs
 
var inst = SemThread.create( Int count, params );
// Create an instance-object
C synopsis target-domain
SemThread_Handle SemThread_create( Int count, const SemThread_Params *params, Error_Block *eb );
// Allocate and initialize a new instance object and return its handle
 
Void SemThread_construct( SemThread_Struct *structP, Int count, const SemThread_Params *params, Error_Block *eb );
// Initialize a new instance object inside the provided structure
ARGUMENTS
count — initial semaphore count
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 SemThread object which is initialized to count.
 
per-instance deletion

C synopsis target-domain
Void SemThread_delete( SemThread_Handle *handleP );
// Finalize and free this previously allocated instance object, setting the referenced handle to NULL
 
Void SemThread_destruct( SemThread_Struct *structP );
// Finalize the instance object inside the provided structure
 
SemThread.pend( )  // per-instance

Wait for the semaphore to become available

C synopsis target-domain
Int SemThread_pend( SemThread_Handle handle, UInt timeout, Error_Block *eb );
 
ARGUMENTS
handle — handle of a previously-created SemThread instance object
timeout — timeout in microseconds
eb — error block
DETAILS
RETURNS
refer to description above
 
SemThread.post( )  // per-instance

Increment the semaphore count

C synopsis target-domain
Bool SemThread_post( SemThread_Handle handle, Error_Block *eb );
 
ARGUMENTS
handle — handle of a previously-created SemThread instance object
eb — error block
RETURNS
true for success, false for error in error block
 
per-instance convertors

C synopsis target-domain
ISemaphore_Handle SemThread_Handle_upCast( SemThread_Handle handle );
// unconditionally move one level up the inheritance hierarchy
 
SemThread_Handle SemThread_Handle_downCast( ISemaphore_Handle handle );
// conditionally move one level down the inheritance hierarchy; NULL upon failure
 
per-instance built-ins

C synopsis target-domain
Int SemThread_Object_count( );
// The number of statically-created instance objects
 
SemThread_Handle SemThread_Object_get( SemThread_Object *array, Int i );
// The handle of the i-th statically-created instance object (array == NULL)
 
SemThread_Handle SemThread_Object_first( );
// The handle of the first dynamically-created instance object, or NULL
 
SemThread_Handle SemThread_Object_next( SemThread_Handle handle );
// The handle of the next dynamically-created instance object, or NULL
 
IHeap_Handle SemThread_Object_heap( );
// The heap used to allocate dynamically-created instance objects
 
Types_Label *SemThread_Handle_label( SemThread_Handle handle, Types_Label *buf );
// The label associated with this instance object
 
String SemThread_Handle_name( SemThread_Handle handle );
// The name of this instance object
generated on Thu, 25 Jun 2009 21:46:10 GMT