Pumpkin, Inc.

Pumpkin User Forums

meaning of OSEXACT_BITS

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

meaning of OSEXACT_BITS

Postby luben » Wed Jun 13, 2001 7:02 am

Hello,

It's about the new EFLAGS.

I'm reading and reading again the manual, but there is something unclear in OSEXACT_BITS.

I can't find the diference in the way of action of OSEXACTLY_BITS and OSALL_BITS, ecsept that they were explained in different manner, but the logical function should be absolutely the same.

It could be: or the functions are just equal, or the manual is wrong.

Example: Let's we have an 8 bit event flag E_FLAG set to 0b01010011. and let's our mask = 0b00010011.

If I wait the event with OS_WaitEFlag(E_FLAG,mask,OSALL_BITS,OSNO_TIMEOUT,_Label). It return the control to the task, correct?

The same will be if the option is set to OSEXACT_BITS. Where is the difference?

For sure you have to make additional explanation about the option, from the manual it becomes that they are equal.

In fact, the exactly option needs one additional field for "value". The result should be

if ((~(E_FLAG ^ value))& mask == 0 )
{.....}

This expression covers the real case of waiting exactly some bits of the EFlag. Many years ago I used to make logical analizers (device that records uP data if some event occures - like exactly address, some data, some bits of data, etc. ) and from there I got the ideas for EFlags. My advice is, if you can find somewhere around you a logical analizer - look at it how they set the events - usually like 0X11XX10b - meaning that bits 2,3,6 - don't care, bits 0,7 should be 0, bits 1,4,5 - should be 1.
But this "X" means that there are not 2 states 0 and 1, but one additional state - "don't care", and of course - one additional bit information, that needs one additional field in the function.
So, in my oppinion the exactly option needs one additional field "value" or it's absolutely the same like OSALL_BITS, at least it brings equal resualts.

Anyway, even without this option (OSEXACT_BITS) EFlags are powerful enough :-).

Regards
Luben

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

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

Re: meaning of OSEXACT_BITS

Postby luben » Wed Jun 13, 2001 7:32 am

Hello,

I think that in your manual you should change the sentance of EFlags for OSEXACT_BITS - "the high bits in event flag must match the high bits in the mask parameter...." with
"event flag must be equal to the mask". Well, if my english is not right you can correct me, but I think that this is what you meant.

So in short the functuions of EFlags should be:

OSANY_BITS ---- (EFlag $ mask)== 0

OSALL_BITS ---- ((EFlag & mask) ^mask) != 0

OSEXACT_BITS -- (EFlag ^ mask) == 0

CORRECT?

Regards
Luben

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

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

Re: meaning of OSEXACT_BITS

Postby aek » Wed Jun 13, 2001 7:39 am

I'll explain the difference. Also, remember that Salvo's event flag bits are all active high, i.e. "things happen" only when bits in an event flag are set to 1.

Let's say an event flag (eFlag) has been set to 00110001b. When calling OSWaitEFlag(), the task(s) will continue in these situations:

OSANY_BITS XXXXXXX1b
OSANY_BITS XXX1XXXXb
OSANY_BITS XX1XXXXXb

OSALL_BITS 00000001b
OSALL_BITS 00010000b
OSALL_BITS 00100000b
OSALL_BITS 00010001b
OSALL_BITS 00100001b
OSALL_BITS 00110000b
OSALL_BITS 00110001b

OSEXACT_BITS 00110001b only!

In other words, the operator refers to which bits in the mask are also set in the eFlag. In the case of OSALL_BITS, it means "task will continue if all the '1' bits in the mask are also set in the eFlag." In the case of OSANY_BITS, it means "task will continue only if the mask matches the eFlag exactly." Below is the actual source code:

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;

default:
break;
}


In your example, there is no difference, in both cases the task will continue.

The reason why OSEXACT_BITS and OSALL_BITS exist is because you might have two different tasks waiting on different groups of bits in an event flag. In that case, you may want one task to continue only when there is an exact match, but in another case, you may want the task to continue when there is a "minimum set" of matches.

I think you'll find that once you have multiple tasks waiting eFlags, and you've used a single eFlag to do 8 bits instead of two separate ones (e.g. 2 bits in one, 6 bits in the other), then you'll find that these options are useful / necessary.

Event flags are a little different from other Salvo events, in that (as before) multiple tasks can wait a single eFlag, but all tasks waiting an eFlag can become eligible when the eFlag is signaled. Therefore you can "pack" event flag bits into a single eFlag and thereby conserve RAM memory.

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

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

Re: meaning of OSEXACT_BITS

Postby aek » Wed Jun 13, 2001 7:44 am

yes, you are correct, and I'll change the manual to reflect this -- the manual is wrong.

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

[This message has been edited by aek (edited June 13, 2001).]

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

Re: meaning of OSEXACT_BITS

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

code:

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


I think that here is a mistake!

**** eFlag &= mask ****** after this operation the eFlag will be changed!!! It's my own bitter experience. the sign "=" will set the value into eFlag

Regards
Luben

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

Re: meaning of OSEXACT_BITS

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

Don't worry -- that's just a local (auto) variable inside the function -- it does not change the actual eFlag.

The switch statement was preceded by this (I left it out for simplicity):

code:
eFlag = ecbP->event.efcbP->eFlag;

[This message has been edited by aek (edited June 13, 2001).]

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

Re: meaning of OSEXACT_BITS

Postby luben » Thu Jun 14, 2001 6:47 am

Hello,

Just for curiosity - is it mistake in the program ( "&=") or you made it especially? I can't find any sense to change the flag, even if this flag is temporary. The good style of programming is - don't do anything what you don't need and the sense of SALVO is the same - bring the power to useful, meaningful resources.

Regards
Luben

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 1 guest

cron