80 likes | 195 Views
CS444/CS544 Operating Systems. Threads Introduction to CPU Scheduling 2/02/2006 Prof. Searleman jets@clarkson.edu. Outline. Laboratory exercise: PThreads CPU scheduling NOTE: Quiz: Thursday, 2/9, in lab (ITL) Covers material in SGG: Chapters 1 - 4
E N D
CS444/CS544Operating Systems Threads Introduction to CPU Scheduling 2/02/2006 Prof. Searleman jets@clarkson.edu
Outline • Laboratory exercise: PThreads • CPU scheduling NOTE: • Quiz: Thursday, 2/9, in lab (ITL) • Covers material in SGG: Chapters 1 - 4 • New due date for Lab#1: Tuesday, Feb. 7 • Read: Chapter 5
Thread Support • Pthreads is a user-level thread library • Can use multiple kernel threads to implement it on platforms that have kernel threads • Java threads (extend Thread class) run by the Java Virtual Machine • Kernel threads • Linux has kernel threads (each has its own task_struct) – created with clone system call • Each user level thread maps to a single kernel thread (Windows 95/98/NT/2000/XP, OS/2) • Many user level threads can map onto many kernel level threads like scheduler activations (Windows NT/2000 with ThreadFiber package, Solaris 2)
Scheduling Policy • We’ve talked about the context switch mechanism • How we change which process or thread is executing on the CPU • Today, we will talk about scheduling policies • How do we choose which process or thread to execute next • Unit of scheduling = process or thread
Scheduler • Scheduler = the module that moves jobs from queue to queue • Scheduler typically runs when: • A process/thread blocks on a request (transitions from running to waiting) • A timer interrupt occurs • A new process/thread is created or is terminated
Scheduling Algorithm • The scheduling algorithm examines the set of candidate processes/threads and chooses one to execute • Scheduling algorithms can have different goals • Maximize CPU utilization • Maximize throughput (#jobs/time) • Minimize average turnaround time ( Avg(EndTime – StartTime) ) • Minimize response time • Recall: Batch systems have which goal? Interative systems have which goal?
Starvation • Starvation = process is prevented from making progress towards completion because another process has a resource that it needs • Scheduling policies should try to prevent starvation • E.g. Even low priority processes should eventually get some time on the CPU
Brainstorm • What are some different ways to schedule access to a resource? • First Come First Serve • Many services humans use are like this? • Prefer Short Jobs • Express lane at the grocery store • Important Jobs First • Order you do your TODO list? Maybe round robin? • Now what about scheduling processes?