Metrologic Optimus S Programming Manual page 236

"c" programming guide
Table of Contents

Advertisement

230
"C" Programming Guide For Optimus S/R
OSSemPost
OSTaskCreate
Purpose
To signal the semaphore.
Syntax
unsigned char OSSemPost (OS_Event *pevent);
where, pevent is a pointer to the semaphore. This pointer is returned to your
application when the semaphore is created.
Example
err = OSSemPost (DispSem);
Description
A semaphore is signaled by calling OSSemPost. If the value of a semaphore is
greater than or equal to zero, the semaphore count is incremented and
OSSemPost returns to its caller. If the semaphore count is less than zero, then
tasks are waiting for the semaphore to be signaled. In this case, OSSemPost
removes the highest priority task pending for the semaphore from the pending
list and makes this task ready to run. The scheduler is then called to determine
if the awakened task is now the highest priority task ready to run.
Note that semaphores must be created before they are used.
Return
If successful, it returns OS_NO_ERR. (i.e. the semaphore is available)
Otherwise, it returns OS_TIMEOUT. (i.e. timeout occurred)
See Also
OSSemCreate, OSSemPend
Purpose
To create a task.
Syntax
unsigned char OSTaskCreate (void (*task) (void * pd), void *pdata, unsigned
char *pstk, unsigned long stk_size, unsigned char prio);
where, task is a pointer to the task's code.
pdata is a pointer to an optional data area, which can be used to pass parameters
to the task when it is created.
pstk is a pointer to the task's top of stack. The stack is used to store local
variables, function parameters, return addresses, and CPU registers during an
interrupt. The size of this stack is defined by the task requirements and the
anticipated interrupt nesting. Determining the size of the stack involves
knowing how many bytes are required for storage of local variables for the task
itself, all nested functions, as well as requirements for interrupts (accounting
for nesting).
prio is the task priority. A unique priority number must be assigned to each
task; the lower the number, the higher the priority.
Example
OSTaskCreate (beep_task, (void *)0, beep_stk, 256, 10);
static unsigned char beep_stk [256];
Description
This function allows an application to create a task. The task is managed by
µC/OS. Tasks can be created prior to the start of multitasking or by a running
task. Note that a task cannot be created by an ISR.
/* create a beep_task with priority 10 */

Advertisement

Table of Contents
loading

This manual is also suitable for:

Optimus r

Table of Contents