Pumpkin, Inc.

Pumpkin User Forums

Multiple instances of tasks

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

Multiple instances of tasks

Postby calluml » Fri Mar 05, 2004 7:48 am

I'm new to Salvo and have the following requirement:

- control multiple LEDs independently (one task type)
- control multiple motors independently (another task type)

My question is: is it possible to create multiple instances of the above tasks, but pass each instance the details of which port or bits to work with?

As Salvo dictates static local variables for tasks, how could this be achieved. Or can it?

thanks,

callum

calluml
 
Posts: 10
Joined: Fri Mar 05, 2004 12:00 am
Location: united kingdom

Re: Multiple instances of tasks

Postby aek » Fri Mar 05, 2004 8:09 am

Hello.

In Salvo Pro, you'd use tcb extensions and explcitly initialize the extension(s) in each task (right after creating it, but before launching the scheduler) to be instance-specific, e.g. a pointer to a struct that contains the port-specific setttings for that particular task.

You can't pass parameters to a task, so tcb extensions are the way you get around that.

Without tcb extensions enabled, you need to deduce at runtime which instance of the task you're in, and then act accordingly (maybe return a pointer to a struct based on the current taskID). Use OStID(OScTcbP) to return the taskID (an integer) of the current task. The disadvantage of this approach is that you must re-deduce the taskID each time you (re-)enter the task.

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

[This message has been edited by aek (edited March 05, 2004).]

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

Re: Multiple instances of tasks

Postby calluml » Fri Mar 05, 2004 8:34 am

Many thanks for the very prompt reply.

I had read a little about TCB extentions and wondered if they would do the job. Excellent news.

calluml
 
Posts: 10
Joined: Fri Mar 05, 2004 12:00 am
Location: united kingdom

Re: Multiple instances of tasks

Postby aek » Fri Mar 05, 2004 8:50 am

Just remember that to use Salvo's tcb extensions, you must either do a Salvo Pro source-code build, or build (and use) a custom library that has one or more extensions enabled.

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

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

Re: Multiple instances of tasks

Postby aek » Sun Mar 07, 2004 2:59 am

Yes.

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

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

Re: Multiple instances of tasks

Postby calluml » Sun Mar 07, 2004 3:56 am

Thanks,

But just be clear, does this mean I need the Pro version to use extensions?

calluml
 
Posts: 10
Joined: Fri Mar 05, 2004 12:00 am
Location: united kingdom

Re: Multiple instances of tasks

Postby calluml » Sun Mar 07, 2004 3:56 am

Many thanks again for the speedy response.

This has to be one of the most responsive forums I've ever seen.

calluml
 
Posts: 10
Joined: Fri Mar 05, 2004 12:00 am
Location: united kingdom

Re: Multiple instances of tasks

Postby aek » Sun Mar 07, 2004 3:59 am

Workaholics 'R Us

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

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


Return to Coding

Who is online

Users browsing this forum: No registered users and 3 guests

cron