Hi, I have a doubt about tasks in fifo and round robind mode.
The MQXUG says that FIFO and Round Robin mode can work together, so if you want to create a task in round robin mode, you need to set MQX_HAS_TIME_SLICE. Well, If I do it, how can I create a task to work in FIFO mode having MQX_HAS_TIME_SLICE setted?
I'm a bit confused...
Thank you
已解决! 转到解答。
FIFO: First task in, First task out... Means that as you insert task to the queue, they are in the order processed (the time a task will run is INFINITE, or the task itself can give up CPU time). Every task is defaultly inserted in FIFO queue.
Round-Robin: The same as FIFO, but the time is NOT INFINITE: the time is restricted by NUMBER OF TICKS dedicated for the task. The task running in Round-Robin has MQX_TIME_SLICE_TASK flag set and also, number of ticks).
Hi, FIFO and Round Robin can work together on one processor, they cannot both set for the one task.
Basically those tasks which have TIME_SLICE flag setted are time sliced with other task on given priority.
The priority based sheduling is still working for all tasks - that means the higher prio task will be executed if needed.
PetrL
Hi PetrL
I know that, but I don't know how I tell to TASK_TEMPLATE that one task has time slice and another one has a FIFO schedule mode independly of priorities. Because when MQX_HAS_TIME_SLICE is setted, the last elements of TESK_TEMPLATE correspond to time slice of the task... then if you put 0 in this element, the scheduler will give a minimum task time when I want that this task work in FIFO mode not in Round Robin. Is this correct doesn't it?
Thanks.
Matt
Partially you are right. The scheduler works like this (steps):
1) Only ready queue with highest priority (queue of ready tasks with highest priorities) is considered to be run (ignore other= lower priority tasks)
2.1) Iif current task has time slice, then:
2.1.1) if current task's time slice has counted down, then reschedule to the next task - scheduling is DONE
2.2) Schedule the current task - scheduling is DONE
If the kernel was not compiled with MQX_HAS_TIME_SLICE, then remove point 2.1 Note that setting time slice 0 for a task having time slice flag set has no meaning...
Hi JuroV.
I understand about how the scheduler handles the ready task. My question is, how do I declare a task to work in FIFO mode having MQX_HAS_TIME_SLICE setted?
Thanks for your anwers
FIFO: First task in, First task out... Means that as you insert task to the queue, they are in the order processed (the time a task will run is INFINITE, or the task itself can give up CPU time). Every task is defaultly inserted in FIFO queue.
Round-Robin: The same as FIFO, but the time is NOT INFINITE: the time is restricted by NUMBER OF TICKS dedicated for the task. The task running in Round-Robin has MQX_TIME_SLICE_TASK flag set and also, number of ticks).
Hi JuroV
I understand your response.
I have a question related with RR
I'm using MQX 3.7
In my main.c have
TASK_TEMPLATE_STRUCT MQX_template_list[] =
{
/* Task number, Entry point, Stack, Pri, String, Auto? */
{MAIN_TASK, Main_task, 2000, 9, "main", MQX_AUTO_START_TASK | MQX_TIME_SLICE_TASK, 0L, 2 },
{SECOND_TASK, Second_task, 2000, 9, "second", MQX_AUTO_START_TASK | MQX_TIME_SLICE_TASK, 0l, 2},
{0, 0, 0, 0, 0, 0, }
};
In mqx.h said:
/*
** Tasks with this attribute will use the time slice
** scheduler within the kernel
*/
#if MQX_HAS_TIME_SLICE
#define MQX_TIME_SLICE_TASK (0x04)
#endif
I checked the file small_ram_config.h
And I saw:
#ifndef MQX_HAS_TIME_SLICE
#define MQX_HAS_TIME_SLICE 0
#endif
I changed the value, for 1
#ifndef MQX_HAS_TIME_SLICE
#define MQX_HAS_TIME_SLICE 1
#endif
But In CodeWarrior when I saw this code
#if MQX_HAS_TIME_SLICE
#define MQX_TIME_SLICE_TASK (0x04)
#endif
it looks like desactivated
I suppose that the flag: MQX_HAS_TIME_SLICE doesn't udated by MQX,
am I correct?
When I execute this program ( that has the 2 task )
void Main_task(uint_32 initial_data)
{
int a;
for(a=0; a< 32000 ; a++)
{
printf("hola\t");
}
void Second_task(uint_32 initial_data)
{
int a;
for(a=0; a< 32000 ; a++)
{
printf("adios\t");
}
}
Execute the program like a FIFO , it doesn't execute like Round Robin
What are the correct modifications in the config files for change to RR scheduling?
best regards
jam
Hi,
I meet the same question with you. Now I have addressed it. The step is:
1) open <mqx_install_dir>/build/<board>/uv4/build_libs.uvmpw
1) add #define MQX_HAS_TIME_SLICE 1 in user_config.h
2) Bebuild the MQX libraries(Please note that: you should Batch build)
3) Rebuild your application.