①Event Flags: Clear/Refer/Delete event flags
As, these functions are not holding much share of programming, let me put all these in one post. And, these functions are exactly same as of Semaphore, though Semaphore does not have a function equivalent to clr_flg().
② uITRON implementation to clear event flag
ER clr_flg(ID flgid, FLGPTN clrptn)
{
Sanity check on arguments
Enter critical section (Interrupt Disable)
existing flag pattern &= clrptn;
Exit critical section (Interrupt Restore)
return E_OK;
}
③ uITRON implementation to refer event flag information
ER ref_flg(ID flgid, T_RFLG *pk_rflg)
{
Sanity check on arguments
Enter critical section (Interrupt Disable)
Store event flag's current bit pattern
Store ID number of task which is at the head of flag's wait queue
Exit critical section (Interrupt Restore)
return E_OK;
}
④ uITRON implementation to delete flag
ER del_mtx(ID mtxid)
{
Check context. If called from ISR,
return E_CTX;
Sanity check on arguments
Enter critical section (Interrupt Disable)
For each task waiting on the event flag's queue {
Set E_DLT at the error code register of task's context
If task is waiting for timeout {
Delete task from timer queue
}
Set task's status as Ready
If task is not in suspended state {
Change the task from event flag's queue to ready queue
If executing task's priority is lower than the waiting,
set to execute scheduler when quitting this function
}
else {
Delete the task from the event flag queue
}
}
Release resources allocated when creating event flag(Release event flag's queue)
If scheduler has to be executed {
Call scheduler
Return the error code in the context's error code register
}
Exit critical section (Interrupt Restore)
return E_OK;
}
Please visit other posts under RTOS label.
As, these functions are not holding much share of programming, let me put all these in one post. And, these functions are exactly same as of Semaphore, though Semaphore does not have a function equivalent to clr_flg().
② uITRON implementation to clear event flag
ER clr_flg(ID flgid, FLGPTN clrptn)
{
Sanity check on arguments
Enter critical section (Interrupt Disable)
existing flag pattern &= clrptn;
Exit critical section (Interrupt Restore)
return E_OK;
}
③ uITRON implementation to refer event flag information
ER ref_flg(ID flgid, T_RFLG *pk_rflg)
{
Sanity check on arguments
Enter critical section (Interrupt Disable)
Store event flag's current bit pattern
Store ID number of task which is at the head of flag's wait queue
Exit critical section (Interrupt Restore)
return E_OK;
}
④ uITRON implementation to delete flag
ER del_mtx(ID mtxid)
{
Check context. If called from ISR,
return E_CTX;
Sanity check on arguments
Enter critical section (Interrupt Disable)
For each task waiting on the event flag's queue {
Set E_DLT at the error code register of task's context
If task is waiting for timeout {
Delete task from timer queue
}
Set task's status as Ready
If task is not in suspended state {
Change the task from event flag's queue to ready queue
If executing task's priority is lower than the waiting,
set to execute scheduler when quitting this function
}
else {
Delete the task from the event flag queue
}
}
Release resources allocated when creating event flag(Release event flag's queue)
If scheduler has to be executed {
Call scheduler
Return the error code in the context's error code register
}
Exit critical section (Interrupt Restore)
return E_OK;
}
No comments:
Post a Comment