task delete and semaphore

WuHao derossi at mail.ustc.edu.cn
Mon Jul 2 02:21:50 UTC 2007


rtems4.7

rtems_task_delete will delete a task and release all resources it holds,
however except semaphores.
When try to run testsuites I got an unexpected executing by accident:

Objects:
TA1:task 1, priority 3;
TA2:task 2, priority 1;
SM:mutex, "unlocked" initial state, "priority inheirt" waitqueue discipline;

Process:
1.TA1 holds mutex SM;
2.TA1 is preempted by TA2;
3.TA2 deletes TA1, the mutex SM's holder will be TA1 forever;
4.TA2 trys to hold SM, because SM is held by TA1, TA2 will wait for SM.
Before TA2 enqueues SM's waitqueue, a "_Thread_Change_priority" function
will be performed to change TA1's priority form 3 to 1 due to the
"priority inheirt" discipline. However,"_Thread_Change_priority"
function will move TA1 to "Ready_Chain". Thus the deleted task TA1
becomes ready again.
5.TA2 is blocked, TA1 gets CPU and run..................

Should semaphore release be done?

Thanks.



More information about the users mailing list