Versions Compared

Key

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

...

Files

os.h/os_sem.c

Prototype

Code Block

OS_SEM_CTR  OSSemPost (OS_SEM  *p_sem,
                       OS_OPT   opt,
                       OS_ERR  *p_err)

Arguments

p_sem

is a pointer to the semaphore.

...

  1. Semaphores must be created before they are used.
  2. You can also post to a semaphore from an ISR but the semaphore must be used as a signaling mechanism and not to protect a shared resource.

Example Usage

Code Block
titleOSSemPost() example usage
          OS_SEM  SwSem;
           
           
          void  TaskX (void  *p_arg)
          {
              OS_ERR      err;
              OS_SEM_CTR  ctr;
           
           
              (void)&p_arg;
              while (DEF_ON) {
                  :
                  :
                  ctr = OSSemPost(&SwSem,
                                   OS_OPT_POST_1 + OS_OPT_POST_NO_SCHED,
                                  &err);
                  /* Check "err" */
                  :
                  :
              }
          }