...
Code Block | ||
---|---|---|
| ||
OS_SEM MySem; (1) void main (void) { OS_ERR err; : : OSInit(&err); : OSSemCreate(&MySem, (2) "My Semaphore", (3) 1, (4) &err); (5) /* Check "err" */ : /* Create task(s) */ : OSStart(&err); (void)err; } |
Panel | ||||
---|---|---|---|---|
| ||||
(1) The application must declare a semaphore as a variable of type (2) You create a semaphore by calling (3) You can assign an ASCII name to the semaphore, which can be used by debuggers or µC/Probe to easily identify the semaphore. Storage for the ASCII characters is typically in ROM, which is typically more plentiful than RAM. If it is necessary to change the name of the semaphore at runtime, you can store the characters in an array in RAM and simply pass the address of the array to (4) You specify the initial value of the semaphore. You should initialize the semaphore to 1 when the semaphore is used to access a single shared resource (as in this example). (5) |
...