Re: scheduler locking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 01, 2002 at 03:50:34PM -0000, Pichai  Raghavan wrote:
> I have a requirement to lock the Linux scheduler; what I mean by  
> this is that when I enter the kernel mode in context of a 
> particular process, no other task (other than the idle task) 
> should be running.

On an UP, scheduling becomes cooperative. So you can make sure you are
not calling it in any way (beware that many things like kmalloc can
schedule, but usualy there is a non-blocking variant or flag).

On SMP (or with preempt patch) the situation is far worse, because on
the other CPUs, the processes are currently running.

> These are the various ways we have come up with:
> (i) Moving all tasks in the running queue to interruptile queue 
> other than current and idle task. This way schedule() can never 
> get to run any other task.

You sure don't want to make them interruptible. But even just puting
them to uninterruptible state would however add some races (and
processes that are already sleeping may be woken up anytime by an
interrupt. So you probably end up signalling all other processes with
SIGSTOP and waiting for them to actually get it.

This is also only way to get around that a process might be running on
onother CPU on SMP.

> (ii) Changing schedule so that it does a while(1) as long as the 
> current task is not in the run queue. Once the current task is 
> runnable return immediately.

You wouldn't need signals here. But you have to force schedule on all
CPUs on SMP.

In both cases, you must note, that things like kmalloc may wait on
kernel threads (like kswapd, bdflush, perhaps even kreiserfsd and maybe
others). If you don't let them to processor, you have to do everything
non-blocking anyway.

> Will the above ways work? Or there are better ways? One suggestion 
> I got was to use the goodness flag but I am not exactly sure.

IIRC goodness flag is related to how scheduler chooses processes to run
and it's too much scheduler internal that can change anytime (there are
at least two completely different schedulers around these days).

Perhaps if you said why do you need that, someone could come with more
elegant solution for the whole problem.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux