Pumpkin, Inc.

Pumpkin User Forums

OS_Delay -- usage

If you can't make Salvo do what you want it to do, post it here.

OS_Delay -- usage

Postby aek » Tue Aug 30, 2005 2:18 am

Hi Monte.

Apart from the missing semicolon after OSSched(), that looks fine.

The behavior you should be seeing is that Task2() is running flat-out, calling LedToggle(1) at essentially the context-switching rate (around 125 instruction cycles or so on a PIC). Every 100 timer ticks (i.e. every 1s), Task1() comes along and calls LedToggle(0).

In a program like this (i.e. by looking at the LED(s?), you won't be able to perceive the fact that Task1() takes priority over Task2() when its delay expires every 1s.

If it's not working as I described, check for unintentional resets, something in LedToggle(), etc. You should be able to run it in the MPLAB SIM (I'm assuming you're running ona PIC) With breakpoints on the two calls to LedToggle and the StopWatch turned on. If all else fails, .zip the project and send it to support here and we'll figure it out.

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

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

Re: OS_Delay -- usage

Postby RumJungle » Tue Aug 30, 2005 9:23 am

Hi,

I'm evaluating Salvo and have a question about OS_Delay.
I have a simple program as listed below. I've also called OSTimer() from a 100Hz timer interrupt.

The delay in Task1 seems to work correctly. However, Task2 is called at the rate of Task1's delay, once a second. Do lower priority tasks get blocked during a higher priority delay? I most likely have something setup wrong.

TIA - Monte

code:
#define OSUSE_LIBRARY               TRUE
#define OSLIBRARY_TYPE OSF
#define OSLIBRARY_CONFIG OSA
#define OSLIBRARY_VARIANT OSA
#define OSEVENTS 1
#define OSEVENT_FLAGS 1
#define OSMESSAGE_QUEUES 1
#define OSTASKS 3

void Task1(void)
{
while(TRUE)
{
LedToggle(0);
OS_Delay(100, TaskA1);
}
}

void Task2(void)
{
while(TRUE)
{
LedToggle(1);
OS_Yield(TaskA2);
}
}

main()
{
OSInit();
OSCreateTask(Task1, OSTCBP(1), 5);
OSCreateTask(Task2, OSTCBP(2), 10);

for(;;)
OSSched()
}


[This message has been edited by aek (edited August 30, 2005).]

RumJungle
 
Posts: 1
Joined: Mon Aug 29, 2005 11:00 pm


Return to Coding

Who is online

Users browsing this forum: Google [Bot] and 2 guests

cron