Class Note for CMPSCI 377 at UMass(58)
Class Note for CMPSCI 377 at UMass(58)
Popular in Course
Popular in Department
This 4 page Class Notes was uploaded by an elite notetaker on Friday February 6, 2015. The Class Notes belongs to a course at University of Massachusetts taught by a professor in Fall. Since its upload, it has received 15 views.
Reviews for Class Note for CMPSCI 377 at UMass(58)
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 02/06/15
CMPSCI 377 Operating Systems Fall 2005 Lecture 5 Septenqber 29 Lecturer Emery Berger Scribe Pavel Sapozhnikav Ryan Flaherty 51 THREADS What are threads To answer this question well take a look at the term granularityl o Coarsegrained gravel o Finegrained sand Thus threads are sand while processes are gravell Which means threads are always less than processes and one process may contain many threads We can also look at the differences between Processes and Threadsl PROCESSES consist of Control address space resources while THREADS consists of Control onlyl C API 0 Process forkO 0 Thread pthreadcreate So threads are easier to maintain than processes because there is less book keeping to do We also want to look at how OS implement threadsl OS implements threads at 0 User level User level threads require no context switching and they use thread library to manage threadsi They are also more exible than Kernel threadsi User level threads can also use multiple scheduling algorithms So why would we not want to use User level threads 7 Cooperative threadsThings just ran No Quanta 7 OS knows about processes not threads User threads calling lO halts the process Multiple threads on one process dont get more time 51 52 Lecture 5 September 29 o Kernel Kernel threads are being scheduled by OS and are lightweight threads Kernel threads require context switch which is very expensive By context switch we mean that we need to save PC registers and stack pointers However there is no work that needs to be done with TLB Virtual Memory Kernel threads can be extended to multiple processors which earlier systems didn t support Sun So at some point Sun came up with this really fast Hybrid model which mapped User level threads onto lightweight processes However this model was too hard for the developers to understand so they didn t develop it Disadvantage of Hybrid model 0 1 big disadvantage 99 percent of programmers are stupid 0 Load Balancing Spread out threads So there are two classic ways of implementing Load Balancing 7 Work Sharing Waste of time Giving excess work away This is a waste of time because you have to go around asking people if they can receive the work 7 Work Stealing Work Stealing means get work from someone else only ifl am out of work This is the Optimal approach This is the real deal you can t get any better than that 52 SCHEDULING There are two types of scheduling o longterm 7 how many jobs do you run at once 0 shortterm 7 how does OS select program from ready queue to execute 7 Kernel runs scheduler on interupt when process is created In the shortterm there is Nonpreemptive and Preemptive systems 0 Nonpreempt ive 7 Don7t use anymore 7 Scheduler can t do anything while a process is running 0 Preemptive 7 May interrupt a running process lmportant Metrics Lecture 5 September 29 53 0 Utilization percent of time that the CPU is busy 7 might be jobs that do not use CPU and you will 7starve7 them Throughput processes completing divided by time 7 not many jobs that complete on their own 7 serializing will maximize throughput 7 time slicing hurts throughput 0 Response Time time between ready and next 10 7 serializing makes for a horrible response time 7 time slicing makes for good response time but has alot of context switching Waiting Time time processes spend in ready state 7 time slicing drops waiting time Schedulers these days must be able to handle multiple cores and multiple CPUs Each CPU gets its own queuei If there is only one queue there will be contentioni There is also CPU Af nity7 where a process can ask for a speci c CPU each time it runs OS principle 0 use past behavior as a predicter of future behavior 7 works well for spinning downsaving power 0 recent past recent future 0 longterm past longterm future Scheduling issues 0 Conflicting goals cannot optimize all criteria simultaneously 0 Want to 7 Max CPU utilization and throughput 7 Min waiting time and response time You must choose according to the system type Interactive or Services Scheduling Interactive Systems 0 Want to minimize response time 7 500 ms is the threshold 0 Want to minimize rariance of response time 7 if a process takes unusually long the use gets upset 54 Lecture 5 September 29 Scheduling Servers 0 Want to maximize throughput 0 Want to minimize OS overhead and context switching Scheduling Algorithm FCFS rst come rst serve aka FIFO In the early versions the jobs did not give up the CPU even for lO Now we can assume the jobs will give up the CPU lst example 0 B wait time 0 o C wait time l o A wait time 3 2nd example 0 A wait time 0 o B wait time 4 o C wait time 5 3rd example 0 A wait time 0 o B wait time l o C wait time 5 The advantage of FCFS is that it is simple The disadvatages of FCFS is that the average wait time is highly variable It may also lead to poor overlap of lO and CPU
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'