🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3487

Re: SysV shared memory coherency issues

#3487
From: Robert Redelmeier
Date: Tue, 14 Feb 2006 14:30
45 lines
4250 bytes
In comp.lang.asm.x86 Ryan Underwood <spamtrap@crayne.org> wrote in part:
>        if (m_Mailbox[STALE_MBOX] != 1)
>                { /* these actions are never taken */ }
> 
> which generated the following assembly:
> 
>        movl    8(%ebp), %eax   # this, this
>        movl    32(%eax), %eax  # <variable>.m_Mail
>        addl    $288, %eax      #, D.40882
>        fldl    (%eax)  #* D.40882
>        fld1

Egads!  You're not testing FP numbers for _equality_, are you?
This is a cardinal sin!  FP numbers are like sandpiles.
Whenever you move them, you lose some sand, and mix some dirt in.

When comparing floats/doubles, subtract&abs and test if the
difference is small enough.

In theory, if you start with clean FP registers (load an integer)
and never do anything nasty with them (like divide by non-2powers
or multiply by non-integers) then maybe they'll stay clean enough
for an equality compare.  But I wouldn't count on it!

> 
> to: [with knowledge that sizeof(double)==2*sizeof(uint32_t)]
> 
>        if (((uint32_t*)m_Mailbox)[STALE_MBOX*2] != 1)
>                { /* these actions are taken when mbox value is set to 0 */ }
> 
> which generated the following assembly:
> 
>        movl    8(%ebp), %eax   # this, this
>        movl    32(%eax), %eax  # <variable>.m_Mail
>        addl    $288, %eax      #, D.40882
>        movl    (%eax), %eax    #* D.40882, D.40883
>        cmpl    $1, %eax        #, D.40883
> 
> As you can see, the load changes from a floating point to
> an integer load.  To my utter astonishment, this corrected
> the symptom that I was observing.

Doh!

-- Robert
Technical Details
Message-ID: <vQlIf.47893$dW3.82@newssvr21.news.prodigy.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!news.glorb.com!news.hub.org!sn-xt-sjc-02!sn-xt-sjc-09!sn-post-01!supernews.com!corp.supernews.com!news.crayne.org!clax86!robomod!not-for-mail
References: <-Z-dneLPKKkNlWzeRVn-oQ@fidnet.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: fc89c,83404d35faeda18b
X-Google-Thread: f5392,83404d35faeda18b
X-Google-Thread: 11318c,83404d35faeda18b
X-Google-Thread: 114917,83404d35faeda18b
X-Google-Attributes: gidfc89c,gidf5392,gid11318c,gid114917,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!news.glorb.com!news.hub.org!sn-xt-sjc-02!sn-xt-sjc-09!sn-post-01!supernews.com!corp.supernews.com!news.crayne.org!clax86!robomod!not-for-mail
From: Robert Redelmeier <redelm@ev1.net.invalid>
Newsgroups: comp.unix.programmer,comp.os.linux.development.system,gnu.gcc.help,comp.lang.asm.x86
Subject: Re: SysV shared memory coherency issues
Approved: CLAX86 Moderators <ccrayne@crayne.org>
Date: Tue, 14 Feb 2006 14:30:51 GMT
Organization: SBC http://yahoo.sbc.com
Message-ID: <vQlIf.47893$dW3.82@newssvr21.news.prodigy.com>
Sender: clax86@wotan.crayne.org
References: <-Z-dneLPKKkNlWzeRVn-oQ@fidnet.com>
X-CLAX86-Policy: http://www.pacificsites.com/~ccrayne/clax86.html
X-CLAX86-Faq: http://www.faqs.org/faqs/by-newsgroup/comp/comp.lang.asm.x86.html
X-CLAX86-Info-1: Send submissions to comp-lang-asm-x86@moderators.isc.org
X-CLAX86-Info-2: Send technical complaints to clax86-admin@crayne.org
X-CLAX86-Info-3: Send complaints about policy to clax86-admin@crayne.org
X-Comment: moderators do not necessarily agree or disagree with this article.
X-Authentication-Warning: mailbox8.ucsd.edu: Host newssvr21-ext.news.prodigy.com [207.115.16.221] claimed to be newssvr21.news.prodigy.com
User-Agent: tin/1.6.2-20030910 ("Pabbay") (UNIX) (Linux/2.6.9n (i686))
X-UserInfo1: [[OWS\WEPBUIBFD[LZKJOPHAWB\^PBQLGPQRJRQIMASJETAANVW[AKWZE\]^XQWIGNE_[EBL@^_\^JOCQ^RSNVLGTFTKHTXHHP[NB\_C@\SD@EP_[KCXX__AGDDEKGFNB\ZOKLRNCY_CGG[RHT_UN@C_BSY\G__IJIX_PLSA[CCFAULEY\FL\VLGANTQQ]FN
X-Greylisting: NO DELAY (Relay+Sender autoqualified);
 processed by UCSD_GL-v2.1 on mailbox8.ucsd.edu;
 Tue, 14 February 2006 06:30:54 -0800 (PST)
X-Spam-Level: Level 
X-Spamscanner: mailbox8.ucsd.edu  (v1.6 Aug  4 2005 15:27:38, -2.8/5.0 3.0.4)
X-MailScanner: PASSED (v1.2.8 40640 k1EEUqit052519 mailbox8.ucsd.edu)
X-PacificInternet-MailScanner-Information: Please contact the ISP for more information
X-PacificInternet-MailScanner: Found to be clean
X-PacificInternet-MailScanner-SpamCheck: not spam (whitelisted),
 SpamAssassin (score=-0.001, required 5.5, autolearn=disabled,
 SPF_HELO_PASS -0.00)
X-PacificInternet-MailScanner-From: news@newssvr21-int.news.prodigy.com
X-Spam-Status: No
X-UIDL: 00D"!Nhi!!HnI"![/l!!
X-Complaints-To: abuse@supernews.com
Lines: 46