Find the answer to your Linux question:
Results 1 to 8 of 8
Hello, I just would like to ask how I can change OS quantum (time slice) in Linux? For example, smaller value makes context switch be more frequent. Thanks, Jeff...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2013
    Posts
    2

    Change OS quantum


    Hello,

    I just would like to ask how I can change OS quantum (time slice) in Linux? For example, smaller value makes context switch be more frequent.


    Thanks,

    Jeff

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Hi,

    Could you provide a little more detail about what you are trying to do? Maybe a code example or a description of a specific problem would help.

  3. #3
    Linux Newbie Syndacate's Avatar
    Join Date
    May 2012
    Location
    Hell..no literally, this state is hell..
    Posts
    192
    Quote Originally Posted by atreyu View Post
    Hi,

    Could you provide a little more detail about what you are trying to do? Maybe a code example or a description of a specific problem would help.
    He described what he's looking for pretty well..

    He wants to modify the scheduler such that each thread is spending less time on the CPU before a chance to context switch. Giving him access to the scheduler code would be plenty useful for his purposes. I'd tell him but I simply don't know where that functionality is in the kernel.

  4. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by Syndacate View Post
    He described what he's looking for pretty well..
    No, you described it pretty well... :)

  5. #5
    Linux Newbie Syndacate's Avatar
    Join Date
    May 2012
    Location
    Hell..no literally, this state is hell..
    Posts
    192
    Quote Originally Posted by atreyu View Post
    No, you described it pretty well...
    I feel like I parroted him but okay, lol. Now that it's out in the open hopefully there's somebody around who knows the kernel well enough to point this guy in the right direction.

  6. #6
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    3,569
    I'm no expert on the linux source code, but this looks like an interesting tool
    What do we want?
    Time machines!

    When do we want 'em?
    Doesn't really matter does it!?


    The Fifth Continent

  7. #7
    Linux Newbie Syndacate's Avatar
    Join Date
    May 2012
    Location
    Hell..no literally, this state is hell..
    Posts
    192
    Quote Originally Posted by elija View Post
    I'm no expert on the linux source code, but this looks like an interesting tool
    It's going to be a place in the source. Or if not direct C source it'll be a module of some sort with the scheduling configuration - not sure how it's programmed.

    I feel like I should look this up now :-\.

  8. #8
    Linux Newbie Syndacate's Avatar
    Join Date
    May 2012
    Location
    Hell..no literally, this state is hell..
    Posts
    192
    I just checked the kernel source tree, as of 3.9.4:

    Investigate the
    /kernel/sched/ directory. It seems that all the scheduling info is in there. There's only like 10 C files, though the core is 200kb so expect to read a lot for that .

    I didn't dig through the actual files but if I had to guess, you'll want a basic understanding of what functions exist in core.c so you can see the functionality, even if you only know the functions that are in there it'll give you an idea as to the functionality. Use an IDE or ctags or whatever your favorite flavor of C code browsing is to pull up all the functions/members to give you a nice overview of the contents.

    After that, check out rt.c for the real time scheduler it seems, and fair.c for the fair scheduler. Real time is about 1/3 the size so I'd suggest looking at that one first.

    Same process for that, take a look at what functions are in there, use their names and other misc. public or static data members (also see what's in sched.h as far as function and member declarations go) to try to learn what the hell they're doing.

    If there's an "interface" of sorts (which I'm guessing there is) in order to swap schedulers out easily, you may not fond a lot of functions in the scheduler files being directly called, they'll probably be called via funct ptrs from the core.

    Oh well, that's about all I can tell you man. I don't really know anything about the kernel but that's what I gathered between this post and the last with a quick google .

    Best of luck, man. I'm not sure if the quantum will be part of the individual schedule or the core programming, but I'm guessing it'll likely be one or the other. If not, I can almost guarantee it's AT LEAST in the sched folder, haha.

    Hope that helps ya some!

Posting Permissions

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