Saturday, December 14, 2013

Message Buffer vs Data Queue: Refer status

① Difference between referring Message Buffer and Data Queue

ref_mbf() returns the task id for waiting receive and send tasks, number of messages in the buffer and size of free message buffer area.
ref_dtq() returns the task id for waiting receive and send tasks and number of data elements in the data queue.

② ITRON implementation of referring message buffer
ER ref_mbf(ID mbfid, T_RMBF *pk_rmbf)
{
        Sanity check on arguments;
        enter critical section;
        parse through the buffer byte-by-byte by checking the boundary to check number of valid messages and
                store it in pk_rmbf->smsgcnt;
        store the free buffer size in pk_rmbf->pk_rmbf
        check the receive waiting task queue;
        if (any task exists) {
                store the task id into the pk_rmbf->stskid;
        }
        else {
                pk_rmbf->stskid = TSK_NONE;
        }
        check the send waiting task queue;
        if (any task exists) {
                store the task id into the pk_rmbf->rtsk_d;
        }
        else {
                pk_rmbf->rtsk_d = TSK_NONE;
        }
        exit critical section;
        return E_OK;
}
 

No comments: