Pumpkin, Inc.

Pumpkin User Forums

New options to EFLAG

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

New options to EFLAG

Postby luben » Wed Jun 13, 2001 9:18 am

Hello,

What I can propose to Eflags is to add some additional options, that could be very useful in some cases.

OSEMPTY_BITS – if this option activated the OS_WaitEFlag() will return the control to the task is all of the bits in the mask have corresponding zero’s in the eflag. Such option is useful when you have to watch if one process is into some boundary, or to activate process if no one bits of the flag exists.
Example: If you have door closing system you can watch is the door opened (1 bit of eflag), if somebody in the room (1 bit), if button to open the door pressed (1bit). If no one of this condition exists – close the door.
Of course this could be made using the existing function, but the way is not elegant and maybe will consume one additional Eflag

OSNOTEXACT_BITS – it’s the opposite of OSEXACT_BITS – the mask is not equal to EFLAG. It’s useful if you watch process to be exactly in some state, or you can find the changes of the state
Example

code:

OS_WaitEFlag(E_FLAG,mask,OSNOTEXACTLY_BITS,OSNO_TIMEOUT,_Label);
mask = E_FLAG_value;
…….

in this example you can activate the process (task) if there is some change in the eflag – you have to agree that this is very useful option and could be implement on many places. For example is there is change of the status of EFLAG you can send some messages to display. Maybe this could be named – OSCHANGED_BITS.

Regards
Luben


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

Re: New options to EFLAG

Postby aek » Wed Jun 13, 2001 10:48 am

Hmmm ... these are interesting options. We will consider them for future releases.

Thanks for the suggestion!

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

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

Re: New options to EFLAG

Postby luben » Thu Jun 14, 2001 12:56 am

Hello,

I think that it's a time for you to change your mind about the meaning of eflags :-)

My wife is a piano player, so I can bring you one example from the music. Music is both music and the pauses between music. I mean pauses are part of the music.

How to apply this to eflags. Not only eflag set to 1 is the information, but the absence of 1 is information too. Both 0 and 1 have equal importance. Well, you set flags to 1 and sounds like 1 is the most important part of the flags. In fact they both 1 and 0 have the same weight.

So, I can continue thinking in this direction - you should add OSALLZEROES_BITS, OSALLNOTZEROS_BITS options to complete this idea.
Sometimes is good to check if some flags are zero, and if they are zero to take action. Imagine you have a level measure of the petrol tank - full/empty. And if filled - the flag is set to 1. So, if it becomes 0 will be good if one task can start signalling message to display or LEDs that tank is empty. This is what came to my mind in first time.

In short - eflags have different meaning then BinSem. 0 and 1 have the same weight, so the approach is different. Always remember that pauses in music are so important like the noice...

Regards
Luben

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

Re: New options to EFLAG

Postby luben » Thu Jun 14, 2001 7:38 am

Hello,

I think that if the fragment that makes the logical calculation is what you published in the forum, it's very easy to implement the new options (like piece of cake, as they say):

OSALLZERO_BITS - event appears if all corresponding bits in the flag have zeroes. Example - lock the door of the system if door not open and nobody is in the room.

OSANYZERO_BITS - event appears if even one of the corresponding bits in the flag is zero. Example - light emergency light if no fuel or no voltage or no water in the cooling system.. etc.

OSNOTEXACT_BITS - event appears if the mask is not equal to the flag (useful when you have to watch the change of the flag and take some action according to this)


code:

switch ( options )
{ case OSANY_BITS:
if ( eFlag & mask )
u.avail++;
break;

case OSEXACT_BITS:
if ( !(eFlag ^ mask) )
u.avail++;
break;

case OSALL_BITS:
if ( !((eFlag &= mask) ^ mask) )
u.avail++;
break;

case OSALLZERO_BITS:
if ( !(((~eFlag) & mask) ^ mask) )
u.avail++;
break;

case OSANYZERO_BITS:
if ( (~eFlag) & mask) )
u.avail++;
break;

case OSNOTEXACT_BITS:
if ( eFlag ^ mask) )
u.avail++;
break;

default:
break;
}


Am I correct?

Somewhere you should declare the values of these option keys with #default----.

Of course, this functionality could be made with existing SALVO option keys, but in some of the cases you need to use 2 Eflags (2 bytes or words) and to signal both of them simultaneously with invert values...... not good, huh?

What you can see is that the new option keys are just "mirror image" or "anti" of the existing option keys (as you know in the Universe exists antimatter too). The sense of this is - zeroes in eFlags are with the same importance like ones. So for them should be made the same amount of option keys.

By the way you can define them like bits in one bite, not like sequential values. This could bring you advantage to use NOT function of all of them with simple option key like:

code:

#define OS_NOT 0x80 // if set in mask, function will be inverted
#define OSALL_BITS 1
#define OSANY_BITS 2
#define OSEXACT_BITS 4
#define OSALLZERO_BITS 8
#define OSANYZERO_BITS 0x10
#define OSNOTEXACT_BITS 0x20

//before the "case" statement you should check for OS_NOT option

if (mask & 0x80) // mask is local variable of the function
// equal to the mask of OS_WaitEFlag
{
flag_invert = 1; // will invert the final
mask &= (0x80); //clear bit
}
result
else
flag_invert = 0;

switch ( options )
{ case OSANY_BITS:
if ( eFlag & mask )
flag_event_appeared = 1; // sets flag for event
break;

case OSEXACT_BITS:
if ( !(eFlag ^ mask) )
flag_event_appeared = 1; // sets flag for event
break;

case OSALL_BITS:
if ( !((eFlag &= mask) ^ mask) )
flag_event_appeared = 1; // sets flag for event
break;

case OSALLZERO_BITS:
if ( !(((~eFlag) & mask) ^ mask) )
flag_event_appeared = 1; // sets flag for event
break;

case OSANYZERO_BITS:
if ( (~eFlag) & mask) )
flag_event_appeared = 1; // sets flag for event
break;

case OSNOTEXACT_BITS:
if ( eFlag ^ mask) )
flag_event_appeared = 1; // sets flag for event
break;

default:
break;
}

if(flag_event_appeared ^ flag_invert)
u.avail++;
// calculates the event, taking in mind the value of flag_invert


In the source you should wait the event with inversion like that:

OS_WiatEFlag(E_FLAG,mask,OS_NOT+OSANY_BITS.....);

What you think about this?

Take this topic like saying good words for the zeroes in the EFLAGS. In my oppinion they were discriminated... you know, all we are alergic if somewhere the rights of somebody are violated

Luben


[This message has been edited by luben (edited June 14, 2001).]

[This message has been edited by luben (edited June 14, 2001).]

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


Return to Coding

Who is online

Users browsing this forum: No registered users and 2 guests

cron