Page 1 of 1

Task Priority

PostPosted: Sun Jun 22, 2008 8:15 am
by igncio250
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();
}



Re: Task Priority

PostPosted: Mon Jun 23, 2008 7:13 am
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.

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


Re: Task Priority

PostPosted: Thu Jun 26, 2008 8:46 am
by igncio250
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.



Re: Task Priority

PostPosted: Thu Jun 26, 2008 8:54 am
by igncio250
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.



Re: Task Priority

PostPosted: Fri Jun 27, 2008 9:42 am
by aek
You can pass a pointer to a structure ...

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