Pumpkin, Inc.

Pumpkin User Forums

OSReadEFlag and OSProtect

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

OSReadEFlag and OSProtect

Postby jtemples » Thu Oct 10, 2002 8:09 am

My application is calling OSSetEFlag from both the ISR and main code. (I have OSCALL_OSSIGNALEVENT OSFROM_ANYWHERE in my salvocfg.h).

After adding some new event flags to my code as a result of the recent thread regarding shared event flags and timeouts, a new problem cropped up. One of my event flags, signalled from the ISR, would not reach its task reliably.

One of the things that I tried, and that appears to have fixed the problem, is adding OSProtect/OSUnprotect to all OSClrEFlag calls. I just looked at salvo.h, and see that OSClrEFlag and OSSetEFlag are really calls to the same function, so I think this makes sense. (This isn't clear from the manual; I would have assumed that only OSSetEFlag would require protection.)

One additional thing I did was to add OSProtect/OSUnprotect to OSReadEFlag. This caused my original problem to return. Should protection not be applied to OSReadEflag?

[This message has been edited by jtemples (edited October 10, 2002).]

jtemples
 
Posts: 45
Joined: Tue Jul 16, 2002 11:00 pm

Re: OSReadEFlag and OSProtect

Postby aek » Thu Oct 10, 2002 9:55 am

Hello.

I don't know what target you've got -- I'll assume it's PIC or PIC18 with PICC or PICC-18 ... this stuff only applies to compilers that use a static overlay model for parameters.

quote:
This isn't clear from the manual; I would have assumed that only OSSetEFlag would require protection.
Page 141 of the User Manual helps: it states that "OSCALL_OSSIGNALEVENT manages how interrupts are controlled in event-signaling services (e.g. OSSignalMsg()), OSClrEFlag() and OSSetEFlag()." So they're all in the same boat. OSSetEFlag() and OSClrEFlag() both require protection when OSCALL_OSSIGNALEVENT is set to OSFROM_ANYWHERE because they both take parameters, which means that without first disabling interrupts (OSProtect()) those parameters may be corrupted my simultaneous calls at the ISR level.
quote:
One additional thing I did was to add OSProtect/OSUnprotect to OSReadEFlag. This caused my original problem to return. Should protection not be applied to OSReadEflag?
Did you set OSCALL_OSRETURNEVENT to OSFROM_ANYWHERE? If not (and if you're only calling OSReadEFlag() from mainline code), then wrapping OSReadEFlag() with OSProtect()/OSUnprotect() won't do any harm ...

The fact that applications built with PICC/PICC-18 require this sort of "protection of function parameters from interrupts" means that it's critical that mainline functions be protected wherever they exist in multiple callgraphs. So make absoluetly sure that you aren't missing protection somewhere ...

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

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

cron