www.beck-ipc.com

@CHIP-RTOS C Library - RTOS API


RTX_Reserve_Sem

Reserve a resource semaphore.   If current task is already the owner of this semaphore then the semaphore's usage count is incremented by one and the function returns immediately with success.

int RTX_Reserve_Sem ( int semID, long far *time_ms );

Parameters

semID

The semaphore ID of a resource semaphore acquired by a call to RTX_Create_Sem.

time_ms

Pointer for ms to wait: Zero -> Wait forever for semaphore
Positive value -> Maximum number of milliseconds to wait for resource
Negative value -> Polling mode, return immediately.   If semaphore was not available the return value will be the -27 time-out indication.

Return Value

0 on success else error code.

Comments

The calling task will be suspended to wait for the resource if the semaphore is owned by some other task.

When the resource is finally available for use by the caller, the procedure will return with 0.

Upon first acquiring ownership of the resource, the resouce's usage count is set to one.

It is permissible for a task to call RTX_Reserve_Sem even if the calling task already owns the resource.   The resource usage count is incremented by one for each subsequent call by the resource owner.

This usage count is down counted by RTX_Release_Sem and cleared by RTX_Free_Sem.   When the count reaches zero the task no longer owns the semaphore.

The wait priority used here is 20.   (See the RTX_Wait_Sem_Priority alternative API for explanation of wait priority.)

See Also

RTOS API

This library function invokes a RTOS software interrupt. Refer to this RTOS API function's documentation for more details.

Related Topics

RTX API   Overview

Supported since or modified in @CHIP-RTOS version

    SC12SC13SC11SC1x3SC2x
    V1.00V1.00V1.00V0.90V1.00

This API List
List of C Libraries
@CHIP-RTOS Main Index


End of document