Slashdot Mirror


The Completely Fair Scheduler

hichetu writes "Kernel trap has a nice summary of what is going on behind the scenes to change the Linux Scheduler. The O(1) Linux scheduler is going to be changed so that it is fair to interactive tasks. You will be surprised to know that O(1) is really too good not to have any side-effects on fairness to all tasks."

79 of 292 comments (clear)

  1. Isnt this called Cron ? by Anonymous Coward · · Score: 5, Funny


    I thought Linux used Cron as a scheduler ?

    1. Re:Isnt this called Cron ? by ozamosi · · Score: 5, Informative

      That is for scheduling background tasks that run once a day (or whatever you set it to)

      This is for scheduling CPU resouces in real time. To decide if Firefox or Apache is going to be executed the following split second.

    2. Re:Isnt this called Cron ? by LiquidCoooled · · Score: 5, Funny

      Can't we just give the processes weapons and let them decide which follows?

      --
      liqbase :: faster than paper
    3. Re:Isnt this called Cron ? by sphealey · · Score: 5, Interesting

      > Can't we just give the processes weapons and
      > let them decide which follows?

      That is actually the kind of question that my Operations Research professor (who also did a lot of work in CPU simulation and performance estimating) used to throw onto final exams as the "separate the B+ from the A" question. If your answer was interesting enough he would send you over to one of his Masters candidates to see if it could be taken any further. So I wouldn't count your suggestion out from the start!

      sPh

    4. Re:Isnt this called Cron ? by HerrEkberg · · Score: 5, Funny

      Just throw this into the kernel and we are good to go.

    5. Re:Isnt this called Cron ? by Progman3K · · Score: 4, Informative

      Yes, that's called psDoom
      http://psdoom.sourceforge.net/

      --
      I don't know the meaning of the word 'don't' - J
    6. Re:Isnt this called Cron ? by Anonymous Coward · · Score: 5, Insightful

      Coming up with an idea (even if totally made up) and the backing it up with arguments is much harder than memorization and regurgitation and actually backing it up with things having to do with that class shows you have learned something, or at least know about the concepts discussed in the class.

    7. Re:Isnt this called Cron ? by KDR_11k · · Score: 2

      In school they told us exactly that, doesn't matter if your conclusion is wrong if you argue it right.

      --
      Justice is the sheep getting arrested while an impartial judge declares the vote void.
    8. Re:Isnt this called Cron ? by sphealey · · Score: 5, Interesting

      That guy was actually the best test writer and overall course designer that I have ever had among all the academic (through a masters) teachers and corporate trainers I have encountered. When you finished his course you received exactly the grade you deserved according to the formal definitions of the grades; as you indicate one didn't receive an A in that class unless one actually _understood_ the material [for the record I was in the B+ group ;-( - which was a correct evalution]. Not surprisingly it also turned out to be one of the most useful classes I ever took as well.

      sPh

    9. Re:Isnt this called Cron ? by theonetruekeebler · · Score: 5, Funny
      Okay -- Since I'm not allowed to drink beer in class I'll just have to post this from home.

      Want to give each process a weapon? Fine. But they have to earn ammunition.

      Every time a process gives up its slot, it's given a round of ammunition. It has the option of "shooting" a process ahead of it in the queue, thereby expending a round of ammunition. A shot process must give up its slot in the next round. Whether it loses all its ammo when it respawns remains a research question.

      There are two floating point tunable parameters, "accuracy" and "rampage." "Accuracy" is the likelihood that a given shot will actually hit the process it aims at. "Rampage" is the tendency of a process to save up rounds for a while then go on a spree.

      Okay, there's a third parameter, "armor," which is the odds of a hit actually becoming an injury. This is meant to protect system processes against luser jobs, and top-level processes against spawned threads.

      Of course, the scheduler itself is a boss job that can't be killed, has perfect armor and has infinite ammo.

      For the purpose of top and other job monitoring tools we can replace a process's "NICE" score with a "VIOLENCE" score -- an aggregate of their armor, accuracy, rampage tendencies and current ammo supply. We can rename the renice utility to medicate. The important thing about medication is that it eventually wears off, unless you specify the -l (lobotomize) option, which turns the process into a harmless drooling vegetable. Its companion utilities are aim and armor, which tune a job's accuracy and armor class, respectively.

      There are two important things about this approach. First, it's probabilistic instead of purely heirarchical. Second, it should give Jack Thompson the screaming heebie jeebies. In fact, I'm going to call this the JTMS scheduler -- the Jack Thompson Murder Simulator Scheduler.

      I'm sure this concept can be explored further, but the bar's about to close.

      --
      This is not my sandwich.
    10. Re:Isnt this called Cron ? by smittyoneeach · · Score: 3, Interesting

      You mean this was the "old school" where you were graded on the basis of something they used to call "learning".
      "Progress" has saved us all of that stress and ambiguity.
      Now, you just pay a small mountain of cash for tuition, and walk away with your "A".
      It's all about efficiency these days.

      --
      Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
    11. Re:Isnt this called Cron ? by kcbrown · · Score: 5, Interesting

      For the purpose of top and other job monitoring tools we can replace a process's "NICE" score with a "VIOLENCE" score -- an aggregate of their armor, accuracy, rampage tendencies and current ammo supply. We can rename the renice utility to medicate. The important thing about medication is that it eventually wears off, unless you specify the -l (lobotomize) option, which turns the process into a harmless drooling vegetable. Its companion utilities are aim and armor, which tune a job's accuracy and armor class, respectively.

      Of course, with such a scheduler, something like the Doom system administration tool (perhaps more like Quake where you can aim vertically as well as horizontally) will become the preferred method of managing the processes on a system.

      For one thing, the processes will obviously shoot back, as the process manager itself (which you see as yourself when running it) is a running process, and thus subject to being fired upon by the other processes.

      Secondly, a headshot obviously gets you a "lobotomize" effect. This could pose a problem if one of the other processes hits you with a headshot...

      Finally, the application of a medpack to an injured process invokes the "medicate" action.

      There are a few possible problems with this, of course:

      1. When you have two or more system administrators, all running the process manager, the system itself becomes a warzone with innocent processes being killed by the dozen as the administrators go on rampages in their attempts to kill each other for supreme control of the system.
      2. Certain weapons, such as the BFG, are powerful enough to take out all but the most heavily armored processes, and since some of them are area effect weapons, a lot of innocent processes will bite the dust as a result of their usage.
      3. Lightly-armored processes will need additional protection in the form of fast reflexes to avoid being hit.
      4. Eventually the administrators will begin using aimbots and the like. One can see where the resulting arms race will go. Obviously the aimbots will have to run on a different system since otherwise they'll be potential targets.
      5. "Spawn camping" takes on a whole new meaning. Newly created processes become very vulnerable compared with running under earlier versions of Linux. Normal users will have an increasingly difficult time starting tasks like OpenOffice and will start to migrate back to Windows or other OSes with clearly inferior schedulers.
      6. Due to all of the above, the system will eventually become unusable by anyone but the system administrators. The sysadmins will, of course, say that this is how it should be.

      In short, Linux will quickly become the must-have operating system for gamers, but at the expense of the general purpose desktop.

      --
      Use 'slashdot stuff' in the subject line in any email you send me if you want to get past the spam filter.
    12. Re:Isnt this called Cron ? by Syberghost · · Score: 2, Funny

      Of course, the scheduler itself is a boss job that can't be killed, has perfect armor and has infinite ammo.

      Fascist!

    13. Re:Isnt this called Cron ? by shaitand · · Score: 2, Interesting

      'Coming up with an idea (even if totally made up) and the backing it up with arguments is much harder than memorization and regurgitation and actually backing it up with things having to do with that class shows you have learned something, or at least know about the concepts discussed in the class.'

      Sure. It demonstrates that you've learned something and that you are a quick thinking and creative person. Your writing ability also plays a major role.

      Unfortunately, you could learn the material without being creative, quick thinking, or a good writer. If you are this unfortunate sole you just got a lower grade. Grades are supposed to demonstrate understanding of the course material, not how bright you are.

    14. Re:Isnt this called Cron ? by Khazunga · · Score: 2, Informative

      Unfortunately, you could learn the material without being creative, quick thinking, or a good writer. If you are this unfortunate sole you just got a lower grade. Grades are supposed to demonstrate understanding of the course material, not how bright you are.

      It's a philosophical question, with no correct answer, but I don't think grades should evaluate the understanding of a course. Grades should evaluate the ability to *use* the material of a course. This is beyond understanding. A student who completely understands a course should get a B. An A-level student is one who grasps the course material so well that he builds on it to produce other conclusions.

      If you lack skills needed to compound your understanding of the material, tough luck. A B is not a poor grade...

      --
      If at first you don't succeed, skydiving is not for you
    15. Re:Isnt this called Cron ? by shaitand · · Score: 3, Insightful

      'Grades should evaluate the ability to *use* the material of a course.'

      I disagree. That falls back to a measure of the intellect of the individual. That will play a role after school but you don't go to school to demonstrate your abilities or use material, you go to learn material.

      'An A-level student is one who grasps the course material so well that he builds on it to produce other conclusions.'

      I agree with that. Someone who has a fully grasp of the material understands it well. As I said, the grade should reflect understanding of the material that you took the course to learn. It should not reflect intellect (beyond that required to understand said material), creativity, etc.

      'If you lack skills needed to compound your understanding of the material, tough luck. A B is not a poor grade...'

      I never said a student with a more thorough understanding of the material shouldn't get an A. I said the A shouldn't be reserved for the quick thinking creative writer who can make up nonsense on the spot for a test question. The slow methodical student may have greater insight into the material but be less creative.

      This is the same faulty logic that leads to essays and papers as a measure of understanding. Papers do demonstrate understanding but they aren't the best tool to do so. If papers are primary method used to measure understanding then you aren't ultimately measuring comprehension of the material, you are measuring writing ability.

  2. Fair? by alienmole · · Score: 4, Funny

    If scheduling was completely fair, this would have been a frist ps0t.

  3. Smells like Communism by 0xdeadbeef · · Score: 5, Funny

    Free software: because some processes are more equal than others.

    1. Re:Smells like Communism by Anonymous Coward · · Score: 5, Funny

      Yes, each process according to its needs,
      each CPU according to its abilities.

  4. Surprised? by WombatDeath · · Score: 5, Funny

    You will be surprised to know that O(1) is really too good not to have any side-effects on fairness to all tasks.

    No I won't, because I don't know what the hell it means.

    Hah! In your face, Taco!

    1. Re:Surprised? by Eevee · · Score: 5, Informative

      In computer science, Big O notation is used for the complexity of a task.

    2. Re:Surprised? by jrschulz · · Score: 5, Informative

      A scheduler is the piece of software that brings you the illusion of multi-tasking. Because a single processor (with a single core) can only run one process at the same time, the operating system switches the process currently running. And it does this very fast (IIRC up to 1000 times a second in the case of linux).

      The scheduler decides which process runs when and has to make sure that no process has to wait in the queue forever without getting his share of CPU time (this is what is called "starving").

      Since the scheduler is a program by itself, it has a specific runtime characteristic, usually dependent of the number of programs waiting for their CPU share. The special property of the current scheduler in linux is that its runtime is in fact independent of this number. That's expressed in CS by O(1).

    3. Re:Surprised? by BiggerIsBetter · · Score: 4, Funny

      In computer science, Big O notation is used for the complexity of a task.

      Meanwhile, outside computer science, Big O faces are used for the completion of a task.

      --
      Forget thrust, drag, lift and weight. Airplanes fly because of money.
    4. Re:Surprised? by Otter · · Score: 4, Informative

      I think the intended meaning is "Unsurprisingly, the O(1) behavior came at the expense of optimum scheduling."

    5. Re:Surprised? by marcosdumay · · Score: 2

      It's more like: "Our O(1) algorithm gives the optimum performance we tried so much to achieve. But when we made it, we discovered that we were persuing the wrong goal."

  5. SMP and RT capabilities? by Anonymous Coward · · Score: 2, Interesting

    Will the new scheduler be more efficient at scheduling single processes across a multi-core system?

    On another not[e], when are we going to be able to build a default kernel capable of low latency I/O for A/V work?

  6. I/O prioritisation by Doug+Neal · · Score: 5, Interesting

    Linux really doesn't need a new process scheduler. What it could really do with is I/O prioritisation. Windows now has it, so there's no excuse. CPU power is fairly abundant these days so managing its usage is less of an issue than it used to be, but I/O bandwidth is often in short supply and I/O-bound applications can choke a system and make interactive processes a pain in the ass to use. I'd like to see some way of reserving and limiting bandwidth to particular devices for particular processes. And an equivalent of "top" for monitoring processes' I/O activity would also be extremely handy... as far as I know, the system calls don't even exist in the kernel to do this yet.

    1. Re:I/O prioritisation by tepples · · Score: 4, Interesting

      And an equivalent of "top" for monitoring processes' I/O activity would also be extremely handy... as far as I know, the system calls don't even exist in the kernel to do this yet. Windows has this to an extent. I press Ctrl+Shift+Esc to open Windows Task Manager, then View > Select Columns... > turn on Page Faults Delta, and I see the penalty for sticking with the 6-year-old paid-for PC that I still use.
    2. Re:I/O prioritisation by Anonymous Coward · · Score: 5, Informative

      > What it could really do with is I/O prioritisation.
      ionice. Available since 2005-08-28.

      > And an equivalent of "top" for monitoring processes' I/O activity would also be extremely handy

      I agree, that would be nice.

    3. Re:I/O prioritisation by hackstraw · · Score: 2, Informative

      Linux really doesn't need a new process scheduler. What it could really do with is I/O prioritisation. Windows now has it, so there's no excuse.

      I dunno. Linux has has some changes recently in the scheduling department, and an O(1) process scheduler can only be "a good thing". Recently, the I/O block layer got a new scheduler (linky http://kerneltrap.org/node/7637). Regarding other I/O prioritization, I can't say with authority that this is needed or not.

      Maybe all of these things are related, but in my selfish world, I want Linux to scale better. Scaling well beyond 64 CPUs or cores, but I believe this is a much greater task than ~60 hours of coding. It took a while before Linux got SMP clean, and today SMP is normal, not something that reserved for servers. The monolithic high clockrate CPU is dead, and this has been overtaken by multi-core processors, and more than one of them inside of one box. In my eye, this is where all OSes should be focusing their attention.

    4. Re:I/O prioritisation by Stephen+Williams · · Score: 5, Interesting
      And an equivalent of "top" for monitoring processes' I/O activity would also be extremely handy

      I'd love something like that.

      There's a way of logging I/O; it's pretty rough-and-ready, not really suitable for permanent use, but can be handy for figuring out what keeps causing a laptop HDD to spin up, for example. As root, do:

      echo 1 >/proc/sys/vm/block_dump
      I/O is then logged to the kernel ring buffer, and can be retrieved with dmesg. The entries look like:

      pdflush(138): WRITE block 1161864 on dm-4
      pdflush(138): WRITE block 0 on dm-3
      pdflush(138): WRITE block 524328 on dm-3
      pdflush(138): WRITE block 786952 on dm-3
      pdflush(138): WRITE block 786960 on dm-3
      When you've finished, do

      echo 0 >/proc/sys/vm/block_dump
      as root to turn it off again.

      Like I said, very rough-and-ready, nowhere near as nice as a proper I/O top would be, but there it is.

      -Stephen
    5. Re:I/O prioritisation by Anonymous Coward · · Score: 2, Informative

      Linux has had I/O prioritization for a few years now. There are a couple of I/O schedulers adapted to different workloads (deadline, anticipatory, fair, no op) that can be set globally or per block device. The default scheduler since 2.6.18 is cfq (the "fair" one) and it supports manual prioritization too (using the "ionice" command).

      In fact, I don't think Linux has ever suffered from the same I/O problems that people often complain about in Windows.

    6. Re:I/O prioritisation by jawtheshark · · Score: 4, Informative

      Now, page faults are indeed a form of I/O, but a page fault is technically seen just the fact that some memory required isn't in physical memory. I don't think the parent poster was talking about that. One of the most common reasons for page faults are simply that a block of memory has been swapped to disk, and then suddenly it is required, and as such the block of memory needs to be read into the physical memory.

      I'd say: add some memory to that box of yours.

      You can read up on it here

      --
      Ahhh...the great dumpster continuum. Many a free computer will be found there. -- sowth (748135)
    7. Re:I/O prioritisation by DaleGlass · · Score: 3, Informative

      atop seems to have support for disk monitoring, but it requires a kernel patch:

      http://www.atconsultancy.nl/atop/kernpatch.html

    8. Re:I/O prioritisation by ppc_digger · · Score: 4, Funny

      I agree, that would be nice.
      Don't you mean "that would be ionice"?
      --
      Of all major operating systems, UNIX is the only one originally meant for gaming.
    9. Re:I/O prioritisation by Anonymous Coward · · Score: 2, Interesting

      I read an article somewhere on Sun's site about I/O scheduling in SunOS, but unfortunately I can't find it now. I'll try to summarize it. The basic point was that when a task wants to write data, it can typically hand that data off to the kernel and then keep running. That means that it's making best use of system resources, since it will use the processor (for example) while the kernel writes to the disk in the background. When a task wants to read data, however, it usually can't do anything until the data's read from disk. So what SunOS will do is schedule I/O unfairly, prioritizing reads over writes, to minimize the amount of time that tasks spend blocked. (My experience is that it will even aggressively swap out pages to expand the write cache.) I wish I could find that article, I seem to remember it having some interesting nitty-gritty details about the way this is actually implemented, as well as some benchmarks from a customer.

    10. Re:I/O prioritisation by makomk · · Score: 2, Informative

      Linux has has some changes recently in the scheduling department, and an O(1) process scheduler can only be "a good thing".

      Which, presumably, is why they're thinking of taking out its current O(1) process scheduler and replacing it with an O(log(n)) one?

    11. Re:I/O prioritisation by Mike+McTernan · · Score: 2, Informative

      iostat is probably an easier way to achieve similar output.

      It still doesn't break it down by task though, so not really the iotop people are looking for.

      --
      -- Mike
    12. Re:I/O prioritisation by Animats · · Score: 4, Interesting

      Linux really doesn't need a new process scheduler. What it could really do with is I/O prioritisation.

      QNX has that, which is essential for real-time work.

      QNX has the advantage that I/O, like almost everything else in QNX, is done via inter-process message passing operations. The message passing system uses priority queues, and so requests to file systems and devices get handled in priority order. So resource managers (file systems, device drivers, etc.) don't have to explicitly handle priorities; it's done for them. Some resource managers, like disk handlers, process multiple requests at a time so they can reorder them to optimize access, but network devices and such are FIFO at the resource manager level and priority ordered at the message level.

      The end result is that you can compile or surf the web on a system that's also doing real time work without interfering with the real time tasks.

    13. Re:I/O prioritisation by Doug+Neal · · Score: 2

      Remember that when multiuser system starts choking due to unoptimized process handling code. Linux can run on setups that differ from your single user workstation. I know this all too well and had this in mind in my original post, most of my Linux work is on servers (although I do have a Linux workstation) - being able to reserve/restrict I/O and CPU per user or better still per website and database would be like, totally useful.
    14. Re:I/O prioritisation by Breakfast+Pants · · Score: 4, Informative

      A one line script does the trick, name it kplayer and put it in ~/bin (and put ~/bin at the top of your $PATH):

      #!/bin/sh
      nice -n -19 ionice -c 1 /usr/bin/kplayer


      --

      --

      WHO ATE MY BREAKFAST PANTS?
    15. Re:I/O prioritisation by JonXP · · Score: 2, Insightful

      And Vista has it completely. Just start up the Resource Monitor (either via the start menu, or the button on the task manager) and you can see all your I/O statistics, as well as several other computer health stats.

    16. Re:I/O prioritisation by brezel · · Score: 2, Informative

      don't forget arguments :)

      #!/bin/sh
      nice -n -19 ionice -c 1 /usr/bin/kplayer $@

    17. Re:I/O prioritisation by asninn · · Score: 2, Interesting

      There's some folks working on scaling, too. ;) I wonder where I'll get a 4096 CPU machine, though...

      --
      butter the donkey
    18. Re:I/O prioritisation by dotgain · · Score: 2, Funny

      If you want me to go on arguing, you'll have to pay for another five minutes.

    19. Re:I/O prioritisation by Handyman · · Score: 4, Informative

      In fact, this functionality is pretty darn useless. (I should know, I got it into 2.6. :-) ) For read I/O it's okay, but for write I/O it sucks. The thing is, what's logged is the actual I/Os, which are generally done by pdflush (if the modifying process doesn't use fsync, which it usually doesn't), and kjournald if you're using ext3. The only thing that's logged otherwise is that a process dirties an inode, but that doesn't tell you how many pages it's modified. You get something like

      process syslogd dirtied inode daemon.log
      process Y dirtied inode some_other_file1
      process Z dirtied inode some_other_file2

      followed by 300 writes by pdflush, which only specify a device and a block number, not a file name. There's no way you can find out for each of the 300 writes whether it was caused by the "syslogd", X or Z process. So there's no way you can count the amount of write I/O that a process has done.

    20. Re:I/O prioritisation by Animats · · Score: 3, Interesting

      Actually, that was the Mars Pathfinder. It was running VxWorks, and the effect of the priority inversion was that the stall timer would trip and reset the whole system. The problem was that VxWorks, like QNX, lets you turn off "priority inheritance" on a mutex. This is usually a bad decision, but that was done on the Mars Pathfinder, and created the possibility of a livelock.

      So they uploaded a patch to change that mutex to "priority inheritance on", and it worked consistently thereafter.

    21. Re:I/O prioritisation by QuoteMstr · · Score: 2, Informative

      nice -n -19 ionice -c 1 /usr/bin/kplayer "$@"

      Quoting the $@ is necessary to ensure that file names with spaces are passed as single words.

  7. credit goes to Con Kolivas by phrasebook · · Score: 3, Insightful

    This new scheduler may have 'Ingo Molnar' written all over it but I'll be giving the credit to ck!

    1. Re:credit goes to Con Kolivas by Anonymous Coward · · Score: 2, Insightful

      Perhaps if we had more 'ego maniacs' like Ingo, stuff would work better?

      I don't think your characterization is fair, I read the entire thread and all I see is someone doing his job.

    2. Re:credit goes to Con Kolivas by jb.cancer · · Score: 5, Informative

      Well, yes & no. It really was Con's RSDL that got ppl looking seriously into changing the mainline scheduler (there already being several out-of-mainline alternatives like nicksched, etc.)

      Con's scheduler seemed to work better at higher workloads than the mainline, by just trying to distribute load evenly and not trying pretty interactivity tricks. But several ppl did say it didn't perform well for certain X client workloads. That's when Ingo's CFS was posted.

      There really is 2 alternatives Ingo's CFS & Con's SDL that's being simultaneously tested by the kernel developers now, and none is accepted into mainline.

      So it wouldn't be fair to say that CFS is *the* next Linux scheduler. It could be SDL as well.

    3. Re:credit goes to Con Kolivas by Anonymous Coward · · Score: 2, Insightful

      Yeah right. doing his job.. Take all the credits. Diss other people's ideas, reimplement them and claim innovation. That used to define the Microsoft notion of innovation.

      I don't know any of these guys and never dealt with them on any level.

      i'd like to give credit to Con Kolivas for the general approach here:
      he has proven via RSDL/SD that 'fair scheduling' is possible and that it results in better desktop scheduling. Kudos Con!

      --- linux.orig/kernel/sched.c
      +++ linux/kernel/sched.c
      @@ -16,6 +16,7 @@
        * by Davide Libenzi, preemptible kernel bits by Robert Love.
        * 2003-09-03 Interactivity tuning by Con Kolivas.
        * 2004-04-02 Scheduler domains code by Nick Piggin
      + * 2007-04-15 Con Kolivas was dead right: fairness matters! :)
        */

      Ingo admitting he was wrong and giving full credit to someone else for the idea is not consistent with my view of an egomaniac. If you have other issues, slashdot may not be the best place to resolve them.

  8. Optimizations leading to less optimized code by suv4x4 · · Score: 3, Insightful

    It's a very interesting phenomenon.

    After enough number of iterations trying to optimize a software program to do everything very well compared to the base "naive" solution, you end up with an OS that does everything poorly.

    It's counterintuitive, but we see it it every day around us.

    1. Re:Optimizations leading to less optimized code by Chandon+Seldon · · Score: 2, Insightful

      After enough number of iterations trying to optimize a software program to do everything very well compared to the base "naive" solution, you end up with an OS that does everything poorly.

      That's blatantly false. Sure, there are tradeoffs. There are also cases where a better algorithm is an outright win 100% of the time.

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
  9. The Multics scheduler always seemed very nice by Anonymous Coward · · Score: 4, Interesting

    On Multics, tasks that used up their CPU were put in a lower priority run queue and tasks that didn't use up their CPU time were put into a higher priority run queue.

    So interactive tasks naturally floated to the top and compute bound tasks naturally sank.

    (Anyone remember Multics?)

    1. Re:The Multics scheduler always seemed very nice by Hognoxious · · Score: 3, Funny

      I used Multics, but I thought it prioritised the tasks by how thick the cards were.

      --
      Confucius say, "Find worm in apple - bad. Find half a worm - worse."
  10. Re:O(1) - what a huge misnomer by Watson+Ladd · · Score: 3, Informative

    Actually the Linux scheduler is O(1). Processes are placed on O(1) queues, and the oldest processes on each queue are compared to each other. The number of queues is fixed, so Linux only has 5 nice levels. This is a scheduler because newer processes on a queue do not deserve the time more then the processes ahead of them.

    --
    Inventions have long since reached their limit, and I see no hope for further development.-- Frontinus, 1st cent. AD
  11. Re:O(1) - what a huge misnomer by ASBands · · Score: 4, Informative

    If you want a good description of the old way it works (which is what you're talking about), [PDF Warning] here it is. As this PDF describes, the 2.4.x kernel uses a O(n) fast algorithm for choosing the next task, going through the array of tasks to re-evaluate them. The the Linux 2.6.x scheduler recalculates timeslices as each task uses up its timeslice. In this fashion, the kernel should always know the most important thread, it is simply the next element. Granted, you are doing the same amount of work, but the pauses for re-evaluation are spread out so that you don't get long lapses where nothing important happens.

    --
    My UID is a prime number. Yeah, I planned that.
  12. The Mother of All Comp-Sci Flame Wars by mosel-saar-ruwer · · Score: 5, Funny

    GP: Can't we just give the processes weapons and let them decide which follows?

    P: That is actually the kind of question that my Operations Research professor (who also did a lot of work in CPU simulation and performance estimating) used to throw onto final exams as the "separate the B+ from the A" question. If your answer was interesting enough he would send you over to one of his Masters candidates to see if it could be taken any further. So I wouldn't count your suggestion out from the start!

    Behold: The Mother of All Possible Comp Sci Flame Wars: The Darwinistically Selected Genetic Algorithms -vs- the Intelligently Designed Algorithms.

    Bumper Stickers $4.95; T-Shirts $19.95:

    $DEITY does not play dice with the Turing Machine.
  13. Completely fair? by tji · · Score: 4, Funny

    No, I think I'll wait for the unbelievably fair scheduler, or perhaps the ridiculously fair scheduler.

  14. Re:And that relates to "fairness" how? by wellingj · · Score: 3, Funny

    The current O(1) schedule is not entirely fair to attain so named O(1) performance. That's how jackass.

  15. Re:O(1) - what a huge misnomer - INCORRECT by ArbitraryConstant · · Score: 4, Informative

    You are incorrect because the act of scheduling the next process to run requires constant time regardless of how many processes there are. The O(1) refers to this, correctly.

    The reason this is important, and the reason they are worried about the act of scheduling the next process rather than time complexity over all N processes, is that if scheduling the next process were not constant time, the percentage of time spent scheduling the next process would grow larger as you added more processes. That's fine if you're on a desktop system and you go from 100 to 200, but as the number starts getting large on (say) big servers, you start running into a situation where all your CPUs are perpetually tied up trying to figure out what process to run next.

    O(n) time over N processes is not a problem; you've either got the CPUs or you don't. If you don't, then your performance will suck for reasons that are your own fault. If you do have enough CPUs, then the time spent scheduling will remain in step with the time spent running the processes, and this is fine. However, if the time spent scheduling grew, every time a process was scheduled, across all CPUs, then your $50000 server would be worthless because it wouldn't be able to handle the workloads you intended for it. All those expensive CPUs would sit there figuring out what process to run rather than running it.

    So, it is NOT a misnomer. It accurately describes the portion of the problem that the developers are concerned with. It's O(n) over n processes, and that's great because it means you can get to n without breaking down.

    --
    I rarely criticize things I don't care about.
  16. Re:O(1) - what a huge misnomer by Watson+Ladd · · Score: 3, Informative

    No. You are wrong. It looks O(n) unless you notice that the processes back on the queue ran more recently then the ones at the front. Therefore they have lower priority then the ones at the front, so we only need to worry about the processes at the front of the queues. To evaluate these priorities we just store the last time they ran, and then subtract from the current time, then add that to the inherent priority.

    --
    Inventions have long since reached their limit, and I see no hope for further development.-- Frontinus, 1st cent. AD
  17. Re:O(1) - what a huge misnomer by ASBands · · Score: 5, Informative

    Here's how Linux 2.6.x task scheduler works:

    • A "runqueue" keeps track of all essential tasks assigned to a given CPU [Queue is O(1) efficient]
    • Each runqueue contains two priority arrays, the active and the expired. As a task completes, it is moved (during the move, the new timeslice is calculated - the point of debate and largest fundamental change to the task scheduler) [Moving from static array to static array is O(1) efficient]
    • When the active priority array is finished, the expired array becomes the active array [Swapping 2 pointers is O(1) efficient]
    • The priority arrays are of fixed length 140, as that is the amount of priority levels Linux has [O(140) = O(1)]
    The point of debate comes if two threads have the same priority, in which case they are put on a round robin in the priority array. However, the confusion comes in that the execution is O(n) (which makes sense if you think about it), but the scheduler itself handles these at O(1) efficiency.
    --
    My UID is a prime number. Yeah, I planned that.
  18. Interactive tasks by Zarhan · · Score: 3, Insightful

    For this reason, I've been using Con Kolivas' patches to replace the scheduler. http://members.optusnet.com.au/ckolivas/kernel/ - very helpful especially if you don't have the fastest computer around. Also seems to help a bit with I/O - if my hard drive is trashing for whatever reason, interactive stuff still remains reasonably responsive. Or at least it doesn't make my mouse cursor skip...

    Even so, I'd prefer to have IO better scheduled - ionice doesn't really seem to work at least for me.

  19. Wait wait wait! What about fixing disk IO first? by Anonymous Coward · · Score: 2, Informative

    There's a huge thread about broken disk IO in kernels > 2.6.17.
    http://forums.gentoo.org/viewtopic-t-482731.html

    How about fixing that first?

    I've noticed all kinds of new schedulers coming out of the woodwork in 2.6. Optional kernel preemption. And also changes to the default timer (250 instead of 100, etc.). These are choices like I've never had in Linux before. Should be good, right?

    But at a higher level there's been such brokenness.
    K3B CD burning broke in 2.6.8 and wasn't fixed until 2.6.10.
    Firewire performance (for me) started fluctuating after ~2.6.7. Although grabbing DV over firewire doesn't take much CPU time, for some reason having video preview enabled during capture may/may not cause dropped frames (on a modern amd64! pathetic!) depending on kernel version.
    And the promise of 2.6 being responsive and feeling interactive under heavy load? Also ended after 2.6.7 for me.
    Recent kernels, like 2.6.18, seem to take minutes to balance tasks out. Playing video during heavy CPU usage? For me it gives priority to everything else BUT the new video process for about 30 seconds. (CFM or anticipatory scheduler)

    So I'm not sure if we should be welcoming all this new "choice" with scheduler-du-jour or try to give us a good default choice that actually works right first.

  20. Re:O(1) - what a huge misnomer by xenocide2 · · Score: 4, Insightful

    It seems like the difference is that people call it an O(1) scheduler to reflect the fact that all the work required to be done at the end of a timeslice (record keeping, picking a new process etc) is done in constant time, and people arguing for O(n) are referring to the cost to schedule all processes. Nobody's saying they can find a schedule for n processes without looking at all of them.

    --
    I Browse at +4 Flamebait

    Open Source Sysadmin

  21. O(1) too good. Surprise? by ozone_sniffer · · Score: 2, Informative

    You will be surprised to know that O(1) is really too good not to have any side-effects on fairness to all tasks. No I won't. AFAIK, O(1) is generally too good for any algorithm that does something useful, given the size of your input varies (n processes). With an input of size n, O(n^k) is generally (i.e. not considering a specific algorithm) acceptable, O(n) is generally good, O(log n) is generally very good and O(1) is generally suppa-duppa doubleplusgood.
  22. PSDoom (Doom process manager) by Alwin+Henseler · · Score: 3, Funny

    Good job sending all those /.ers over there, it will be the mother of all process fights on that poor server now. Sysadmins battling their way through hordes of zombies and monster processes, with ammo (ehm.. mem,cpu) running lower and lower until they're out, just as another wave of uglies comes out of nowhere...

  23. Re:Well duh by Anonymous Coward · · Score: 3, Interesting

    Obviously O(1) is a bad choice. Nice to see Linux learning something from Windows here.

    Actually I find the Windows (XP, haven't tried Vista yet) scheduler to be quite horrible especially with regards to interactivity. One resource hog and things pretty much come to a standstill. IMO it's worse than O(1) and no comparison to Con's staircase.

  24. Fair schedulers are for the weak by hcdejong · · Score: 3, Funny

    Klingon multitasking systems do not support "time-sharing". When a Klingon program wants to run, it challenges the scheduler in hand-to-hand combat and owns the machine.

    (from here)

  25. Re:And that relates to "fairness" how? by GrievousMistake · · Score: 3, Informative

    You fail at reading comprehension. Let's rephrase: The current scheduler runs in O(1) time. To do this, it uses an algorithm that sometimes isn't optimal; that is, it isn't entirely fair.
    The relation between fairness and algorithmic complexity, is that you may sacrifice fairness to get a lower complexity.
    This is just rephrasing GP, I don't know shit enough about schedulers to comment on the actuall algorithms.

    --
    In a fair world, refrigerators would make electricity.
  26. This is very impressive by Animats · · Score: 2, Interesting

    I'm impressed. I did some work on CPU dispatching on a mainframe system in the distant past, and we were never able to beat O(log n) on an ordered dispatch queue. The obvious implementation is O(n); getting to O(log n) requires a tree, and I want to see how they got to O(1).

    This stuff really matters now. If we're going to have 80-CPU multiprocessors, all the main operating system algorithms have to be near O(1), or the scale-up is a lose.

    1. Re:This is very impressive by Anonymous Coward · · Score: 3, Informative

      They cheated.

      Internally, the kernel only has five priority levels. Each one is a queue, and it compares among all of them to determine which task to run, but it only compares the head of the queue. So it's O(5), which is of course O(1), but if it supported an arbitrary number of priority levels (which IMO it should) then it would become O(n) again.

    2. Re:This is very impressive by Watson+Ladd · · Score: 2, Informative

      They cheated. Instead of having a real priority queue Linux places each process into one of a bunch of smaller queues each one with a different priority. Then scheduling requires looking a the processes that are at the head of the fixed number of small queues.

      --
      Inventions have long since reached their limit, and I see no hope for further development.-- Frontinus, 1st cent. AD
  27. Re:Linux is fading away by maxwell+demon · · Score: 4, Insightful

    Possible explanation: More people know about Linux now, so there's less need to Google to learn about it.
    Alternative explanation: People have less problems now using Linux, so they google less for solutions on Linux problems.
    Third explanation: Linux documentation got substantially better, so people have less need to use Google as a substitute.
    Fourth explanation: The larger density of Linux installations comes with a larger density of Linux experts, so people are more likely to consult their local Linux guru than Google.

    Pick your favorite choice or make up yet another explanation.

    Yes, those explanations are all completely made up, but so was the explanation you had in mind.

    --
    The Tao of math: The numbers you can count are not the real numbers.
  28. Re:Isnt this called Cron?^H^H^H^H^H^H Tron? by Jac_no_k · · Score: 2, Interesting

    This reminds me of a movie called Tron.

  29. Schedulers these days I dunnu... by Nefarious+Wheel · · Score: 2, Funny
    It's all data structures and interrupts nowdays laddie! Data structures and interrupts. Why back in my day we had nice chrome-plated algorithms and fat polling intervals and liked it!

    You pesky young folk who think yer flash ram is better than good old reliable ferrite donuts have at with ye! We had disk drives that could pull yer filings out from two feet away on a max seek. Do ya get technology like that nowdays? Do ya? Nuuuuu.....

    Mind ye what we had for an OS scheduler was a smiling polish gennelmun who wore too much after shave, and he was a bit much, but we knew which program ran after which we did! Off with ye now, come back when you have a *real* algorithm.

    (Walks away muttering at his shoes)

    --
    Do not mock my vision of impractical footwear
  30. Re:Linux is fading away by Khazunga · · Score: 2, Insightful

    Bah, it's so easy...

    --
    If at first you don't succeed, skydiving is not for you