All of lore.kernel.org
 help / color / mirror / Atom feed
* time_is_after_jiffies misnomer
@ 2008-12-16 11:31 Peter T. Breuer
  2008-12-16 14:46 ` Johannes Weiner
  2008-12-18  7:38 ` Pavel Machek
  0 siblings, 2 replies; 10+ messages in thread
From: Peter T. Breuer @ 2008-12-16 11:31 UTC (permalink / raw)
  To: linux kernel


I thought at first that

    time_is_after_jiffies(foo)

meant that the current time is later than foo jiffies. In fact, it's
the reverse! (as far as I can tell! 2.6.26-11). 

Can we change this name or provide an alternative? Perhaps

   jiffies_is_later_than(foo)

??

Peter Breuer

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time_is_after_jiffies misnomer
  2008-12-16 11:31 time_is_after_jiffies misnomer Peter T. Breuer
@ 2008-12-16 14:46 ` Johannes Weiner
  2008-12-16 15:17   ` Peter T. Breuer
  2008-12-18  7:38 ` Pavel Machek
  1 sibling, 1 reply; 10+ messages in thread
From: Johannes Weiner @ 2008-12-16 14:46 UTC (permalink / raw)
  To: Peter T. Breuer; +Cc: linux kernel

On Tue, Dec 16, 2008 at 12:31:41PM +0100, Peter T. Breuer wrote:
> 
> I thought at first that
> 
>     time_is_after_jiffies(foo)
> 
> meant that the current time is later than foo jiffies.

'foo jiffies'?

It behaves like all the other time_(after|before) macros.  "Compare a
given time T against some other time X".

T is always the first argument to these macros, it's never the current
time.  This is consistent.

And jiffies, the X here, is a well-known global variable. :)

The banner comment above the macro group should have clarified the
misunderstanding, btw.

	Hannes

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time_is_after_jiffies misnomer
  2008-12-16 14:46 ` Johannes Weiner
@ 2008-12-16 15:17   ` Peter T. Breuer
  2008-12-16 16:18     ` Andreas Schwab
  2008-12-16 20:33     ` Johannes Weiner
  0 siblings, 2 replies; 10+ messages in thread
From: Peter T. Breuer @ 2008-12-16 15:17 UTC (permalink / raw)
  To: Johannes Weiner; +Cc: linux kernel

"Also sprach Johannes Weiner:"
> On Tue, Dec 16, 2008 at 12:31:41PM +0100, Peter T. Breuer wrote:
> > 
> > I thought at first that
> > 
> >     time_is_after_jiffies(foo)
> > 
> > meant that the current time is later than foo jiffies.
> 
> 'foo jiffies'?


?? What does that mean? Yes, "the current time is later than foo
jiffies", is what I wrote. I don't understand why you query it. What I
wrote is a perfectly normal english sentence. It means "if the current
time is X and and the 

> It behaves like all the other time_(after|before) macros.  "Compare a
> given time T against some other time X".

It's poor english. Yes, to an english speaker

   time_is_after_jiffies(foo)

looks like

   the current time is later than foo jiffies

Look at the two:

   the current time is later than foo jiffies
                 |   |  |           `/.
               time_is_after_jiffies(foo)

(I AM a native english speaker, and a very good one - please take this
on board and pay attention to it; you'll find me quoted as the author
of hundreds of technical articles on google :-).

The mathematical "jiffies(foo)" for colloquial "foo jiffies" is the
normal way of writing formal predicates.  Like "colour(red)" for
"red colour". This is a predicate.

> T is always the first argument to these macros, it's never the current
> time.  This is consistent.

That's surely not relevant since it's the macro name that we are talking
about, nothing else.

As to "these macros", I see and know of no macros other than the set I
am commenting on. If you mean some others, you'll have to point them
out to me, but it wouldn't invalidate the observation: the macro names
are phrased the wrong way round for a natural english interpretation.


> And jiffies, the X here, is a well-known global variable. :)


> The banner comment above the macro group should have clarified the
> misunderstanding, btw.

No, it says nothing:

  * These four macros compare jiffies and 'a' for convenience.

What's written above the individual macros is more explanatory, but
it's the NAMES of the macros that are the wrong way round for english:

  
  /* time_is_before_jiffies(a) return true if a is before jiffies */
  #define time_is_before_jiffies(a) time_after(jiffies, a)

It's time_is_before_jiffies(foo) that reads the wrong way round in
english. It should be


     current_time_is_after_jiffies(foo).

Best regards


Peter
  


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time_is_after_jiffies misnomer
  2008-12-16 15:17   ` Peter T. Breuer
@ 2008-12-16 16:18     ` Andreas Schwab
  2008-12-16 16:32       ` Peter T. Breuer
  2008-12-16 20:33     ` Johannes Weiner
  1 sibling, 1 reply; 10+ messages in thread
From: Andreas Schwab @ 2008-12-16 16:18 UTC (permalink / raw)
  To: ptb; +Cc: Johannes Weiner, linux kernel

"Peter T. Breuer" <ptb@inv.it.uc3m.es> writes:

> Look at the two:
>
>    the current time is later than foo jiffies
>                  |   |  |           `/.
>                time_is_after_jiffies(foo)

It's not "foo jiffies", it's time "foo" vs time "jiffies" (where jiffies
is the well known global variable).

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time_is_after_jiffies misnomer
  2008-12-16 16:18     ` Andreas Schwab
@ 2008-12-16 16:32       ` Peter T. Breuer
  2008-12-16 19:29         ` Chris Friesen
  0 siblings, 1 reply; 10+ messages in thread
From: Peter T. Breuer @ 2008-12-16 16:32 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: linux kernel

"Also sprach Andreas Schwab:"
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> "Peter T. Breuer" <ptb@inv.it.uc3m.es> writes:
> 
> > Look at the two:
> >
> >    the current time is later than foo jiffies
> >                  |   |  |           `/.
> >                time_is_after_jiffies(foo)
> 
> It's not "foo jiffies", it's time "foo" vs time "jiffies" (where jiffies
> is the well known global variable).

Forgive me, but you don't seem to really be taking it on board here
either ...  what it SAYS to an english reader is the opposite of what
you intend it to MEAN, unfortunately :(.

So the name is wrong. It's simple to fix. Just change the name. The
simplest naming fix is from

    time_is_after_jiffies(foo)

to

    time_is_before_jiffies(foo)

but obviously that would create more confusion yet, given the
unfortunate current scheme!  So how about keeping the current macro
names but gradually phasing them out in favour of a parallel set of 
alternatives, which could be

    current_time_is_before_jiffies(foo)

?? That reads fine in english and this time it means what it says!

Best regards

Peter

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time_is_after_jiffies misnomer
  2008-12-16 16:32       ` Peter T. Breuer
@ 2008-12-16 19:29         ` Chris Friesen
  0 siblings, 0 replies; 10+ messages in thread
From: Chris Friesen @ 2008-12-16 19:29 UTC (permalink / raw)
  To: ptb; +Cc: Andreas Schwab, linux kernel

Peter T. Breuer wrote:

> Forgive me, but you don't seem to really be taking it on board here
> either ...  what it SAYS to an english reader is the opposite of what
> you intend it to MEAN, unfortunately :(.

time_is_after_jiffies(foo) means: time "foo" is after the current value 
of the variable "jiffies" (which is used throughout the kernel as the 
current time).

You are interpreting it as: the current time is after time "foo" (which 
is in jiffies).

The reason why your interpretation is incorrect is that "jiffies" is a 
specific variable in and of itself, and not a modifier for "foo".

> So how about keeping the current macro
> names but gradually phasing them out in favour of a parallel set of 
> alternatives, which could be
> 
>     current_time_is_before_jiffies(foo)
> 
> ?? That reads fine in english and this time it means what it says!


You're using "jiffies" as a modifier for "foo", when it is actually a 
separate variable.  This makes your version just as ambiguous.

If you really want to change it, removing "jiffies" from the name (and 
thus removing any ambiguity) may make more sense.  Something like:

time_is_after(foo)

which would mean that the current value of "jiffies" is after "foo".

Chris

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time_is_after_jiffies misnomer
  2008-12-16 15:17   ` Peter T. Breuer
  2008-12-16 16:18     ` Andreas Schwab
@ 2008-12-16 20:33     ` Johannes Weiner
  1 sibling, 0 replies; 10+ messages in thread
From: Johannes Weiner @ 2008-12-16 20:33 UTC (permalink / raw)
  To: Peter T. Breuer; +Cc: linux kernel

On Tue, Dec 16, 2008 at 04:17:30PM +0100, Peter T. Breuer wrote:
> "Also sprach Johannes Weiner:"
> > On Tue, Dec 16, 2008 at 12:31:41PM +0100, Peter T. Breuer wrote:
> > > 
> > > I thought at first that
> > > 
> > >     time_is_after_jiffies(foo)
> > > 
> > > meant that the current time is later than foo jiffies.
> > 
> > 'foo jiffies'?
> 
> 
> ?? What does that mean? Yes, "the current time is later than foo
> jiffies", is what I wrote. I don't understand why you query it. What I
> wrote is a perfectly normal english sentence. It means "if the current
> time is X and and the 

Sorry, I forgot to remove that when I realized you were referring to
jiffies as a unit here.  Don't worry, I got it.

> > It behaves like all the other time_(after|before) macros.  "Compare a
> > given time T against some other time X".
> 
> It's poor english. Yes, to an english speaker
> 
>    time_is_after_jiffies(foo)
> 
> looks like
> 
>    the current time is later than foo jiffies
> 
> Look at the two:
> 
>    the current time is later than foo jiffies
>                  |   |  |           `/.
>                time_is_after_jiffies(foo)

The only problem I see is the `is'.  It should be called

	time_after_jiffies()

But time doesn't refer to `the current time' in the first place!  The
macro is not (meant to be) an English sentence.

'time' is the prefix for a group of symbols, a namespace if you will
and it stands for the first argument in all these macros. 'is_after'
is the relation.  'jiffies' the thing you compare with.  It's an infix
operator used in prefix form.

The only problem that I see with the jiffies-comparing macros is the
`is'.  They should be called time_after_jiffies() and
time_before_jiffies() etc.

> (I AM a native english speaker, and a very good one - please take this
> on board and pay attention to it; you'll find me quoted as the author
> of hundreds of technical articles on google :-).

They are probably written in a natural language.

> The mathematical "jiffies(foo)" for colloquial "foo jiffies" is the
> normal way of writing formal predicates.  Like "colour(red)" for
> "red colour". This is a predicate.

I don't think there are many functions/macros in the (core-)kernel
that have the types they operate on encoded in their names.

So interpreting the macro the way you did makes no sense to me
regarding the code in context.

> > The banner comment above the macro group should have clarified the
> > misunderstanding, btw.
> 
> No, it says nothing:
> 
>   * These four macros compare jiffies and 'a' for convenience.
> 
> What's written above the individual macros is more explanatory, but
> it's the NAMES of the macros that are the wrong way round for english:
> 
>   
>   /* time_is_before_jiffies(a) return true if a is before jiffies */
>   #define time_is_before_jiffies(a) time_after(jiffies, a)
> 
> It's time_is_before_jiffies(foo) that reads the wrong way round in
> english. It should be
> 
> 
>      current_time_is_after_jiffies(foo).

How would you name the existing time_after() then?

	Hannes

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time_is_after_jiffies misnomer
  2008-12-16 11:31 time_is_after_jiffies misnomer Peter T. Breuer
  2008-12-16 14:46 ` Johannes Weiner
@ 2008-12-18  7:38 ` Pavel Machek
  1 sibling, 0 replies; 10+ messages in thread
From: Pavel Machek @ 2008-12-18  7:38 UTC (permalink / raw)
  To: Peter T. Breuer; +Cc: linux kernel

On Tue 2008-12-16 12:31:41, Peter T. Breuer wrote:
> 
> I thought at first that
> 
>     time_is_after_jiffies(foo)
> 
> meant that the current time is later than foo jiffies. In fact, it's
> the reverse! (as far as I can tell! 2.6.26-11). 
> 
> Can we change this name or provide an alternative? Perhaps
> 
>    jiffies_is_later_than(foo)
> 
> ??

Yes, it is confusing and yes, it should be fixed. Probably by
introducing better names and switching callers to them.

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time_is_after_jiffies misnomer
  2008-12-16 16:04 Peter T. Breuer
@ 2008-12-16 16:13 ` Pekka Enberg
  0 siblings, 0 replies; 10+ messages in thread
From: Pekka Enberg @ 2008-12-16 16:13 UTC (permalink / raw)
  To: ptb; +Cc: hannes, linux kernel

On Tue, Dec 16, 2008 at 6:04 PM, Peter T. Breuer <ptb@inv.it.uc3m.es> wrote:
> The kernel's
>
>     time_is_after_jiffies(500)
>
> macro mathematically means
>
>    the current value of the jiffies variable is LESS THAN 500

Not that you would ever do something like that. Instead, you will see
something like this if you grep the kernel sources a bit:

    time_is_after_jiffies(jiffies + 500)

                    Pekka

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time_is_after_jiffies misnomer
@ 2008-12-16 16:04 Peter T. Breuer
  2008-12-16 16:13 ` Pekka Enberg
  0 siblings, 1 reply; 10+ messages in thread
From: Peter T. Breuer @ 2008-12-16 16:04 UTC (permalink / raw)
  To: hannes; +Cc: linux kernel

"Also sprach ptb:"
> "Also sprach Johannes Weiner:"
> > 'foo jiffies'?
> 
> ?? What does that mean? Yes, "the current time is later than foo
> jiffies", is what I wrote.  I don't understand why you query it. What I
> wrote is a perfectly normal english sentence.

Light dawns. Perhaps you think "jiffies" is a meaningless word that
happens to be the name of a variable that measures elapsed time.

It's not. "jiffy" is a "short moment of time" in english, and "jiffies"
is its plural. Like "augenblick" in german, but a bit longer
("augenblick" probably translates as "moment", or "instant", literally,
"eyeblink").  "In a jiffy" is an english phrase meaning "soon!".  It's
close to an "instant" but of vaguer extent.

So the variable called "jiffies" measures the number of elapsed
jiffies.

Like a variable called "hours" that measures the number of elapsed
hours.

"foo jiffies" is no stranger than "foo hours" or "foo minutes" or "foo
seconds". That's why I was puzzled that you queried it!

> It's poor english. Yes, to an english speaker
> 
>    time_is_after_jiffies(foo)
> 
> looks like
> 
>    the current time is later than foo jiffies
> 
> Look at the two:
> 
>    the current time is later than foo jiffies
>                  |   |  |           `/.
>                time_is_after_jiffies(foo)


See it now? 

Imagine that you had a macro called


   time_is_after_hours

then 

  time_is_after_hours(12)


would mean to an english speaker

  the current time is later than midday

I.e.

  the current time is later than 12h
               |    |   |        .|'
              time_is_after_hours(12)

Unfortunately the kernel's "time_is_after_hours(12)" macro means
mathematically what we would express in english as "the current time is
BEFORE 12h".  Ouch.

The kernel's 

     time_is_after_jiffies(500)

macro mathematically means

    the current value of the jiffies variable is LESS THAN 500

!! That's the other way round from the way that an english speaker
would read the macro name as meaning! So the semantics and the name
contradict each other.

Clear now?

Peter

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-12-18  7:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-16 11:31 time_is_after_jiffies misnomer Peter T. Breuer
2008-12-16 14:46 ` Johannes Weiner
2008-12-16 15:17   ` Peter T. Breuer
2008-12-16 16:18     ` Andreas Schwab
2008-12-16 16:32       ` Peter T. Breuer
2008-12-16 19:29         ` Chris Friesen
2008-12-16 20:33     ` Johannes Weiner
2008-12-18  7:38 ` Pavel Machek
2008-12-16 16:04 Peter T. Breuer
2008-12-16 16:13 ` Pekka Enberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.