Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Description

Changes the current value of the semaphore count. This function is normally selected when a semaphore is used as a signaling mechanism. OSSemSet() can then be used to reset the count to any value. If the semaphore count is already 0, the count is only changed if there are no tasks waiting on the semaphore.

Files

os.h/os_sem.c

Prototype

Arguments

p_sem

is a pointer to the semaphore that is used as a signaling mechanism.

cnt

is the desired count that the semaphore should be set to.

p_err

is a pointer to a variable used to hold an error code:

OS_ERR_NONE

If the count was changed or, not changed, because one or more tasks was waiting on the semaphore.

OS_ERR_OBJ_PTR_NULL

If OS_CFG_ARG_CHK_EN is set to 1 in os_cfg.h: if p_sem is a NULL pointer.

OS_ERR_OBJ_TYPE

If OS_CFG_OBJ_TYPE_CHK_EN is set to 1 in os_cfg.h: if p_sem is not pointing to a semaphore.

OS_ERR_SET_ISR

If OS_CFG_CALLED_FROM_ISR_CHK_EN set to 1 in os_cfg.h: if this function was called from an ISR.

OS_ERR_TASK_WAITING

If tasks are waiting on the semaphore.

Returned Value

None

Required Configuration

OS_CFG_SEM_EN and OS_CFG_SEM_SET_EN must be enabled in os_cfg.h. Refer to uC-OS-III Configuration Manual

Callers

Application.

Notes/Warnings

  1. Do not use this function if the semaphore is used to protect a shared resource.

Example Usage

  • No labels