Professional Documents
Culture Documents
Outcomes
2
managers and their functions Identify type of operating system Discuss the goals of process scheduling policies Determine time line for up to six different process scheduling algorithms
Operating System: Part of the computing system that manages all of the hardware and software Controls every file, every device, every section of main memory, and every nanosecond of processing time Controls who can use the system and how Computer system consists of: Software (programs) Hardware (the physical machine and its electronic components)
Objectives
4
Convenience
Making the computer easier to use Allowing better use of computer resources
Efficiency
Functions
5
Process Scheduling
OS determines which process should run at any given time Introducing a virtual memory Benefit
A
Memory Management
process can run in main memory without all instructions and data for that program present at main memory at one time Total memory space available to a program may exceed the actual main memory on the system
The OS masks the details of the hardware from the programmer and provides the programmer with a convenient interface for using the system
Program creation Program execution Access to I/O devices Controlled access to files System access Error detection and response Accounting
8 Illustrate the main resources that are managed by the OS. A portion of OS is in main memory. The remainder contains user program and data The allocation of this resource ( main memory) is controlled by the OS The OS decide when I/O device can be used by a program in execution, and control access to and use of files OS determine how much processor time is devoted to the execution of program
At top; User Command Interface users issue command to the OS User Command Interface is unique to each operating system
following tasks:
Monitor its resources continuously Enforce the policies that determine who gets what, when, and how much Allocate the resource when its appropriate Deallocate the resource when appropriate
Preserves the space in main memory occupied by the operating system Checks the validity of each request for memory space Sets up a table to keep track of who is using which section of memory in a multiuser environment Deallocates memory when the time comes to reclaim the memory
central processing unit (CPU) Keep track of the status of each process Processor Manager has two levels of responsibility:
Chooses the most efficient way to allocate all of the systems devices, printers, terminals, disk drives, based on a scheduling policy Makes the allocation, starts its operation Deallocates the device
including data files, assemblers, compilers, and application programs Responsibilities include:
Enforces restrictions on who has access to which files by using predetermined access Controls what users are allowed to do with files once they access them Allocates the resource by opening the file and deallocates it by closing the file
fifth essential manager called the Network Manager Network Manager provides a convenient way for users to share resources while controlling users access to them. The resources include:
Hardware (such as CPUs, memory areas, printers, tape drives, modems, and disk drives) Software (such as compilers, application programs, and data files)
Machine Hardware
18
Memory chips Input/output devices Storage devices Central processing unit (CPU)
computer ( through keyboard/ display) to request the execution of the job Batch user program is batched together with programs from other users and submitted by a computer operator. After the program is completed. Results are printed out for the user Single program (Uni-programming)- works only one program at a time Multi-programming (Multi-tasking) made to keep the processor as busy as possible; ( when 1 program waiting for I/O, another can use the CPU )
Single Program
22
Scheduling
25
Key to multi-programming
Determines which jobs will get the CPU, when, and for how long Decides when processing should be interrupted Determines which queues the job should be moved to during its execution Recognizes when a job has concluded and should be terminated
Finite number of resources (e.g., disk drives, printers, and tape drives) Some resources cant be shared once theyre allocated (e.g., printers) Some resources require operator intervention (e.g., tape drives)
A good process scheduling policy should Maximize throughput by running as many jobs as
Minimize response time by quickly turning around interactive requests Minimize turnaround time by moving entire jobs in and out of system quickly Minimize waiting time by moving jobs out of READY queue as quickly as possible
(continued):
Maximize CPU efficiency by keeping CPU busy 100 percent of time Ensure fairness for all jobs by giving every one an equal amount of CPU and I/O time
Builds up READY queue & empties I/O queues Creates an unacceptable imbalance in the system
Suspends all activity on the currently running job Reschedules it into the READY queue
processing of a job and transfers the CPU to another job without external interrupts
First Come, First Served (FCFS) Shortest Job Next (SJN) Priority Scheduling Shortest Remaining Time (SRT) Round Robin Multiple Level Queues
First-Come, First-Served
32
earlier they arrive, the sooner theyre served Simple algorithm to implement: uses a FIFO queue Good for batch systems; unacceptable for interactive systems Turnaround time is unpredictable
Jobs arrival sequence: A, B, C Job A has a CPU cycle of 15 milliseconds Job B has a CPU cycle of 2 milliseconds Job C has a CPU cycle of 1 millisecond
Average turnaround time: 16.67 s Figure 4.5: Timeline for job sequence A, B, C using the FCFS algorithm
Jobs arrival sequence: C, B, A Job A has a CPU cycle of 15 milliseconds Job B has a CPU cycle of 2 milliseconds Job C has a CPU cycle of 1 millisecond
Average turnaround time: 7.3 s Figure 4.6: Timeline for job sequence C, B, A using the FCFS algorithm
Nonpreemptive Handles jobs based on length of their CPU cycle time Easiest to implement in batch environments Doesnt work in interactive systems Optimal only when all jobs are available at same time
Four batch jobs A, B, C, D, all in the READY queue Job: A B C D CPU cycle: 5 2 6 4
Average turnaround time: 9 s Figure 4.7: Timeline for job sequence B, D, A, C using the SJN algorithm
Preemptive version of the SJN algorithm Processor allocated to job closest to completion Current job can be preempted if newer job in READY queue has shorter time to completion Cannot be implemented in interactive system Requires advance knowledge of the CPU time required to finish each job SRT involves more overhead than SJN OS monitors CPU time for all jobs in READY queue and performs context switching
0 1 2 3 A B C D 6 3 1 4
Figure 4.8: Timeline for job sequence A, B, C, D using the preemptive SRT algorithm
0 1 2 3 A B C D 6 3 1 4
Figure 4.9: Timeline for job sequence A, B, C, D using the nonpreemptive SJN algorithm
Priority Scheduling
40
Programs with highest priority are processed first Not interrupted until CPU cycles are completed or a natural wait occurs
priority in READY queue System administrator or Processor Manager use different methods of assigning priorities
Round Robin
41
Preemptive Used extensively in interactive systems Based on a predetermined slice of time (time
quantum) thats given to each job Size of time quantum crucial to system performance
Figure 4.10: Timeline for job sequence A, B, C, D using the preemptive round robin algorithm
Job is preempted and put at the end of the READY queue and its information is saved in its PCB
If job is finished, all resources allocated to it are released & completed job is returned to user If interrupted by I/O request, then info is saved in PCB & it is linked at end of the appropriate I/O queue Once I/O request is satisfied, job returns to end of READY queue to await allocation of CPU
Figure 4.11: Context switches for job A with three different time quantums. In (a) the job finishes before the time quantum expires. In (b) and (c), the time quantum expires first, interrupting the job.
relation to the average CPU cycle If the quantum is too large - larger than most CPU cycles
Algorithm reduces to the FCFS scheme Amount of context switching slows down the execution of the jobs Amount of overhead is dramatically increased
quantum:
Should be long enough to allow 80% of CPU cycles to run to completion Should be at least 100 times longer than the time required to perform one context switch