Re: Making a SCHED_FIFO process monopolize the processor

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

 



On Sat, Aug 28, 2010 at 06:35:03PM +0200, Michael Blizek wrote:
> Hi!
> 
> On 02:01 Sat 28 Aug     , Pablo Antonio wrote:
> ...
> > I want to know if it's possible to create a real-time process with
> > SCHED_FIFO policy that starts running and never lets any other process
> > run again.
> 
> Yes, it should be. However hardware interrupts will still arrive.

I don't care about that. All I want is *no other processes* to run ever
again, but kernel code in my process' context is alright.

> 
> > I had read that processes in SCHED_FIFO usually run until a) they block
> > themselves by calling some syscall (for example, an I/O request), b)
> > they are preempted by some higher priority process or c) they decide to
> > yield the processor. So I thought that technically it would be possible
> > to create a process that "takes over" the processor from all the other
> > processes: Just create a SCHED_FIFO process that loops infinitely.
> > 
> > However, when I tried this it didn't work. Someone told me about
> > sched_rt_runtime_us and sched_rt_period_us, which acted like a
> > protection for this cases. So I tried both setting sched_rt_runtime_us
> > to -1 and setting both values to the same number, but it didn't work
> > either: I can switch to another terminal, execute top and see the
> > process running.
> 
> This is weird. Are you sure that you have put the process in the SCHED_FIFO
> queue and assigned a static priority > 0 via sched_setscheduler? If you start
> top and look in the PR column you should see "RT".

Here's something I've been using. The first command sets the runtime value
to the period value, so real-time process don't leave space for other
processes to run. The others create process with SCHED_FIFO policy.

$ cat /proc/sys/kernel/sched_rt_period_us | sudo tee /proc/sys/kernel/sched_rt_runtime_us
$ time sudo chrt -f 99 bash -c 'seq 10000000 > /dev/null'

In a two-core CPU I used:
$ time sudo chrt -f 99 bash -c 'seq 10000000 > /dev/null' & time sudo chrt -f 99 bash -c 'seq 10000000 > /dev/null'

For some reason, for priority numbers under 99 the PR column doesn't say RT.
For example, for priority 98 it says -99. Those commands sometimes kind of
hang the other processes but sometimes they don't.

> 
> > What am I doing wrong? Is there some option in the kernel I have to
> > enable/disable?
> 
> I do not think that there is an option about this.

:/

Thanks,

-- 
Pablo Antonio (AKA crazy2k)
http://www.pablo-a.com.ar/



--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at 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