Wednesday, January 15, 2014

Rendezvous: Reply, Refer, Delete

① ITRON implementation of rpl_rdv

ER rpl_rdv(RDVNO rdvno, VP msg, UINT rmsgsz)
{
        Sanity check on arguments
        Enter critical section (Interrupt Disable)
        Check whether a task exists specified by the given Rendezous number.
        Check whether the calling task is in termination-waiting state.
        Confirm whether that task currently waits on this rendezous only.
        Check the return message size is not bigger than the maximu message size of cal_por.
        Copy the message from the argument to the call_por's pointer in the tcb
        Set the reply message size in the error code field of the task's tcb.
        if (tw-task is waiting in Timeout)
                Remove from timer queue
        Set tw-task status as Ready
        if (the tw-task is NOT suspended) {
                Add the tw-task to the Ready Queue of priority
                If (the tw-task priority is higher than the current){
                        Call scheduler
                        Return error code from scheduler
                } else {
                        Exit critical section and return error code from it (E_OK)
                        (return E_OK)
                }
        }
        Exit critical section and return the error code from it (E_OK)
        (return E_OK)
}

② ITRON implementation of ref_por

ER ref_por(ID porid, T_RPOR *pk_rpor)
{
        Sanity check on arguments
        Enter critical section (Interrupt Disable)
        Assign ctskid with TSK_NONE or first valid task id at the head of call wait queue
        Assign atskid  with TSK_NONE or first valid task id at the head of accept wait queue
        Exit critical section and return the error code from it (E_OK)
        (return E_OK)
}

③ ITRON implementation of ref_rdv

ER ref_rdv(RDVNO rdvno, T_RRDV *pk_rrdv)
{
        Sanity check on arguments
        Enter critical section (Interrupt Disable)
        Check the taskid specified by the rdvno waits for the same rdvno;
        If so assign wtskid with the task id, otherwise TSK_NONE.
        Exit critical section and return the error code from it (E_OK)
        (return E_OK)
}

④ ITRON implementation of del_por

ER del_por(ID porid)
{
        Sanity check on arguments
        If called from ISR
                return E_CTX;
        Enter critical section (Interrupt Disable)
        /* Release all tasks waiting with E_DLT
        for (each task in the accept & calling waiting queue)
        {
                Get the task control block from the task ID
                Assign E_DLT in the return error code of the task's context;
                if task is waiting in Timeout
                        remove from timer queue
                Set task status as Ready
                if the task is NOT suspended {
                        Change the task to the Ready Queue of priority
                        If (the task priority is higher than the current)
                                set the flag to call scheduler
                } else {
                        Just delete the task from the send wait queue
                }
        }
        Free all the memory allocated for the data queue;
        if (the flag to call scheduler is set) {
                call scheduler;
        } else {
                exit critical section and return E_OK;
        }
}
 

No comments: