230
"C" Programming Guide For Optimus S/R
OSSemPost
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
OSTaskCreate
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);
/* create a beep_task with priority 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.
Содержание Optimus R
Страница 1: ...Printed on 20 March 2006 C Programming Guide Version 3 04 02 Optimus S Optimus R...
Страница 6: ......
Страница 8: ...2 C Programming Guide For Optimus S R...
Страница 12: ...6 C Programming Guide For Optimus S R The flow is illustrated as shown below...
Страница 23: ...Chapter 2 Development Environment 17 Different types signed unsigned Different types same size...
Страница 24: ...18 C Programming Guide For Optimus S R...
Страница 220: ...214 C Programming Guide For Optimus S R See Also FlashSize free_memory...
Страница 232: ...226 C Programming Guide For Optimus S R 4 11 Implementation defined Limits limits h float h Refer to limit h and float h...
Страница 238: ...232 C Programming Guide For Optimus S R...