Why does the prior level change in this case.

This is a discussion on Why does the prior level change in this case. within the Linux Programming forums, part of the Platform Specific Boards category; I need to undertand why the following works the way it does. When I do something like cat < /dev/zero ...

  1. #1
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329

    Why does the prior level change in this case.

    I need to undertand why the following works the way it does.

    When I do something like

    cat < /dev/zero | grep "f" > /dev/null &
    And then exit the bash shell, I see the following on top

    Code:
     PID USERNAME PRI NICE  SIZE   RES STATE    WAIT     TIME    CPU COMMAND
     4372 cd    64    0  164M  146M sleep    biowai  84:25  8.01&#37; grep
     5664 _postfix   2    0  820K  884K sleep    select  86:57  0.00% qmgr
    Now I do the same thing again. Ie

    cat < /dev/zero | grep "f" > /dev/null &
    But instead of exiting, I kill the bash session. Which in turn logs me out. When this happens, 2 minutes later, I see

    Code:
      PID USERNAME PRI NICE  SIZE   RES STATE    WAIT     TIME    CPU COMMAND
     4372 cd    -5    0  164M  146M sleep    biowai  84:25  8.01% grep
     5664 _postfix   2    0  820K  884K sleep    select  86:57  0.00% qmgr
    Ie, the PRI changes from 64 to -5 and as a result, the system starts to slow. What would trigger such behavior?

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,251
    The priority is a dynamic value. You shouldn't expect it to remain the same every time you look at it. It's part of the scheduling algorithm.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Also, I doubt very much that it would affect the performance of the system - it's only using 8% CPU time.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Segmentation fault!?!?!?
    By Viper187 in forum Windows Programming
    Replies: 57
    Last Post: 10-02-2008, 09:40 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. A simple array question
    By frenchfry164 in forum C++ Programming
    Replies: 7
    Last Post: 11-25-2001, 03:13 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21