public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: george anzinger <george@mvista.com>
To: nigel@nrg.org
Cc: Roger Larsson <roger.larsson@norran.net>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH for 2.5] preemptible kernel
Date: Tue, 20 Mar 2001 14:27:21 -0800	[thread overview]
Message-ID: <3AB7D949.FC508065@mvista.com> (raw)
In-Reply-To: <Pine.LNX.4.05.10103201333590.26772-100000@cosmic.nrg.org>

Nigel Gamble wrote:
> 
> On Tue, 20 Mar 2001, Roger Larsson wrote:
> > One little readability thing I found.
> > The prev->state TASK_ value is mostly used as a plain value
> > but the new TASK_PREEMPTED is or:ed together with whatever was there.
> > Later when we switch to check the state it is checked against TASK_PREEMPTED
> > only. Since TASK_RUNNING is 0 it works OK but...
> 
> Yes, you're right.  I had forgotten that TASK_RUNNING is 0 and I think I
> was assuming that there could be (rare) cases where a task was preempted
> while prev->state was in transition such that no other flags were set.
> This is, of course, impossible given that TASK_RUNNING is 0.  So your
> change makes the common case more obvious (to me, at least!)
> 
> > --- sched.c.nigel       Tue Mar 20 18:52:43 2001
> > +++ sched.c.roger       Tue Mar 20 19:03:28 2001
> > @@ -553,7 +553,7 @@
> >  #endif
> >                         del_from_runqueue(prev);
> >  #ifdef CONFIG_PREEMPT
> > -               case TASK_PREEMPTED:
> > +               case TASK_RUNNING | TASK_PREEMPTED:
> >  #endif
> >                 case TASK_RUNNING:
> >         }
> >
> >
> > We could add all/(other common) combinations as cases
> >
> >       switch (prev->state) {
> >               case TASK_INTERRUPTIBLE:
> >                       if (signal_pending(prev)) {
> >                               prev->state = TASK_RUNNING;
> >                               break;
> >                       }
> >               default:
> > #ifdef CONFIG_PREEMPT
> >                       if (prev->state & TASK_PREEMPTED)
> >                               break;
> > #endif
> >                       del_from_runqueue(prev);
> > #ifdef CONFIG_PREEMPT
> >               case TASK_RUNNING               | TASK_PREEMPTED:
> >               case TASK_INTERRUPTIBLE | TASK_PREEMPTED:
> >               case TASK_UNINTERRUPTIBLE       | TASK_PREEMPTED:
> > #endif
> >               case TASK_RUNNING:
> >       }
> >
> >
> > Then the break in default case could almost be replaced with a BUG()...
> > (I have not checked the generated code)
> 
> The other cases are not very common, as they only happen if a task is
> preempted during the short time that it is running while in the process
> of changing state while going to sleep or waking up, so the default case
> is probably OK for them; and I'd be happier to leave the default case
> for reliability reasons anyway.

Especially since he forgot:

TASK_ZOMBIE
TASK_STOPPED
TASK_SWAPPING

I don't know about the last two but TASK_ZOMBIE must be handled
correctly or the task will never clear.

In general, a task must run till it gets to schedule() before the actual
state is "real" so the need for the TASK_PREEMPT.  

The actual code generated with what you propose should be the same (even
if TASK_RUNNING != 0, except for the constant).

George

  reply	other threads:[~2001-03-20 22:32 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-15  1:25 [PATCH for 2.5] preemptible kernel Nigel Gamble
2001-03-17 17:34 ` Pavel Machek
2001-03-19 21:01   ` Nigel Gamble
2001-03-20  8:43 ` Rusty Russell
2001-03-20  9:32   ` Keith Owens
2001-03-21  0:48     ` Nigel Gamble
2001-03-21  1:23       ` Keith Owens
2001-03-21  3:35         ` Nigel Gamble
2001-03-21  8:04           ` george anzinger
2001-03-21  9:04             ` Keith Owens
2001-03-21 14:32             ` Rusty Russell
2001-03-23 20:42               ` Nigel Gamble
2001-03-28 11:47             ` Dipankar Sarma
2001-03-21  9:19           ` Keith Owens
2001-03-21  9:41             ` David S. Miller
2001-03-21 10:05               ` Andrew Morton
2001-03-22  0:20                 ` Nigel Gamble
2001-03-21 10:57               ` george anzinger
2001-03-21 11:30                 ` David S. Miller
2001-03-21 17:07                   ` george anzinger
2001-03-21 18:18               ` Nigel Gamble
2001-03-21 22:25               ` Rusty Russell
2001-03-21 15:46             ` Andrea Arcangeli
2001-03-28 10:20           ` Dipankar Sarma
2001-03-28 20:51             ` george anzinger
2001-03-29  9:43               ` Dipankar Sarma
2001-03-30  6:32               ` Keith Owens
2001-03-21  0:24   ` Nigel Gamble
2001-03-30  0:26     ` Nigel Gamble
2001-03-30 20:11       ` Rusty Russell
2001-04-01  7:48         ` george anzinger
2001-04-01 21:13           ` Nigel Gamble
2001-04-02 19:56             ` george anzinger
2001-04-04 17:59               ` Rusty Russell
2001-04-01 21:07         ` Nigel Gamble
2001-04-04 17:51           ` Rusty Russell
2001-03-20 18:25 ` Roger Larsson
2001-03-20 22:06   ` Nigel Gamble
2001-03-20 22:27     ` george anzinger [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-04-06 23:52 Paul McKenney
2001-04-07  0:45 ` Andi Kleen
2001-04-07  1:25 Paul McKenney
2001-04-07 19:59 ` Rusty Russell

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=3AB7D949.FC508065@mvista.com \
    --to=george@mvista.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nigel@nrg.org \
    --cc=roger.larsson@norran.net \
    /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