Pumpkin, Inc.

Pumpkin User Forums

cannot stop a task?

For issues specific to Microchip's PICmicro® MCUs, including compilers (e.g. HI-TECH PICC & PICC-18, Microchip MPLAB®-C18) and IDEs (e.g. Microchip MPLAB®).

cannot stop a task?

Postby kamyip » Mon Feb 27, 2006 10:34 am

I have the following tasks:
TaskBeep() - priority 6
TaskTest() - priority 10

Inside TaskTest I tried to stop TaskBeep() ie

TaskTest(){
for(; {
OSStopTask(TASK_BEEP_P);
OS_Delay(....)
..do something here
OSStartTask(TASK_BEEP_P);
}

I could not stop the TaskBeep() as I wanted.
Where did I go wrong?


Kam

kamyip
 
Posts: 46
Joined: Mon Apr 15, 2002 11:00 pm

Re: cannot stop a task?

Postby aek » Mon Feb 27, 2006 10:53 am

What did OSStopTask() return?

Only tasks in certain states can be stopped ...

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

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

Re: cannot stop a task?

Postby kamyip » Tue Feb 28, 2006 4:18 am

Ok, is it clear now. Thanks for the prompt response.

Kam :-)

kamyip
 
Posts: 46
Joined: Mon Apr 15, 2002 11:00 pm

Re: cannot stop a task?

Postby aek » Tue Feb 28, 2006 8:43 am

From the Reference for OSStopTask():
quote:
OSStopTask() can stop any task that is not already destroyed or waiting an event.
So it sounds like when you call OSStopTask(), TaskBeep() is waiting ...

Why is it hard (from an OS viewpoint) to stop waiting tasks? Well, because there's a lot of cleanup required, and it's somewhat ambiguous as to how that cleanup should be done. Many RTOSes do not allow you to stop or kill/destroy a task if it is (also) waiting an event.

In your case, it might be better to signal the task, and then have it react to the signaling to control the on/off of beeping. For example, you could signal the task with messages that are const chars -- 'B' might mean "start beeping" and 'Q' might mean "be quiet".

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

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

Re: cannot stop a task?

Postby kamyip » Tue Feb 28, 2006 12:57 pm

It returns 0x01 aka OSERR.

The beep task as follow:

code:
void TaskBeep( void ){   

Tris_Beep =0; //init pin to output
Bit_Beep =0; //buzzer drive set low
for (;;) {
OS_WaitBinSem(BINSEM_UPDATE_BEEP_P, OSNO_TIMEOUT, TaskBeep1);
Bit_Beep = 1;
OS_Delay(5, TaskBeep2);
Bit_Beep = 0;
}

}


Question: How do I know under what state that I can stop the task?

[This message has been edited by aek (edited February 28, 2006).]

kamyip
 
Posts: 46
Joined: Mon Apr 15, 2002 11:00 pm


Return to PICmicro MCUs

Who is online

Users browsing this forum: No registered users and 1 guest

cron