mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Krishna Kumar" <kumarkr@us.ibm.com>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Andreas Dilger <adilger@turbolabs.com>,
	ak@muc.de, andrewm@uow.edu.au,
	"David S. Miller" <davem@redhat.com>,
	jgarzik@mandrakesoft.com, kuznet@ms2.inr.ac.ru,
	linux-kernel@vger.kernel.org, netdev@oss.sgi.com,
	owner-netdev@oss.sgi.com, tim@physik3.uni-rostock.de
Subject: Re: [PATCH] net/ipv4/*, net/core/neighbour.c jiffies cleanup
Date: Thu, 8 Nov 2001 08:55:51 -0800	[thread overview]
Message-ID: <OFE014018A.D6D3430D-ON88256AFE.005C057D@boulder.ibm.com> (raw)


Hi Linus,

> >
> > In short: It is wrong to do
> >
> >          if (jiffies <= start+HZ)
> >
> > and it is _right_ to do
> >
> >          if (jiffies - start <= HZ)
>
> Actually this last part is wrong, isn't it ? jiffies <= start + HZ is
also
> a correct way to do it, since start+HZ will overflow to the current value
> of jiffies when HZ time elapses. So the above two statements are
IDENTICAL.
>
> No.
>
> Try it out with a few examples. You'll see.
>
>                    Linus

I am sorry, but I still don't see the difference. I wrote a small program
with different
cases, but the values still come same irrespective of the input arguments
to the
checks. Could you tell under what conditions the checks wuold fail ? The
2's
complement  works the same for addition and subtraction. I have included
the
test program below.

Thanks,

- KK

---------------------------------------------------------------------------------------------
/*
     if (jiffies <= start+HZ)
     if (jiffies - start <= HZ)
*/

#define HZ 100

main()
{
     unsigned long start, jiffies;

     /* Case 1 */
     start = ((unsigned long) -1);
     jiffies = start + HZ;
     if (jiffies <= start + HZ) {
           printf("Less Case 1\n");
     }
     if (jiffies - start <= HZ) {
           printf("Less Case 2\n");
     }

     /* Case 2 */
     start = ((unsigned long) -10);
     jiffies = start + HZ + 1;
     if (jiffies <= start + HZ) {
           printf("Less Case 3\n");
     }
     if (jiffies - start <= HZ) {
           printf("Less Case 4\n");
     }

     /* Case 3 */
     start = ((unsigned long) -10);
     jiffies = start + HZ - 1;
     if (jiffies <= start + HZ) {
           printf("Less Case 5\n");
     }
     if (jiffies - start <= HZ) {
           printf("Less Case 6\n");
     }
}



             reply	other threads:[~2001-11-08 17:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-08 16:55 Krishna Kumar [this message]
2001-11-08 17:10 ` Linus Torvalds
2001-11-08 18:01 ` Andreas Dilger
2001-11-09 10:43 ` Vino Thomas
  -- strict thread matches above, loose matches on Subject: below --
2001-11-08 17:47 Krishna Kumar
2001-11-08  3:07 Krishna Kumar
2001-11-08  5:26 ` Linus Torvalds
2001-11-08  0:00 Tim Schmielau
2001-11-08  0:09 ` David S. Miller
2001-11-08  0:36   ` Andreas Dilger
2001-11-08  1:22     ` Linus Torvalds
2001-11-08  0:44   ` David S. Miller
2001-11-08  0:58     ` Tim Schmielau
2001-11-08  1:09     ` David S. Miller
2001-11-08  1:20       ` Tim Schmielau
2001-11-08  1:36       ` David S. Miller
2001-11-08  4:32     ` Andreas Dilger
2001-11-08  4:39     ` David S. Miller
2001-11-08 17:54   ` kuznet
2001-11-08 18:10     ` Tim Schmielau
2001-11-08 18:10     ` Andreas Dilger
2001-11-08 18:32       ` kuznet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=OFE014018A.D6D3430D-ON88256AFE.005C057D@boulder.ibm.com \
    --to=kumarkr@us.ibm.com \
    --cc=adilger@turbolabs.com \
    --cc=ak@muc.de \
    --cc=andrewm@uow.edu.au \
    --cc=davem@redhat.com \
    --cc=jgarzik@mandrakesoft.com \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@oss.sgi.com \
    --cc=owner-netdev@oss.sgi.com \
    --cc=tim@physik3.uni-rostock.de \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®