2008-12-16 11:31:56

by Peter Breuer

[permalink] [raw]
Subject: time_is_after_jiffies misnomer


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


2008-12-16 14:44:43

by Johannes Weiner

[permalink] [raw]
Subject: Re: time_is_after_jiffies misnomer

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

2008-12-16 15:18:00

by Peter Breuer

[permalink] [raw]
Subject: Re: time_is_after_jiffies misnomer

"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

2008-12-16 16:05:20

by Peter Breuer

[permalink] [raw]
Subject: Re: time_is_after_jiffies misnomer

"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

2008-12-16 16:13:43

by Pekka Enberg

[permalink] [raw]
Subject: Re: time_is_after_jiffies misnomer

On Tue, Dec 16, 2008 at 6:04 PM, Peter T. Breuer <[email protected]> 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

2008-12-16 16:19:25

by Andreas Schwab

[permalink] [raw]
Subject: Re: time_is_after_jiffies misnomer

"Peter T. Breuer" <[email protected]> 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, [email protected]
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."

2008-12-16 16:33:03

by Peter Breuer

[permalink] [raw]
Subject: Re: time_is_after_jiffies misnomer

"Also sprach Andreas Schwab:"
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> "Peter T. Breuer" <[email protected]> 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

2008-12-16 19:30:21

by Chris Friesen

[permalink] [raw]
Subject: Re: time_is_after_jiffies misnomer

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

2008-12-16 20:32:21

by Johannes Weiner

[permalink] [raw]
Subject: Re: time_is_after_jiffies misnomer

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

2008-12-18 07:38:50

by Pavel Machek

[permalink] [raw]
Subject: Re: time_is_after_jiffies misnomer

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