Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Files

os.h/os_sem.c

Prototype

Code Block
void  OSSemCreate (OS_SEM      *p_sem,
                   CPU_CHAR    *p_name,
                   OS_SEM_CTR   cnt,
                   OS_ERR      *p_err)

Arguments

p_sem

is a pointer to the semaphore control block. It is assumed that storage for the semaphore will be allocated in the application. In other words, you need to declare a “global” variable as follows, and pass a pointer to this variable to OSSemCreate():

...

  1. Semaphores must be created before they are used.

Example Usage

Code Block
titleOSSemCreate() example usage
          OS_SEM  SwSem;
           
           
          void main (void)
          {
              OS_ERR  err;
           
           
              :
              OSInit(&err);                 /* Initialize µC/OS-III             */
              :  
              :
              OSSemCreate(&SwSem,           /* Create Switch Semaphore          */
                          "Switch Semaphore",
                           0,
                          &err);
              /* Check "err" */
              :
              :
              OSStart(&err);                /* Start Multitasking              */
          }