① Difference between referring Data Queue and Mailbox
② ITRON implementation of referring data queue
ER ref_dtq(ID dtqid, T_RDTQ *pk_rdtq)
{
Sanity check on arguments;
enter critical section;
store the number of data elements in the data queue into the pk_rdtq->sdtqcnt;
check the receive waiting task queue;
if (any task exists) {
store the task id into the pk_rdtq->stsk_id;
}
else {
pk_rdtq->stsk_id = TSK_NONE;
}
check the send waiting task queue;
if (any task exists) {
store the task id into the pk_rdtq->rtsk_id;
}
else {
pk_rdtq->rtsk_id = TSK_NONE;
}
exit critical section;
return E_OK;
}
③ ITRON implementation of referring Mailbox
ER ref_mbx(ID mbxid, T_RMBX *pk_rmbx)
{
Sanity check on arguments;
enter critical section;
/* Check for the pending message first */
get the head of message queue;
for (each priority level of the messages) {
get the head pointer to the message queue for the particular level;
if (there is message) {
store the pointer to the message into the pk_rmbx->pk_msg;
make pk_rmbx->wtskid = TSK_NONE;
return E_OK;
}
}
/* No message; So, check for any waiting task */
make the pk_rmbx->pk_msg =NULL;
check for any waiting receive task over the queue;
if (there is any task) {
store the task id into the pk_rmbx->wtskid;
return E_OK;
}
/* No task either */
pk_rmbx->wtskid = TSK_NONE;
return E_OK;
}
Enjoy embedded RTOS...
ref_dtq() returns the task id for waiting receive and send tasks and number of data elements in the data queue.
ref_mbx() has to return either the pointer to the message at the top of the message queue or the task ID which is waiting at the receive waiting queue.
② ITRON implementation of referring data queue
ER ref_dtq(ID dtqid, T_RDTQ *pk_rdtq)
{
Sanity check on arguments;
enter critical section;
store the number of data elements in the data queue into the pk_rdtq->sdtqcnt;
check the receive waiting task queue;
if (any task exists) {
store the task id into the pk_rdtq->stsk_id;
}
else {
pk_rdtq->stsk_id = TSK_NONE;
}
check the send waiting task queue;
if (any task exists) {
store the task id into the pk_rdtq->rtsk_id;
}
else {
pk_rdtq->rtsk_id = TSK_NONE;
}
exit critical section;
return E_OK;
}
③ ITRON implementation of referring Mailbox
ER ref_mbx(ID mbxid, T_RMBX *pk_rmbx)
{
Sanity check on arguments;
enter critical section;
/* Check for the pending message first */
get the head of message queue;
for (each priority level of the messages) {
get the head pointer to the message queue for the particular level;
if (there is message) {
store the pointer to the message into the pk_rmbx->pk_msg;
make pk_rmbx->wtskid = TSK_NONE;
return E_OK;
}
}
/* No message; So, check for any waiting task */
make the pk_rmbx->pk_msg =NULL;
check for any waiting receive task over the queue;
if (there is any task) {
store the task id into the pk_rmbx->wtskid;
return E_OK;
}
/* No task either */
pk_rmbx->wtskid = TSK_NONE;
return E_OK;
}
Enjoy embedded RTOS...
No comments:
Post a Comment