Pumpkin, Inc.

Pumpkin User Forums

about"_OSLabel"

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

about"_OSLabel"

Postby aek » Sat Jul 10, 2004 1:54 am

In some Salvo distributions, the label is required because that's how the context switcher tracks where execution will resume after a context switch. In those distributions (e.g. Salvo for PICmicro MCUs, when using HI-TECH PICC or PICC-18 compilers) unique labels are required.

Some other distributions (e.g. the Salvo for TI's MSP430 ones) do not use the label, as the context-switcher works in a different manner.

However, to maintain cross-platform compatibility, the OS_WaitXyz() services always require that you include a label in the label field. If you always use unique labels, and you use _OSLabel(), then you're guaranteed to be able to port your Salvo code across all of the supported distributions without any modifications, e.g. from PIC to MSP430 to 8051.

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

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

Re: about"_OSLabel"

Postby lyons » Sat Jul 10, 2004 4:30 am

I have a simple question:In faction "OS_WaitMsg(ALARM,&msgP,task_alarm_on1)"
task_alarm_on1 is a label,defined by _OSLabel.I do not understand what does "task_alarm_on1" do?Can I define it any ASCII?
lyons
 
Posts: 2
Joined: Fri Jul 09, 2004 11:00 pm
Location: ningbo zhejiang china

Re: about"_OSLabel"

Postby lyons » Mon Jul 12, 2004 4:24 am

How can I define the label? Can I define it with any ASCIIs?
lyons
 
Posts: 2
Joined: Fri Jul 09, 2004 11:00 pm
Location: ningbo zhejiang china

Re: about"_OSLabel"

Postby aek » Mon Jul 12, 2004 7:19 am

Same rules as a label in C.

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

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

Re: about"_OSLabel"

Postby tonykaravidas » Wed Aug 25, 2004 12:43 am

I was searching this forum for something related to _OSLabel and this was the closest I found.
Using tutorial 2 as an example, my question is in regards to the use of _OSLabel.

Why is there the '1' in the name when declared but not used in the function?

_OSLabel(TaskA1)

void TaskA(void)
{
...
}


What would I do if my function was named like this:

void Task2(void)
{
...
}

Would I have to do this:
_OSLabel(Task21) ????

Why isn't it just like this:

_OSLabel(TaskA)

void TaskA(void)
{
...
}

tonykaravidas
 
Posts: 3
Joined: Tue Aug 24, 2004 11:00 pm
Location: Lafayette, CA, USA

Re: about"_OSLabel"

Postby tonykaravidas » Wed Aug 25, 2004 12:45 am

BTW, I read the Tip on page 66 of the manual, but it doesn't make sense to me.
tonykaravidas
 
Posts: 3
Joined: Tue Aug 24, 2004 11:00 pm
Location: Lafayette, CA, USA

Re: about"_OSLabel"

Postby aek » Wed Aug 25, 2004 1:14 am

Hi Tony.

Some Salvo ports (notably the ones for PICC and PICC-18) require unique names for the label field in each OS_Xyz context switch. _OSLabel() satisfies the compiler's requirement that these labels be externally visible at link time.

The argments passed to _OSLabel() just have to match the label field in the OS_Xyz() context switches in your application. Their names are arbitary -- you could just call them label1 through labelN, if you wanted. In our examples, we try to use a label name that takes its name from the task wherein it resides.

To top it all off, many ports (e.g. all of the Salvo for MSP430 and AVR ports) do not require _OSLabel(), because their context switching macros simply disregard the label field. But a label is required in every Salvo context switch, like OS_WaitBinSem(binSem, label).

Using _OSLabel() is recommended, even if not strictly required, because it will guarantee the portability of Salvo code from one target+compiler to the next.

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

[This message has been edited by aek (edited August 25, 2004).]

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

Re: about"_OSLabel"

Postby aek » Wed Aug 25, 2004 1:30 am

Put another way ... the labels in _OSLabel() do not have a one-to-one correspondence with tasks -- they correspond one-to-one to context switches, which can only occur in tasks.

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

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

Re: about"_OSLabel"

Postby tonykaravidas » Wed Aug 25, 2004 3:03 am

I think I understand now.
In the code below, the two lines marked 2 and 3 cannot have the same name so when TaskA yields back to the RTOS (in line 3), it has to use something other than the name used in line 2. That's why you use TaskA1. (or TaskAbyebye or what ever else as long as it's not the same as line 2. So lines 1 and 3 have to match. Tell me if I've missed anything now.

code:
_OSLabel(TaskA1)      <-----1-

void TaskA( void ) <-----2-
{
for (;;)
OS_Yield(TaskA1); <-----3-
}


[This message has been edited by aek (edited August 25, 2004).]

tonykaravidas
 
Posts: 3
Joined: Tue Aug 24, 2004 11:00 pm
Location: Lafayette, CA, USA

Re: about"_OSLabel"

Postby aek » Wed Aug 25, 2004 3:51 am

Correct.

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

-------
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 2 guests

cron