Pumpkin, Inc.

Pumpkin User Forums

Task Priority

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

Task Priority

Postby igncio250 » Sun Jun 22, 2008 8:15 am

Hello,

I am using Salvo Lite, If I have three tasks with priorities Task1_Priority = 15,
Task2_Priority = 15, Task3_Priority = 14. How will the scheduler handle the execution of these tasks? I have notice that Task3 runs but the other two never begin execution.

#include <p18f4550.h>
#include <stdlib.h>
#include <stdio.h>
#include <usart.h>
#include <salvo.h>
//////////////////////////////////////

//#pragma config FOSC = HS
_OSLabel(Task1a)
_OSLabel(Task2a)
_OSLabel(Task3a)

void TaskA( void )
{

while (1) {
printf("TasA
");
OS_Yield();
}


}
////////////////////////////////////
////////////////////////////////
void TaskB( void )
{

while (1) {
printf("TasB
");
OS_Yield();
}

}
/////////////////////////////////////
/////////////////////////////////////
void TaskC( void )
{

while (1) {

printf("TasC
");
OS_Yield();

}

}

/////////////////////////////////////////
/////////////////////////////////////////
int main( void )
{


OpenUSART (USART_TX_INT_OFF &
USART_RX_INT_OFF &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_LOW,31);

OSInit();

OSCreateTask(TaskA, OSTCBP(1),15);
OSCreateTask(TaskB, OSTCBP(2),15);
OSCreateTask(TaskC, OSTCBP(3),14);
while (1) {
OSSched();
}


igncio250
 
Posts: 3
Joined: Sat Jun 21, 2008 11:00 pm

Re: Task Priority

Postby aek » Mon Jun 23, 2008 7:13 am

That's the correct behavior -- TaskC() with priority 14 is always eligible, and so it always runs. The other two tasks never run because while they are always eligible, TaskC() is also always eligible AND it has higher priority.

To let TaskA() and TaskB() run, you could i) use OS_Delay() inside TaskC() instead of OS_Yield() -- this will leave long stretches of time during which TaskC() is delayed (not eligible), which permits TaskA() and TaskB() to run, or ii) run them all at the same priority.

This illustrates how Salvo is priority-based (and not time-sliced). Whichever task(s) is(eligible) AND has the highest priority, will run.

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

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

Re: Task Priority

Postby igncio250 » Thu Jun 26, 2008 8:46 am

quote:
Originally posted by aek:
That's the correct behavior -- TaskC() with priority 14 is always eligible, and so it always runs. The other two tasks never run because while they are always eligible, TaskC() is also always eligible AND it has higher priority.

To let TaskA() and TaskB() run, you could i) use OS_Delay() inside TaskC() instead of OS_Yield() -- this will leave long stretches of time during which TaskC() is delayed (not eligible), which permits TaskA() and TaskB() to run, or ii) run them all at the same priority.

This illustrates how Salvo is priority-based (and not time-sliced). Whichever task(s) is(eligible) AND has the highest priority, will run.


igncio250
 
Posts: 3
Joined: Sat Jun 21, 2008 11:00 pm

Re: Task Priority

Postby igncio250 » Thu Jun 26, 2008 8:54 am

Hello,

Can I pass a structure to OSSignalMsg for the message parameter?

quote:
Originally posted by aek:
That's the correct behavior -- TaskC() with priority 14 is always eligible, and so it always runs. The other two tasks never run because while they are always eligible, TaskC() is also always eligible AND it has higher priority.

To let TaskA() and TaskB() run, you could i) use OS_Delay() inside TaskC() instead of OS_Yield() -- this will leave long stretches of time during which TaskC() is delayed (not eligible), which permits TaskA() and TaskB() to run, or ii) run them all at the same priority.

This illustrates how Salvo is priority-based (and not time-sliced). Whichever task(s) is(eligible) AND has the highest priority, will run.


igncio250
 
Posts: 3
Joined: Sat Jun 21, 2008 11:00 pm

Re: Task Priority

Postby aek » Fri Jun 27, 2008 9:42 am

You can pass a pointer to a structure ...

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

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


Return to General

Who is online

Users browsing this forum: No registered users and 2 guests

cron