① Delete Variable and Fixed Memory Pool
Similar to creation of memory pool, deletion cannot be done from interrupt context. Deletion can be done from task contexts which has some priority value. All the waiting tasks in the queue are just waken up and E_DLT is set as return error code for them.
Deletion of fixed memory pool is same as variable memory pool.
② uITRON implementation to delete variable memory pool
ER del_mpl(ID mplid)
{
Check context. If called from ISR,
return E_CTX;
Sanity check on arguments
Enter critical section (Interrupt Disable)
For each task waiting on the memory pool'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 memory pool'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 semaphore queue
}
}
Release the memory allocated for the memory pool
Release resources allocated when creating memory pool(Release memory pool'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;
}
③ uITRON implementation to delete fixed memory pool
ER del_mpf(ID mpfid)
{
Check context. If called from ISR,
return E_CTX;
Sanity check on arguments
Enter critical section (Interrupt Disable)
If (head pointer points to NULL == 0) { /* no memory. some task may be waiting */
For each task waiting on the memory pool'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 memory pool'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 semaphore queue
}
}
}
Release the memory allocated for the memory pool
Release resources allocated when creating memory pool(Release memory pool'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 find other function details under RTOS label.
Similar to creation of memory pool, deletion cannot be done from interrupt context. Deletion can be done from task contexts which has some priority value. All the waiting tasks in the queue are just waken up and E_DLT is set as return error code for them.
Deletion of fixed memory pool is same as variable memory pool.
② uITRON implementation to delete variable memory pool
ER del_mpl(ID mplid)
{
Check context. If called from ISR,
return E_CTX;
Sanity check on arguments
Enter critical section (Interrupt Disable)
For each task waiting on the memory pool'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 memory pool'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 semaphore queue
}
}
Release the memory allocated for the memory pool
Release resources allocated when creating memory pool(Release memory pool'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;
}
③ uITRON implementation to delete fixed memory pool
ER del_mpf(ID mpfid)
{
Check context. If called from ISR,
return E_CTX;
Sanity check on arguments
Enter critical section (Interrupt Disable)
If (head pointer points to NULL == 0) { /* no memory. some task may be waiting */
For each task waiting on the memory pool'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 memory pool'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 semaphore queue
}
}
}
Release the memory allocated for the memory pool
Release resources allocated when creating memory pool(Release memory pool'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