Saturday, June 29, 2013

Semaphore Vs Mutex: Refer state

① Refer Semaphore and Mutex information

Though it is not very commplex process, just put it for reference.

② uITRON implementation to refer semaphore information

ER ref_mtx(ID mtxid, T_RMTX *pk_rmtx)
{
        Sanity check on arguments
        Enter critical section (Interrupt Disable)
        Store ID number of task locking the mutex
        Store ID number of task which is at the head of mutex's wait queue
        Exit critical section (Interrupt Restore)
        return E_OK;
}

③ uITRON implementation to refer mutex information

ER ref_sem(ID semid, T_RSEM *pk_rsem)
{
        Sanity check on arguments
        Enter critical section (Interrupt Disable)
        Store ID number of task which is at the head of semaphore's wait queue
        Store the semaphore resource count (remaining number of resources)
        Exit critical section (Interrupt Restore)
        return E_OK;
}

For other posts, please under RTOS label.

No comments: