We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, i am new to real-time systems and rtx. my doubt is i have written a program in which i am creating two tasks one with while loop(task1) and one doesn't have while loop(task2),both with same priority.
my doubt here is when i execute my program when task1 is executing it executes for round robin timeout duration and gives chance to task2 which doesn't have while loop task2 executes once and continues to be in RUNNING state and task1 starts to execute in task2 stack and puts it in delay whereas i should not be put actually.
the code is as follows:
#include <RTL.h> OS_TID tid; __task void task3(void) { tid = os_tsk_self(); } __task void task2(void) { while(1) os_dly_wait(10); } __task void task1(void) { os_tsk_create(task2 , 0x01); os_tsk_create(task3 , 0x01); os_tsk_delete_self(); } int main() { os_sys_init(task1); }
Any reason you don't match the naming of the tasks in your text with the names actually used in the source code?
Anyway - the RTOS also has an idle task that will run when none of your own tasks are ready to run.
And, according to specification "All tasks must be implemented as endless loops. A task must never return." http://www.keil.com/support/man/docs/rlarm/rlarm_ar_task_def.htm
So your program is invalid, because it isn't fulfilling all documented requirements.
i am sorry for that wrong naming. my doubt is that, is it the case that if a while loop is missed then the next task will starts executing in the previous task's stack space.
It is the case that you get undefined behaviour if you run out of a task function, since Keil only documents that a function may not do that but doesn't document what failure you will get.
In your case, it's enough to know that your code isn't fulfilling the requirements - so either add a loop or have the thread kill itself.