Linux Process Management

Linux Process Management
Linux Implementation of Threads
• Threads enable concurrent programming /
true parallelism
• Linux implementation of threads
Linux Process Scheduling
• Policy
– Policy is the behavior of the scheduler that
determines what runs when. A scheduler’s policy
often determines the overall feel of a system.
– I/O-Bound vs. Processor-Bound Processes
• Scheduler policy in Unix systems tends to explicitly
favor I/O-bound processes
• Linux..
Process priority
• 2 ranges
– nice value
• -20 to +19 with default of 0
• Larger nice values correspond to lower priority
• ps –el
– real-time priority
• 0 -99
• Higher values correspond to higher priority
• Used for real-time processes – always higher than
normal processes.
The scheduling policy in action
Process Scheduling in Unix
• Based on traditional methods
– Timeslice
– Priority (Priority exported to user in nice values)
• Problematic
– Two low priority processes swap to much
– Timeslice / priority correlation
– Timeslice measurement (timer click)
The scheduling policy in action
• Linux: Completely Fair Scheduling
– Model process scheduling as if the system had an
ideal perfectly multitasking processor.
• That is, each process receives 1/n of the processor’s
time, where n is the number of runnable processes and
we’d schedule them for intimately small durations, so
that in any measureable period we’d have urn all n
processes for the same time.
• Conceptually: we are running 2 processes
simultaneously each using 50% of CPU
Completely Fair Scheduling (CFS)
• CFS will run each process for some amount of
time, round-robin, selecting next the process
that has run the least.
Completely Fair Scheduling (CFS)
Determine Time allotted to run
• CFS calculates how long a process should run
as a function of the total number of runnable
• CFS uses the nice value to weight the
proportion of the processor a process should
Completely Fair Scheduling (CFS)
Determine Time allotted to run
• Each process then runs for a “time-slice”
proportional to its weight divided by the total
weight of all runnable threads.
Completely Fair Scheduling (CFS)
Picking the next task
• Red/black trees
– Balanced tree
• Leftmost leaf contains process with the
smallest runtime (time spent running)
normalized by the number of runnable
processes and by its ‘weight’
Kernel Preemption
• Unix kernel is non-preemptive
• Linux kernel is pre-emptive
Real-Time Scheduling Policies
• Not managed by CFS, but by a separate realtime scheduler.
• Soft real-time behavior
Related flashcards

Corporate governance

23 cards

System administration

65 cards


61 cards

Create Flashcards