Pumpkin, Inc.

Pumpkin User Forums

OSTimedOut() second possible mistake

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

OSTimedOut() second possible mistake

Postby luben » Sun Jul 08, 2001 12:20 am

Hello,

This article should be named - "Mistake inside other mistake".

I'm thinking and thinking again about this macro OSTimedOut() and I see that maybe you have second mistake there. Let's explain....

In my opinion the macro should look like

code:

#define OSTimedOut() (OScTcbP->u.runStatus.state == OSTA_TIMEDOUT)

Why I think so... in the previous declaration of status states you wrote:

code:

#define OSTA_DESTROYED 0 /* 000b */
#define OSTA_STOPPED 1 /* 001b */
#define OSTA_DELAYED 2 /* 010b */
#define OSTA_WAITING 3 /* 011b */
#define OSTA_WAITING_TO 4 /* 100b */
#define OSTA_ELIGIBLE 5 /* 101b */
#define OSTA_TIMEDOUT 6 /* 110b */
#define OSTA_UNDEF 7 /* 111b */


I agree that & operator, like you set in the annotation note could work, but only if this definitions look like (every status has it's own bit)

code:

#define OSTA_DESTROYED 0 /* 00000000b */
#define OSTA_STOPPED 1 /* 00000001b */
#define OSTA_DELAYED 2 /* 00000010b */
#define OSTA_WAITING 4 /* 00000100b */
#define OSTA_WAITING_TO 8 /* 00001000b */
#define OSTA_ELIGIBLE 16 /* 00010000b */
#define OSTA_TIMEDOUT 32 /* 00100000b */
#define OSTA_UNDEF 64 /* 01000000b */

only now the operator & has the same meaning like ==, I mean you can compare the status with some value, just because every bit is connected with some status .

So... or your definition of OSTimedOut() is wrong and should be with ==, or the definitions of statuses are wrong. What I see is the DEMO version SALVO.H file. So, from what I see in the DEMO is that - one mistake exists more - it's up to you to see the sources and to find it. Well, I don't deny the oportunity that I mistake too :-)

regards
Luben

[This message has been edited by luben (edited July 09, 2001).]

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

Re: OSTimedOut() second possible mistake

Postby luben » Sun Jul 08, 2001 8:36 am

Because after returning from OS_WaitXYZ () are possible only 2 states it is really possible to use & operator, but like:

code:
--------------------------------------------------------------------------------

#define OSTimedOut() (!(OScTcbP->u.runStatus.state & 1))

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

Note that the result will be with negative value if not used "!". In old SALVO2.1 SALVO.H definitions it don't need "!".

I think that OSTimedOut() has still hidden problems - you know the law of Murphy - the problems are alwayes more then you expect and encountered :-)

Luben

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

Re: OSTimedOut() second possible mistake

Postby luben » Mon Jul 09, 2001 6:59 am

After one day of thinking I'm 95% sure that the definition of OSTimedOut() is wrong again (published in the SALVO BULLETIN BOARD). My opinion is :
Or the operator <&> should be changed to == or the value OSTIMED_OUT to 0x01.


Well, I'm not 100% sure, will be good if you had something in the mind and the operator only looks like wrong, but works correctly :-)

Regards
Luben

[This message has been edited by luben (edited July 09, 2001).]

[This message has been edited by luben (edited July 09, 2001).]

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

Re: OSTimedOut() second possible mistake

Postby aek » Tue Jul 10, 2001 8:19 am

The correct (final) definition should be:

code:
#define OSTimedOut() (OScTcbP->u.runStatus.state == OSTA_TIMEDOUT)

No need for curly braces, etc. but == is needed instead of & (or &&).

Statuses (sp?) are mutually exclusive and must fit into a 3-bit field -- therefore bit patterns are not applicable.

We'll update the Service Bulletin shortly ...

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

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


Return to Bug Reports

Who is online

Users browsing this forum: No registered users and 1 guest

cron