2003-05-22 17:45:11

by Ming Lei

[permalink] [raw]
Subject: Linux 2.4 scheduler is RTOS-alike?


this question is regarding linux kernel 2.4.7-2.4.20.
linux 2.4 kernel does support real time sheduler. If using FIFO real time
schedule policy, would the case that higher priority thread starve the lower
priority thread happen? Similarly, let's say an example: if I have higher
prioority thread A and lower priority thread B, thread A is running without
any wait or blocking, is there a possiblity that 2.4 scheduler may want to
switch to thread B? Why?

If I want to instrument the 2.4 kernel to print out the message for every
thread context switch, where should I put the trace point?



2003-05-22 19:47:11

by Ming Lei

[permalink] [raw]
Subject: Re: Linux 2.4 scheduler is RTOS-alike?


will it be the same behavior If thread A and thread B both have a lot of
printf? Suppose A get first run, does B get run at all?

> this question is regarding linux kernel 2.4.7-2.4.20.
> linux 2.4 kernel does support real time sheduler. If using FIFO real time
> schedule policy, would the case that higher priority thread starve the
lower
> priority thread happen? Similarly, let's say an example: if I have higher
> prioority thread A and lower priority thread B, thread A is running
without
> any wait or blocking, is there a possiblity that 2.4 scheduler may want to
> switch to thread B? Why?

Yes, FIFO threads that spin will block lower priority threads forever.

Sure, guaranteed if the high prio SCHED_FIFO task doesn't block at all. If
you have a pure cpu burner, it will starve all lower priority
threads.

2003-05-22 20:24:23

by Elladan

[permalink] [raw]
Subject: Re: Linux 2.4 scheduler is RTOS-alike?

The printfs could block, so B could run while A is blocked.

They might not ever block if you're always printing to the console, but
if they go over the network or into some sort of file or anything, they
could block.

If you want to trace the operation without blocking, you might make your
own printf that outputs to a ring buffer, or use internal counters or
the like.

-J

On Thu, May 22, 2003 at 01:01:30PM -0700, Ming Lei wrote:
>
> will it be the same behavior If thread A and thread B both have a lot of
> printf? Suppose A get first run, does B get run at all?
>
> > this question is regarding linux kernel 2.4.7-2.4.20.
> > linux 2.4 kernel does support real time sheduler. If using FIFO real time
> > schedule policy, would the case that higher priority thread starve the
> lower
> > priority thread happen? Similarly, let's say an example: if I have higher
> > prioority thread A and lower priority thread B, thread A is running
> without
> > any wait or blocking, is there a possiblity that 2.4 scheduler may want to
> > switch to thread B? Why?
>
> Yes, FIFO threads that spin will block lower priority threads forever.
>
> Sure, guaranteed if the high prio SCHED_FIFO task doesn't block at all. If
> you have a pure cpu burner, it will starve all lower priority
> threads.

2003-05-22 20:34:44

by Elladan

[permalink] [raw]
Subject: Re: Linux 2.4 scheduler is RTOS-alike?

Also of note, FIFO threads will actually block the same priority threads
forever. An RR thread will also block a lower priority thread forever,
but it'll get preempted by other RR threads with the same priority. A
FIFO thread is never preempted except by higher priority, it has to
yield somehow (explicitly or by blocking)

-J

On Thu, May 22, 2003 at 01:01:30PM -0700, Ming Lei wrote:
>
> will it be the same behavior If thread A and thread B both have a lot of
> printf? Suppose A get first run, does B get run at all?
>
> > this question is regarding linux kernel 2.4.7-2.4.20.
> > linux 2.4 kernel does support real time sheduler. If using FIFO real time
> > schedule policy, would the case that higher priority thread starve the
> lower
> > priority thread happen? Similarly, let's say an example: if I have higher
> > prioority thread A and lower priority thread B, thread A is running
> without
> > any wait or blocking, is there a possiblity that 2.4 scheduler may want to
> > switch to thread B? Why?
>
> Yes, FIFO threads that spin will block lower priority threads forever.
>
> Sure, guaranteed if the high prio SCHED_FIFO task doesn't block at all. If
> you have a pure cpu burner, it will starve all lower priority
> threads.