Versions Compared

Key

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

...

Description

OSTaskSemSet() allows the user to set the value of the task’s signal counter. You would set the signal counter of the calling task by passing a NULL pointer for p_tcb.

Files

os.h/os_task.c

Prototype

Code Block
OS_SEM_CTR  OSTaskSemSet (OS_TCB      *p_tcb,

...


                          OS_SEM_CTR

...

   cnt;
                          OS_ERR      *p_err)

Arguments

p_tcb

is a pointer to the task’s OS_TCB to clear the signal counter. A NULL pointer indicates that the user wants to clear the caller’s signal counter.

Anchor10058001005800cntanchor10058031005803

the desired value for the task semaphore counter.

...

p_err Anchor10058051005805

is a pointer to a variable that will contain an error code returned by this function.

...

...

OS_ERR_NONE

...

classWebWorks_Indent_2

...

If the call was successful and the signal counter was

...

set.

...

...

OS_ERR_SET_ISR

...

classWebWorks_Indent_2

...

If OS_CFG_CALLED_FROM_ISR_CHK_EN set to

...

DEF_ENABLED in os_cfg.h: if calling this function from an ISR

...

.

OS_ERR_TASK_WAITING

If tasks are waiting on the semaphore, the count is not changed.

Returned Value

Anchor10058111005811The new value of the signal counter prior to setting it. Anchor10058121005812

Required Configuration

Always enabled.

Callers

Application.

Notes/Warnings

...

rowspan15

...

  1. Do not call OSTaskSemSet() from an ISR.

Example Usage

Code Block
titleOSTaskSemSet() example usage
          OS_TCB   TaskY;
           
           
          void TaskX (void *p_arg)
          {
              OS_ERR      err;
              OS_SEM_CTR  ctr;
           
           
              while (DEF_ON) {
                  :
                  :
                  ctr = OSTaskSemSet(&TaskY,
                                      0,
                                     &err);
                  /* Check "err" */
                  :
                  :
              }
          }