Page 1 of 1

Task-switching and priorities

PostPosted: Thu Jun 11, 2009 3:25 am
by larsbn
Dear Sir,
I have a simple, general OS-question for you. I'm not so used to OS and I'm just learning to use Salvo for my controllers. Anyway, here is my question:

Suppose I define three tasks, all with different priorities. Let's say task1 has priority 5, task2 has priority 6 and task3 has priority 7. In my program, the tasks will never be in a waiting och delayed state. They are always eligible. The task with highest priority will run first and after that, task2 will run. What happens when task 2 is done? Will it run task1 again?

If I understand the task-switching right, in the above situation, task3 will NEVER run. Correct?

(I'm aware of that I can get "round-robbin" execution by assigning them the same priority, I'm just curious about what happens in the situation above.)

Sincerly,
LarsB


Re: Task-switching and priorities

PostPosted: Thu Jun 11, 2009 5:37 am
by aek
In Salvo, the lower the priority number, the higher the priority. Priority 0 is the highest priority.

Salvo's scheduler follows a very simple rule -- "run the highest-priority eligible task".

In your example, task1 is the only task that will ever run. If you delay, stop or cause task1 to wait, then task 2 will run. Etc.

If you give them all the same priority and keep them all eligible (via OS_Yield() context switches only), they will round-robin. From start, tasks at the same priority level will run in the order that they were created.

------------------