Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preempted Task does not resume from last step #7

Closed
kuldeepgade opened this issue Oct 20, 2021 · 12 comments
Closed

Preempted Task does not resume from last step #7

kuldeepgade opened this issue Oct 20, 2021 · 12 comments

Comments

@kuldeepgade
Copy link

@Chalandi : If 5ms task is in execution, at certain step, 1ms Tick arrived. Control shall passes to 1ms.
But, while coming back to 5ms, it shall resume execuion from the point it left.
This is not happening.
Please suggets your inputs.

Thanks

@Chalandi
Copy link
Owner

@kuldeepgade : Can you explain more what you mean by "This is not happening" ?

When you have in your application another higher prio task than the 5ms task which became ready just after the execution of the systick interrupt, the OS will switch the context to this higher prio task instead of coming back to the 5ms (after the systick ISR execution).

Is that the case in your application ?

@kuldeepgade
Copy link
Author

kuldeepgade commented Oct 20, 2021

16347227869271579428876713873786

@Chalandi : Task execution flow is explained in this diagram

@Chalandi
Copy link
Owner

@kuldeepgade : Could you share your OS Config file ?

@kuldeepgade
Copy link
Author

@Chalandi :
Configuration file will be in different format.
But, I can share you details like priority.
Idle_Task- 5,
Init_Task - 4,
1ms Task- 3,
5ms Task - 2
All tasks are EXTENDED, SUSPENDED, FULL PREEMPTIVE.

Only INIT Task is AUTOSTART task.

@Chalandi
Copy link
Owner

What about the stack sizes ? Do you terminate the task TASK_5ms for any reason in your code ?

@kuldeepgade
Copy link
Author

kuldeepgade commented Oct 20, 2021

  1. Stack Sizes assigned for each task = 64 Words = 256 bytes. [How to optimize this? as it consumes much RAM]
  2. I do terminate each Task.

Example:
TASK(T_5MS)
{
for (; ;)
{
function code;
TerminateTask();
}
}

TASK(T_1MS)
{
for (; ;)
{
function code;
TerminateTask();
}
}

@kuldeepgade
Copy link
Author

@Chalandi : it seems like context saving is successful but context reloading / restoring is not happening for preempted task.
Each time it create new context and start execution from beginning of task.

@kuldeepgade
Copy link
Author

@Chalandi : can you suggest something, why control doesn't return after POP instruction execution in both the handlers.
POP("");
BX LR;

@Chalandi
Copy link
Owner

@kuldeepgade : Could you please share more details about the issue ? maybe share a piece of code and a brief description of the issue in order to help you fixing it

@kuldeepgade
Copy link
Author

kuldeepgade commented Dec 15, 2021

@Chalandi : in OsAsm.c, Os_Dispatcher, Line-40,
control never returns to this line after execution of POP instruction on line-39.
Similarly, for Os_Cat2IsrWrapper function,
Control never returns to Line-105, after execution of POP instruction on Line-103.
20211215_202700
20211215_202626

@Chalandi
Copy link
Owner

@kuldeepgade : how did you checked that the last two instructions are never executed ?
The instruction POP here doesn't update the PC register so the CPU must continue executing the last two instructions (cpsie and bx) before exit the exception handler :

image

Are you running the OS on Cortex-M3 CPU ? This OS version was made for Cortex-M3 without FPU, so if you're running it on any other Cortex-M with FPU enabled you will get some lazy stacking issues as this OS doesn't support the FPU.

@kuldeepgade
Copy link
Author

@Chalandi : I checked with debugger breakpoints.
Thanks for your inputs.

Chalandi pushed a commit that referenced this issue May 14, 2023
Continue work cross GCC build but startup TODO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants