This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Monday, April 6 Project #1 Credit Distribution Agreement (hardcopy) Individual review documents due by endofclass today BarCamp Credit due today before 5:00 pm Submit at http://engr.oregonstate.edu/teach before midnight tonight Hardcopy or email attachment Presenters: hand in documentation of your presentation Attendees: hand in hardcopy of a summary of sessions attended Monday, April 6 Project #2 Will be posted soon MUCH more difficult than Project #1 Due Sunday, April 19 (2 weeks) Homework #1 is posted Discussion in class Friday Today's topics Processes (Chapters 3, 4 in Love text) States Management Introduction to process scheduling Processes (user view) Process a program in execution Program instructions Program data Libraries Processes (system view) Process a unit of work within the system Process needs resources to accomplish its task Process termination requires OS to reclaim any reusable resources CPU, memory, I/O, files Initialization data Etc. Processes (developer view) Process an environment* in which a "program" executes. *Environment has context information: Instruction segment (the program) User data segment System data segment System stack segment Various tables, bookkeeping info, etc. Process state Only one process may be in the running state on any one CPU at any given time Many processes may be ready or waiting. The maximum number of processes that can be in the running state simultaneously is equal to the number of CPUs. Process State As a process executes, it changes state Terminology varies among OS's new: The process is being created. running: Instructions are being executed. waiting: The process is waiting for some event to occur. ready: The process is waiting to be assigned to a CPU. terminated: The process has finished execution. State change When a process state changes from running to waiting or ready all of the system information for that process is saved When a process state changes from waiting or ready to running IP, registers, etc. Switching the CPU from one process to another is called a context switch process is restored according to saved system information linux Process States TASK_RUNNING: TASK_INTERRUPTIBLE, TASK_UNINTERRUPTIBLE: running TASK_ZOMBIE, TASK_STOPPED: new, waiting, ready terminated Managing multiple processes System usually has many processes running concurrently on one or more CPUs OS must manage processes to User processes OS processes Implement fair sharing of the system resources Keep the CPU busy Concurrency Concurrency is implemented by multiplexing the CPUs among the processes / threads Jobs are selected and executed via job scheduling (to implement fairness) When a job has to wait (e.g., for I/O), OS switches another job into the CPU (to keep the CPU busy) A subset of all jobs in system is kept in memory Concurrency: multiple processors vs. simulation True concurrent processing with multiple processors Simulated concurrent processing on one What happens to the idle processes? OS must manage all processes Management is implemented using several scheduling queues determine how CPU time is shared among processes calculate CPU timeslice (CPU burst) for each process determine where to hold an idle process select an idle process to execute when the CPU becomes available Process Scheduling Queues Job queue set of all processes in the system. Ready queue set of all processes residing in main memory that are ready to be assigned to a CPU. Device queues set of processes waiting for a device (e.g., I/O), one queue per device. Other waiting queues processes waiting for another communication or interrupt. Various configurations possible How does the CPU become available? Once a process is assigned to a CPU, it runs until one of the following occurs: Its CPU timeslice (CPU burst) expires back to the ready queue The process creates a child process that must be completed before continuing The process issues an interrupt request child goes to ready queue parent process goes to special wait queue assigned to one of several special wait queues back to the ready queue after completing request.
I/O, device, interrupt, etc. The process is terminated Example Process Scheduling Queues Maximize CPU utilization Scheduling Criteria Maximize throughput keep the CPU as busy as possible # of processes that complete their execution per time unit amount of time to execute a particular process amount of time a process has been waiting in the ready queue amount of time it takes from when a request was submitted until the first response is produced Minimize turnaround time Minimize waiting time Minimize response time Scheduling should be "fair" Schedulers Longterm scheduler (or job scheduler) Shortterm scheduler (or CPU scheduler) selects which processes should be brought into the ready queue. selects which process should be executed next, determines CPU burst times, and allocates CPU. Longterm scheduler is invoked infrequently (seconds, minutes) Schedulers (Cont.) The longterm scheduler controls the degree of multiprogramming. may be slow. Number of processes actually in memory, being scheduled for CPU time Shortterm scheduler is invoked very frequently (milliseconds) must be fast. Concerns about "thrashing" Intermediate Term Scheduling Sometimes it makes sense to swap a partially executed process out to disk Virtual memory Make room for another process Reduce the degree of multiprogramming Bottlenecks Processes can be described as: many short CPU bursts. I/Obound process spends more time doing I/O than computations CPUbound process spends more time doing computations few long CPU bursts. Typically, algorithms are compared by the average waiting time for a given ordered set of processes. Process scheduling must be done by the CPU between chunks of "real work". The CPU is interrupted at a fixed rate to check scheduling. Scheduling Criteria Other Factors The scheduling tasks require CPU time. These tasks are overhead, but they take a relatively short time 10 to 100 ms. (quantum) Implication: There is a minimum timeslice (hardware dependent) 0.5 to 5 ms. (typically about 5% of quantum) Classical CPU Scheduling Algorithms FCFS SJF SRTF Priority (FirstCome, FirstServed) (Shortest Job First) (Shortest Remaining Time First) RoundRobin Preemptive Nonpreemptive Process Scheduling Examples Use Gantt Charts for comparison Assumptions for introductory examples: Disclaimer: All processes are CPUbound. There is no minimum timeslice. If a new process arrives at the same time that another process surrenders the CPU, the new process precedes the other process in the ready queue. For now ... we ignore scheduling overhead and contextswitching time The examples are unrealistic, but they illustrate concepts with simple calculations. FirstCome, FirstServed (FCFS)
Process CPU Burst Time P1 24 P2 P3 3 3 Suppose that the processes arrive in the order: The Gantt Chart for the schedule is:
P1 0 24 P2 27 P3 30 P1 , P2 , P3 . Waiting time for P1 = 0; P2 = 24; P3 = 27 Questions? Read Love Chapter 4 Do Homework#1 ...
View Full Document
This note was uploaded on 06/28/2009 for the course CS 411 taught by Professor Staff during the Spring '08 term at Oregon State.
- Spring '08
- Operating Systems