Operating System Threads and Scheduling
Operating System Threads and Scheduling
Threads and
Scheduling
This presentation covers threads and scheduling in operating
systems. We will compare user-level and kernel-level threads. We will
also explore scheduling algorithms and real-world applications. Let's
start our journey into OS internals.
SD
by SAYAMMI DOSHI
User-Level Threads vs. Kernel-Level Thread
User-Level Threads (ULT) Kernel-Level Threads (KLT)
Managed by a user-level library. The kernel is unaware of Managed directly by the OS kernel. Each KLT can run in
these threads. parallel on multiprocessors.
Deadlocks
Two or more threads are blocked. Each is waiting for the other to
release a resource.
Scheduling in Operating
Systems
Turnaround Time
Time to execute a
process.
Types of Scheduling: A Comparison
Long-Term Scheduling Short-Term Scheduling Medium-Term Scheduling
Controls the degree of Selects which process should Reduces degree of multiprogramming.
multiprogramming. execute next.
• Swapping.
• Job scheduling. • CPU scheduling. • Remove process from memory.
• Selects processes from the pool. • Invoked very frequently. • Later re-introduced into memory.
• Executed much less frequently. • Must be very fast.
CPU Scheduling Algorithms
FCFS SJN
First Come First Serve. Shortest Job Next.
Simple, but can cause convoy effect. Minimizes average waiting time.
Fair, but context switching overhead. Higher priority gets CPU first.
Real-World Application:
Linux vs. Windows
Linux
Uses a Completely Fair Scheduler (CFS).
Windows
Hybrid approach with priority-based scheduling.