ciaa / firmware_v1

Firmware de la CIAA
http://www.proyecto-ciaa.com.ar
125 stars 120 forks source link

wrong task is executed in ctest_rm_02 and ctest_rm_03 #100

Closed mcerdeiro closed 9 years ago

mcerdeiro commented 10 years ago

wrong task is executed in ctest_rm_02

in ctest_rm_02 two tasks with priorities 1 and 2 have a resource1, the task with priority 1 get the resource and activate task with priority 2 and other with priority 3, the task with priority 3 is executed and when terminates the task with priority 2 is executed and NOT task with priority 1 and the resource is it shall be executed. this is a BUG... :(

mcerdeiro commented 9 years ago

the bug is in the function: https://github.com/ciaa/Firmware/blob/master/modules/rtos/src/Os_Internal.c#L159

this search does not take into account the dinamic priority if the task has some resources as in the test case.

mcerdeiro commented 9 years ago

Test: ctest_rm_02/Extended-with-mixed-preemptive will never run ok there is a contradiction between OSEK and Test OSEK: in Schedule api definition: http://portal.osek-vdx.org/files/pdf/specs/os223.pdf page 53 Extended Return Values are: Extended: • Call at interrupt level, E_OS_CALLEVEL • Calling task occupies resources, E_OS_RESOURCE

so Schedule will return E_OS_RESOURCE if a scheduling is forced and a resource is taken. Testplan RM_02 requires exactly this http://portal.osek-vdx.org/files/pdf/modistarc/ostestproc20.pdf page 37: Task1 GetResource(Resource1) E_OK 6 Task1 ActivateTask(Task2) E_OK Task1 force scheduling Task1 ActivateTask(Task3) E_OK Task1 force scheduling E_OK Task3 TerminateTask()

the first force scheduling works because there is no task with higer prio, the second one failed since there is a higher prio task but the task to be preempted has a resource and returns E_OS_RESOURCE which is conform to the specifificaiton.

mcerdeiro commented 9 years ago

Neither works Extended-with-non-preemptive (extended return errors will never work E_OS_RESOURCE will be returned. this shall be documented, new issue for that.

mcerdeiro commented 9 years ago

done :)