SEM_create
Application Program Interface
2-373
C Interface
Syntax
sem = SEM_create(count, attrs);
Parameters
Int
count;
/* initial semaphore count */
SEM_Attrs
*attrs;
/* pointer to semaphore attributes */
Return Value
SEM_Handle sem;
/* handle for new semaphore object */
Description
SEM_create creates a new semaphore object which is initialized to
count. If successful, SEM_create returns the handle of the new
semaphore. If unsuccessful, SEM_create returns NULL unless it aborts
(for example, because it directly or indirectly calls SYS_error, and
SYS_error is configured to abort).
If attrs is NULL, the new semaphore is assigned a default set of
attributes. Otherwise, the semaphore’s attributes are specified through a
structure of type SEM_Attrs.
struct SEM_Attrs { /* semaphore attributes */
String name; /* printable name */
};
Default attribute values are contained in the constant SEM_ATTRS,
which can be assigned to a variable of type SEM_Attrs before calling
SEM_create.
SEM_Attrs SEM_ATTRS = { /* default attribute values */
"", /* name */
};
SEM_create calls MEM_alloc to dynamically create the object’s data
structure. MEM_alloc must acquire a lock to the memory before
proceeding. If another thread already holds a lock to the memory, there
is a context switch. The segment from which the object is allocated is
described by the DSP/BIOS objects property in the MEM Module.
Constraints and
Calling Context
❏
count must be greater than or equal to 0.
❏
SEM_create cannot be called from a SWI or HWI.
❏
You can reduce the size of your application by creating objects with
Tconf rather than XXX_create functions.
See Also
SEM_create
Create a semaphore