Pumpkin, Inc.

Pumpkin User Forums

Another event flags + timeout question

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

Another event flags + timeout question

Postby aek » Mon Oct 14, 2002 4:27 am

Hello.

No, it won't. From SB-14:

quote:
but only if the eFlag is set (signaled) with exactly the mask and options with which the task is waiting the eFlag.
The operative word here is exactly.

In the current eflag implementation, any signaling of a particular eFlag wakes all the tasks waiting that eFlag and therefore "cancels their timeouts". IOW, eFlag-waiting tasks timeout only if the eFlag is never signaled (at all) in the timeout period ... mask and pattern don't matter.

I'm sorry about that -- all the more reason why I'm looking forward to improving the eFlag functionality in an upcoming release.

One thing you could do for now is use system ticks to detect if this problem has occurred -- I'd suggest an OSBYTES_OF_TICKS of 4 (32-bit). You could then store the system ticks in a static local variable prior to the OS_WaitEFlag() call. Immediately thereafter, if you detect that OSTimedOut() is FALSE AND yet more than a certain number of ticks (equal to your timeout period) have transpired (watch for rollover -- you'll need to abs(new _ticks-old_ticks)), you can detect that the timeout period has elapsed and the eFlag was not signaled within the period. IOW, you use the fact that eFlag signaling wakes up all waiting tasks, and so in the place(s) where tasks are waiting with timeouts, you do a little bit of additional processing to see if it was a "real" timeout (OSTimedOut() == TRUE), a "missed" timeout (OSTimedOut() == FALSE AND too many ticks since the OS_WaitEFlag()), or not a timeout at all (OSTimedOut() == FALSE AND too few ticks since the OS_WaitEFlag()).

I think this is a cure-all, because it solves the problem if you have any signaling of that particular eFlag going on ... and if (and only if) you have no signaling, then the timeout will work "as usual".

Your example looks at single bits -- if you're only waiting single-bit eFlags with timeouts, then use a binSem for each one instead -- binSem timeouts work perfectly.

Regards,

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

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

Re: Another event flags + timeout question

Postby jtemples » Mon Oct 14, 2002 11:43 am

Let's say I have a task that looks like this:

code:

for (; ;) {
OS_WaitEFlag(FLAG_A, 0x01, OSANY_BITS, OSNO_TIMEOUT, ...);

/* process... */

OS_WaitEFlag(FLAG_A, 0x02, OSANY_BITS, 10, ...);

/* process ... */
}


If this task is signaled with 0x01 while in the second WaitEFlag, will the timeout work correctly?

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

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


Return to Coding

Who is online

Users browsing this forum: No registered users and 3 guests

cron