Find the answer to your Linux question:
Results 1 to 3 of 3
Hello mates, I am working on currently 2.6.25.14 version of the K. Suppose there are 2 threads L ( Lower priority ) and H ( Higher Priority ). Lets say ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2009
    Posts
    15

    How does schedule() behave?


    Hello mates,

    I am working on currently 2.6.25.14 version of the K.

    Suppose there are 2 threads L ( Lower priority ) and H ( Higher Priority ). Lets say H is currently running and there's an instruction to "schedule()", assume there's some while condition.

    If this happens, would L gets a chance for execution although it has lower priority than H? Or the scheduler just keep on trying only H?

    Thanks,
    Goutham.

  2. #2
    Just Joined!
    Join Date
    Nov 2007
    Posts
    8
    If there is no other threads whose priority is higher than L waiting in the wait queue then I think the L thread will be given control of the CPU.

    Hope this answers your question and correct me if I am wrong.

  3. #3
    Just Joined!
    Join Date
    Feb 2009
    Posts
    15
    Hello GordenLopes,

    I figured things going through some technical articles. You are right to some extent till K version 2.4. However, from 2.6 onwards scheduling happens in a different way. So, for my current question the answer would be "L will be scheduled even though H has higher priority and is in the ready-queue".

    K 2.6 has a new concept called "dynamic task prioritization".

    To prevent tasks from hogging the CPU and thus starving other tasks that need CPU access, the Linux 2.6 scheduler can dynamically alter a task's priority. It does so by penalizing tasks that are bound to a CPU and rewarding tasks that are I/O bound. I/O-bound tasks commonly use the CPU to set up an I/O and then sleep awaiting the completion of the I/O. This type of behavior gives other tasks access to the CPU.

    I sincerely appreciate your effort.

    --Goutham.

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •