Hi
I'm using a few tasks as TIME_SLICE (time-slice = 100 millisec) and one main task which create this time-slice tasks and next it is blocked.
When I have finished main task, sheduler time-slice counter is not zero. As result first task has a little bit time less then 100 millisec.
How can I reset this time-slice counter before sheduller will start first time-slice counter?
Thanks in advance.
Good Luck.
Solved! Go to Solution.
Hi troll
scheduler time-slice is only a default value for time-slice. Don't bother with that.
You want to have the tasks run the same amount of time. In that case you need to start new task on the new re-scheduling caused by timer.
This is a bit complex issue, needs small hack, but you can do this.
1) create task queue, store it as global variable: suspended_tasks = _taskq_create(MQX_TASK_QUEUE_FIFO);
2) create new tasks with higher priority (= more important tasks) than the starter task: _task_create(0, TASK_ID, 0);
3) create some variable to signal that tasks are ready to run on following interrupt (see small hack below): reinit_tasks_on_interrupts = 1;
4) after (3), the starting task should run in infinite loop and not to call any function that can make rescheduling (e.g. _task_wait or _lwsem_wait ), just waiting for interrupt: wait(1);
5) every new started task will do as first step sleep onto taks queue: _taskq_suspend(suspended_tasks);
small hack:
6) open _bsp_timer_isr() int init_bsp.c and make that the signal from (3) will resume all sleeping tasks: if (reinit_tasks_on_interrupts) { _taskq_resume(suspended_tasks); } before _time_notify_kernel();
Hi troll
scheduler time-slice is only a default value for time-slice. Don't bother with that.
You want to have the tasks run the same amount of time. In that case you need to start new task on the new re-scheduling caused by timer.
This is a bit complex issue, needs small hack, but you can do this.
1) create task queue, store it as global variable: suspended_tasks = _taskq_create(MQX_TASK_QUEUE_FIFO);
2) create new tasks with higher priority (= more important tasks) than the starter task: _task_create(0, TASK_ID, 0);
3) create some variable to signal that tasks are ready to run on following interrupt (see small hack below): reinit_tasks_on_interrupts = 1;
4) after (3), the starting task should run in infinite loop and not to call any function that can make rescheduling (e.g. _task_wait or _lwsem_wait ), just waiting for interrupt: wait(1);
5) every new started task will do as first step sleep onto taks queue: _taskq_suspend(suspended_tasks);
small hack:
6) open _bsp_timer_isr() int init_bsp.c and make that the signal from (3) will resume all sleeping tasks: if (reinit_tasks_on_interrupts) { _taskq_resume(suspended_tasks); } before _time_notify_kernel();