Pumpkin, Inc.

Pumpkin User Forums

Final idea for OS_WaitKey()

Have an idea on how to make Salvo better? Post it here!

Re: Final idea for OS_WaitKey()

Postby luben » Sun Feb 04, 2001 10:22 am

Hello,

Everything looks very neat and good. I think that it's OK and don't need at this moment some changes.

What I can imagine more is to have options in salvocfg that will switch off/on this function, or will simplify the function. Simplify - I mean, to be able to chose what size of the OSWaitEventFlag you can add to your project. OSWaitEventFlag has several options and each one consumes some memory. Usually I never will use all of them - so the "perfect" SALVO should understand (trogth the salvocfg.h) which options to exclude from the project. This will reduce the final size of the code. I guess you have even now some options like OSEventFlags that will bring information to SALVO how many Flags will user use (but not menshened in this message).

It's good that you have 8, 16,24 and 32 bit flags - it's more then enough. Usually the need is for not more then 8 bits, but who knows. If I have opportunity to use large flags defenetely I'll change my style of programming to include such power.

With two words everything with Flags looks OK. Well, it's your job to ensure that all they work correctly :-)

By the way, I can't express my big pleasure that I had the chance to find the idea of SALVO - it changed totally my style of programming and aproach to the C.

Regards
Luben

luben
 
Posts: 324
Joined: Sun Nov 19, 2000 12:00 am
Location: Sofia, Bulgaria

Re: Final idea for OS_WaitKey()

Postby aek » Sun Feb 04, 2001 12:18 pm

Here's how OSWaitKey() is shaping up for the v2.2 release. We would like comments before we commit it to the release.

Salvo v2.2 will include support for event flags, in the conventional sense. This means that one or more tasks can wait on an event flag disjunctively (mask OR flags) or conjunctively (mask AND flags). When an event flag is set, all of the tasks waiting on the event flag evaluate the new flag, and where a pattern match occurs, those task(s) are made eligible to run. Event flag bits must be individually reset by the programmer. This represents an "active high" methodology -- we may actually support both "active high" and "active low" methodologies.

The command set for event flags is:

code:
OSCreateEventFlag(ecbP, mask);
OSSetEventFlag(ecbP, mask);
OSClrEventFlag(ecbP, mask);
OS_WaitEventFlag(ecbP, mask, options, optFP, timeout, label);

Note: v2.2 has a major change in that pointers are now used instead of IDs -- that's why it's ecbP up there and not eID.

OS_WaitEventFlag() is "extendable". By that we mean that if optFP is 0, the pattern match is based on a logical or arithmetic operation (specified by options) between the event flag and the mask. E.g.

code:
OS_WaitEventFlags(ecbP, 0xF3, OSANY_BITS, 0, timeout, label);

If optFP is non-zero, options is disregarded and instead a user-supplied function is called (via pointer) to determine if the event flag matches the conditions and masks desired. E.g.

code:
OS_WaitEventFlags(ecbP, 0xF3, 0, MyBinKeyTestFn, timeout, label);

This is how binKeys will be implemented -- as a sort of superset of functions for event flags. You supply the optional function, and OS_WaitEventFlags() will call it (with the ecbP and mask as its parameters). Your function must return TRUE or FALSE, and this will then control whether the waiting task is blocked or is allowed to proceed.

This has the huge advantage that as a user, you can supply a complex or simple function to effectively replace the built-in flag vs. mask comparison function in OS_WaitEventFlag(). You can even do it on a case-by-case basis! This keeps the Salvo code size to a minimum, but does not restrict the complexity of your own binKey functionality.

Also, 8-, 16- and 32-bit event flags will be supported.

Lastly, Salvo's priority scheme is preserved, i.e. if two tasks with unequal priorities are waiting the same event flags, then the lower priority will be run if there's a pattern match and it becomes the highest-priority eligible task. Otherwise the task will remain eligible and will run (eventually) when it's the highest-priority task.

Comments? Questions?

[This message has been edited by aek (edited February 04, 2001).]

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

Re: Final idea for OS_WaitKey()

Postby luben » Mon Feb 05, 2001 1:31 am

Hello,

1. I think that in your examples you skipped (if we want to be more exactly):

OSCreateEventFlag(ecbP, initial_value);
(not mask, but initial value of the flags - they have different meaning)

and even more exactly:

OSCreateEventFlag(ecbP, (OTTypeFlag)(initial_value));

2. Do you have in the options "exactly" - when the wait event waits for exactly value of the flag? It has some hidden problems - if you wish to compare exactly the mask and the flags you should add one additional mask to show which bits to compare and which no.
I think that in the current version the flag idea is OK, but if you want to add the exactly option it should look like

OS_WaitEventFlag(ecbP,mask,compare_value,options,optFP,timeout,label)

with the mask you just point which bits will be includet in the comparision and which not.

Regards
Luben


[This message has been edited by luben (edited February 05, 2001).]

[This message has been edited by luben (edited February 05, 2001).]

luben
 
Posts: 324
Joined: Sun Nov 19, 2000 12:00 am
Location: Sofia, Bulgaria

Re: Final idea for OS_WaitKey()

Postby aek » Wed Feb 07, 2001 9:47 am

1) Re:

quote:
and even more exactly:

OSCreateEventFlag(ecbP, (OTTypeFlag)(initial_value));


That's fine -- I meant initial value, we can call it that. Values and masks are both of type OStypeEventFlag.

2) I don't think we will have an EXACTLY in the default event flags functionality, as that is more a Luben/bitKey thing and less of an established event flags concept.

What I plan to do is supply Salvo v2.2 with a bitKey function that implements things like EQUAL, etc. You'll be able to use it as-is, or copy it to another function of your own and modify it to suit your needs. If you like, this example (as distributed in Salvo) can include all of the functionality you have suggested. This will be the "default bitKey event flags extender function."

Rather than wade through this long discussion, it would be helpful to me if you could summarize all the "operators" you would like for bitKeys. I could then work quickly to implement them in this bitKey-specific function.

3) At this point I would prefer not to have a configurable OS_WaitEventFlag(). Instead, the user can configure and use their own "event flags extender function" if they so desire. The default OS_WaitEventFlag() function's comparison core (supporting AND and OR) is very small ...

4) At this point 8-, 16- and 32-bit event flags are supported, in a separate event flags control block (efcb), a lot like the message queue control blocks (mqcbs). This keeps Salvo's memory requirements to a minimum.

[This message has been edited by aek (edited February 07, 2001).]

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

Previous

Return to Feature Requests

Who is online

Users browsing this forum: No registered users and 1 guest

cron