Pumpkin, Inc.

Pumpkin User Forums

Task-switching and priorities

If you have a general question or comment regarding Salvo, post it here.

Task-switching and priorities

Postby larsbn » Thu Jun 11, 2009 3:25 am

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.)


Posts: 18
Joined: Mon Mar 10, 2008 11:00 pm
Location: Gothenburg, Sweden

Re: Task-switching and priorities

Postby aek » Thu Jun 11, 2009 5:37 am

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.


Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest