Jump to main content

##

# 1.4.4.5 OSAL_SEM_PostISR Function

## C

    OSAL_RESULT OSAL_SEM_PostISR(OSAL_SEM_HANDLE_TYPE* semID)

## Summary

Posts a semaphore or increments a counting semaphore from within an Interrupt Service Routine (ISR).

## Description

This function posts a binary semaphore or increments a counting semaphore. The highest priority task currently blocked on the semaphore will be released and made ready to run. This form of the post function should be used inside an ISR.

## Precondition

Semaphore must have been created.

## Parameters

Param | Description
--- | ---
semID | Pointer to the Semaphore ID

## Returns

OSAL_RESULT_TRUE - Semaphore posted

OSAL_RESULT_FALSE - Semaphore not posted

## Example

    void __ISR(UART_2_VECTOR) _UART2RXHandler()
    {
        char c;

        // read the character
        c = U2RXREG;
        // clear the interrupt flag
        IFS1bits.U2IF = 0;
        // post a semaphore indicating a character has been received
        OSAL_SEM_PostISR(&semSignal);

    }

## Remarks

This version of the OSAL_SEM_Post function should be used if the program is, or may be, operating inside an ISR. The OSAL will take the necessary steps to ensure correct operation possibly disabling interrupts or entering a critical section. The exact requirements will depend upon the particular RTOS being used.