Pumpkin, Inc.

Pumpkin User Forums

OSWaitEvent and OSEXACT_BITS

If you think you've found a bug or other mistake in your Salvo distribution, post it here.

OSWaitEvent and OSEXACT_BITS

Postby tyski » Thu Dec 22, 2005 10:38 am

In the OSWaitEvent function, the insertion of tasks into the signaled queue is dependent on event flags being set - its wrapped in a

code:

if ( options & OSSET_EFLAG )
{
// signal waiting tasks
}

If you have a task that is waiting an event flag with OSEXACT_BITS, then it can technically be signaled to run by clearing bits in the event flag.

1. event flag is currently 0x07
2. task waits with mask 0x06 and OSEXACT_BITS
3. another task clears bit in event flag so that its now 0x06
4. since bits were cleared, no task was signaled

The Salvo documentation states that event flag bits are active high. The OSSignalEFlag function is written with this in mind (i.e only signaling if bits are set). However, the presence of the OSEXACT_BITS option indicates that the bits are more like "states" rather than one-shot events. This is because OSEXACT_BITS requires that some events may need to be zero (active low) before continuing.

- Tyrel

------------------
Tyrel Newton
Electrical Engineer

Tethers Unlimited, Inc.
11807 North Creek Parkway South, Suite B-102
Bothell, WA 98011-8804, USA
425-486-0100 x836 425-482-9670 FAX
newton@tethers.com
http://www.tethers.com/

Tyrel Newton
Electrical Engineer

Tethers Unlimited, Inc.
11807 North Creek Parkway South, Suite B-102
Bothell, WA 98011-8804, USA
425-486-0100 x836 425-482-9670 FAX
newton@tethers.com
http://www.tethers.com/

tyski
 
Posts: 17
Joined: Thu Aug 18, 2005 11:00 pm
Location: Bothell, WA, USA

Re: OSWaitEvent and OSEXACT_BITS

Postby aek » Thu Dec 22, 2005 11:34 am

Hi Tyrel.

Yep, you are correct. The "optimization" to only allow signaling to proceed if the signaling involves setting the bits (and not if it involves clearing the bits) arises from the fact that in the current eFlag system, bits are active high, and you don't want to be signaling tasks when you're clearing the bits (as this results in unnecessarily running each task only to discover that it doesn't match the pattern+mask).

So it basically makes OSEXACT_BITS useless ...

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

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

Re: OSWaitEvent and OSEXACT_BITS

Postby aek » Thu Dec 22, 2005 11:42 am

If you want to play with the source code, you can remove the
code:
if ( options & OSSET_EFLAG )

filters and (at first glance, I haven't tried it), OSEXACT_BITS should now work in your example. The downside is that if you were to watch the various tasks that wait on eFlags in real-time, you'd see them checking to see if their wait condition has been satisfied whenever OSSetEFLag() or OSClrEFlag() is called ... IOW, normally they wake up and check only when eFLags are set -- now they'll wake up whenever they're set or cleared.

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

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

Re: OSWaitEvent and OSEXACT_BITS

Postby tyski » Thu Dec 22, 2005 11:47 am

I'm not currently using the OSEXACT_BITS methodology. However, I noticed it when looking through the source code and I thought I should point it out for the masses.

- Tyrel

Tyrel Newton
Electrical Engineer

Tethers Unlimited, Inc.
11807 North Creek Parkway South, Suite B-102
Bothell, WA 98011-8804, USA
425-486-0100 x836 425-482-9670 FAX
newton@tethers.com
http://www.tethers.com/

tyski
 
Posts: 17
Joined: Thu Aug 18, 2005 11:00 pm
Location: Bothell, WA, USA


Return to Bug Reports

Who is online

Users browsing this forum: No registered users and 2 guests

cron