Operating System Review Part

Similar documents
Uniprocessor Scheduling. Chapter 9

Lecture Topics. Announcements. Today: Uniprocessor Scheduling (Stallings, chapter ) Next: Advanced Scheduling (Stallings, chapter

Chapter 5: CPU Scheduling

Last Class: Processes

Scheduling of processes

Preview. Process Scheduler. Process Scheduling Algorithms for Batch System. Process Scheduling Algorithms for Interactive System

1.1 CPU I/O Burst Cycle

Course Syllabus. Operating Systems

Scheduling. The Basics

CPU Scheduling. CSE 2431: Introduction to Operating Systems Reading: Chapter 6, [OSC] (except Sections )

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

Announcements. Program #1. Program #0. Reading. Is due at 9:00 AM on Thursday. Re-grade requests are due by Monday at 11:59:59 PM.

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Chapter 9. Uniprocessor Scheduling

CPU Scheduling. Rab Nawaz Jadoon. Assistant Professor DCS. Pakistan. COMSATS, Lahore. Department of Computer Science

Chap 7, 8: Scheduling. Dongkun Shin, SKKU

Properties of Processes

Chapter 6: CPU Scheduling

CPU Scheduling Algorithms

CSE120 Principles of Operating Systems. Prof Yuanyuan (YY) Zhou Scheduling

Operating Systems Comprehensive Exam. Spring Student ID # 3/20/2013

ALL the assignments (A1, A2, A3) and Projects (P0, P1, P2) we have done so far.

Operating Systems Comprehensive Exam. Fall Student ID # 10/31/2013

CPU Scheduling: Objectives

Uniprocessor Scheduling. Aim of Scheduling

Uniprocessor Scheduling. Aim of Scheduling. Types of Scheduling. Long-Term Scheduling. Chapter 9. Response time Throughput Processor efficiency

Chapter 9 Uniprocessor Scheduling

Lecture 5 / Chapter 6 (CPU Scheduling) Basic Concepts. Scheduling Criteria Scheduling Algorithms

Review. Preview. Three Level Scheduler. Scheduler. Process behavior. Effective CPU Scheduler is essential. Process Scheduling

CPU Scheduling. Operating Systems (Fall/Winter 2018) Yajin Zhou ( Zhejiang University

CS3733: Operating Systems

Announcements. Program #1. Reading. Due 2/15 at 5:00 pm. Finish scheduling Process Synchronization: Chapter 6 (8 th Ed) or Chapter 7 (6 th Ed)

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

Operating Systems. Lecture Process Scheduling. Golestan University. Hossein Momeni

Uniprocessor Scheduling

Uniprocessor Scheduling. Basic Concepts Scheduling Criteria Scheduling Algorithms. Three level scheduling

Chapter 5: CPU Scheduling. Operating System Concepts 8 th Edition,

Operating Systems. Scheduling

Frequently asked questions from the previous class survey

Chapter 5: CPU Scheduling

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

CPU Scheduling (1) CPU Scheduling (Topic 3) CPU Scheduling (2) CPU Scheduling (3) Resources fall into two classes:

Announcements. Reading. Project #1 due in 1 week at 5:00 pm Scheduling Chapter 6 (6 th ed) or Chapter 5 (8 th ed) CMSC 412 S14 (lect 5)

CPU Scheduling. Daniel Mosse. (Most slides are from Sherif Khattab and Silberschatz, Galvin and Gagne 2013)

Operating System Concepts Ch. 5: Scheduling

CSCE Operating Systems Scheduling. Qiang Zeng, Ph.D. Fall 2018

Unit 3 : Process Management

8: Scheduling. Scheduling. Mark Handley

CHAPTER 2: PROCESS MANAGEMENT

Techno India Batanagar Department of Computer Science & Engineering. Model Questions. Multiple Choice Questions:

Process Scheduling. Copyright : University of Illinois CS 241 Staff

Scheduling in the Supermarket

Operating Systems ECE344. Ding Yuan

CS370 Operating Systems

CS370 Operating Systems

Process- Concept &Process Scheduling OPERATING SYSTEMS

OPERATING SYSTEMS. UNIT II Sections A, B & D. An operating system executes a variety of programs:

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006

CSE 120 Principles of Operating Systems Spring 2017

Chapter 5 CPU scheduling

CMPS 111 Spring 2003 Midterm Exam May 8, Name: ID:

CSI3131 Final Exam Review

CS370 Operating Systems

CPU Scheduling. The scheduling problem: When do we make decision? - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s)

CSE 120. Fall Lecture 8: Scheduling and Deadlock. Keith Marzullo

Job Scheduling. CS170 Fall 2018

Frequently asked questions from the previous class survey

Operating Systems (1DT020 & 1TT802)

CPU Scheduling. The scheduling problem: When do we make decision? - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s)

CS370 Operating Systems

LECTURE 3:CPU SCHEDULING

Ch 4 : CPU scheduling

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

Lecture 2 Process Management

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

CSE 120 Principles of Operating Systems

CPU Scheduling. Schedulers. CPSC 313: Intro to Computer Systems. Intro to Scheduling. Schedulers in the OS

Today s class. Scheduling. Informationsteknologi. Tuesday, October 9, 2007 Computer Systems/Operating Systems - Class 14 1

Midterm Exam. October 20th, Thursday NSC

Scheduling. Scheduling. Scheduling. Scheduling Criteria. Priorities. Scheduling

Operating Systems Unit 3

Sample Questions. Amir H. Payberah. Amirkabir University of Technology (Tehran Polytechnic)

Operating Systems: Quiz2 December 15, Class: No. Name:

Chapter 5: Process Scheduling

Chapter 2 Processes and Threads. Interprocess Communication Race Conditions

3. CPU Scheduling. Operating System Concepts with Java 8th Edition Silberschatz, Galvin and Gagn

Advanced Operating Systems (CS 202) Scheduling (1)

Interactive Scheduling

Two Level Scheduling. Interactive Scheduling. Our Earlier Example. Round Robin Scheduling. Round Robin Schedule. Round Robin Schedule

Lecture 17: Threads and Scheduling. Thursday, 05 Nov 2009

CSc33200: Operating Systems, CS-CCNY, Fall 2003 Jinzhong Niu December 10, Review

COMP 3361: Operating Systems 1 Final Exam Winter 2009

Scheduling Bits & Pieces

CSE 153 Design of Operating Systems

Main Points of the Computer Organization and System Software Module

Operating Systems Comprehensive Exam. Spring Student ID # 2/17/2011

CPU Scheduling: Part I ( 5, SGG) Operating Systems. Autumn CS4023

Chapter 5: CPU Scheduling. Operating System Concepts Essentials 8 th Edition

Last class: Today: CPU Scheduling. CPU Scheduling Algorithms and Systems

B. V. Patel Institute of Business Management, Computer &Information Technology, UTU

Transcription:

Operating System Review Part CMSC 602 Operating Systems Ju Wang, 2003 Fall Virginia Commonwealth University

Review Outline Definition Memory Management Objective Paging Scheme Virtual Memory System and Replacement Algorithm CPU Scheduling Context Switching FCFI, SJF, and Other Schemes Scheduling in Linux Process Synchronization Critical Section Mutual Exclusion Deadlock

Definition of Operating Systems Operating system as an extended machine It hides low level hardware details from user, and provides an abstract view to programmer and end-user Hiding: CPU registers, Physical memory, disk block. Providing: Process, Virtual Address Space, File System. As an resource manager It provides efficient sharing of hardware resources among various tasks From application developer s point of view, the O.S is nothing but a bunch of services system call and a bunch of utility tools Programming languages: assembly, C/C++, FORTRAN... shell tools, system configuration tools...

Major Functions of Operating System

Layer Structure

Definition of Operating Systems Goals as resource manager Efficient utilization of resource How can we maintain 100% usage of CPU time? How to improve the throughput of a disk array disk scheduling. Short response or turn-around time can the system support 10,000 http users? Protection among users and system Accounting of usage QoS guaranteed scheduling of user tasks Real-time system, time critical mission. Media server, large scale video on demand services.

Interrupt Interrupt is an essential mean for O.S to perform its duty Hardware interrupt allow asynchronous operation among CPU and peripheral devices Process scheduling rely on the interrupt from system clock Interrupt must be handled: efficiently to minimize the system overhead, i.e., clock interruption routine is very compacted written in assembly codes correctly to avoid system halt and return to the right interruption point allow re-entry or not? It is the origin of mutual exclusion and many other problems.

DMA

Memory Management Objectives: Support large program High utilization of physical memory Support many programs Concurrently Secure sharing and protection Provide fast access using inexpensive memory Memory hierarchy

Memory Management: Virtual Memory Virtual memory: Physical memory is divided into pages of same size (usually 4 KB), to be assigned to processes on a need-to-use basis. allow programs to be executed without completely in memory Free programmers from concern of memory storage limitations. Virtual address: or logical address, a linear address space used inside the program. Physical address: the address put in the system bus to access the actual memory. Address translation Each virtual memory access actually take 2 bus cycles hardware support Translation Look-aside Buffer (similar to cache)

Memory Management: Paging Scheme

Memory Management: Page Allocation

Memory Management: Page Replacement

Memory Management: Replacement Algorithm Goal: keep working set in memory Random First-in, First-out (FIFO) not necessary perform good may suffer Baledy anomaly Least Recently Used (LRU) algorithm always page out pages that has not been used for the longest period of time an approximation of optimal algorithm

Baledy Anormaly

Memory Management: More Design Issues Minimize the number of page fault, because page fault is expensive (may cost 20k or more CPU cycles) How many pages should be allocated to a process? Equal vs. proportional allocation Global vs. local replacement: Thrashing: excessive amount of page faults. Working-set strategy: use timestamp to trace the usage of pages Page size: how large it should be? Trade-off: Small size reduce the waste of internal segmentation, but increase the size of page table and the number of page faults.

CPU SCHEDULING A Scheduler evaluate the set of processes in the ready list, select one of them, and assign it to a processor for execution. When a CPU scheduling occurs, we also referred it as context switching. The scheduler will Save the run-time context for the current process Load the run-time context of the process which is select to run? Jump to the last interrupted point of the loaded process

CPU SCHEDULING: Two processes, single CPU

CPU SCHEDULING maximize CPU utilization and allow CPU sharing (multiprogramming) Majority of the CPU-bursts last around 10 msec I/O usually take seconds or minutes to finish Performance measurement for scheduling algorithms: CPU utilization ratio, prefer a high ratio Turnaround time, the shorter, the better Average waiting time? Response time? Time sharing in Linux scheduler: a fixed time slice of 200ms to run.

SCHEDULER CLASSIFICATION Preemptive or non-preemptive scheduling criteria Uni-processor or multi-processor scheduling Real-time scheduling

CPU SCHEDULING ALGORITHMS: FIRST-COME, FIRST SERVED It is non-preemptive Starvation-free, but poor performance in term of average waiting time. Average queueing time may be long. What are the average queueing and residence times for this scenario? How do average queueing and residence times depend on ordering of these processes in the queue?

CPU SCHEDULING ALGORITHMS: SHORTEST JOB FIRST Optimal for minimizing average waiting time. Why? Can you prove it? Might result in starvation under certain situation. Two schemes: Non-preemptive: once assign a job to the CPU, this job will not be preempted until it finish. If a new process arrives with a shorter expected CPU burst than the remaining time of the current process, preempt. Due to the uncertain of job execution time, the length of CPU burst of a process is predicated based on previous history.

CPU SCHEDULING ALGORITHMS: SHORTEST JOB FIRST Predicting the time the process will use on its next schedule: t(n + 1) = w.t(n) + (1 w).t (n), here t(n + 1): is time of next burst t(n): is time of current burst. T (n): is average of all previous bursts W : is a weighting factor emphasizing current or previous bursts.

CPU SCHEDULING Algorithms: PRIORITY BASED SCHEDULING Assign each process a priority. Schedule highest priority first. All processes within same priority are FCFS. Priority may be determined by user or by some default mechanism. The system may determine the priority based on memory requirements, time limits, or other resource usage. Starvation occurs if a low priority process never runs. Solution: build aging into a variable priority. Delicate balance between giving favorable response for interactive jobs, but not starving batch jobs.

CPU SCHEDULING Algorithms: PREEMPTIVE ALGORITHMS The currently executing process might be forced to relinquish the CPU when a higher priority process is ready. Can be applied to both Shortest Job First or to Priority scheduling. On time sharing machines, this type of scheme is required because the CPU must be protected from a run-away low priority process. Give short jobs a higher priority perceived response time is thus better. What are average queueing and residence times? Compare with FCFS.

CPU SCHEDULING Algorithms: ROUND ROBIN Processor Sharing among, use a small quantum (10-100 ms) such that each process runs frequently. Use a timer to cause an interrupt after a predetermined time. Preempts if task exceeds its quantum. The preempted process is usually put at the end of ready queue if there are n processes in the ready queue and the time quantum is q, each process get an equal share (1/n) of CPU time, and no process wait more than (n 1.q time units between its run) Performance: q large, FIFO q small, could result in too much context switching, thus low performance.

CPU SCHEDULING Algorithms: MULTI-LEVEL QUEUES Each queue has its scheduling algorithm. Then some other algorithm (perhaps priority based) arbitrates between queues. Can use feedback to move between queues Method is complex but flexible. For example, could separate system processes, interactive, batch, favored, unfavored processes

CPU SCHEDULING EXAMPLE: BSD Unix Scheduling This scheduling policy was implemented in 4.3 BSD: The quantum time is set to 1 second Priority is computed with respect to process type and execution history. The equations governing their behavior are : CPUj(i) = CPUj(i-1)/2 Pj(i) = BASEj + CPU(i-1)/2 + NICEj, where NICEj is a user supplied value. Each second, the priorities are recomputed by the scheduler and a new scheduling decision is made

CPU SCHEDULING Algorithms: MULTIPLE PROCESSOR SCHEDULING: Different rules for homogeneous or heterogeneous processors. Load sharing in the distribution of work, such that all processors have an equal amount to do. Each processor can schedule from a common ready queue ( equal machines ) OR can use a master slave arrangement.

LINUX CPU SCHEDULING: uses a simple priority based scheduling algorithm distinguishes three classes of processes for scheduling purposes Real-time FIFO processes are the highest priority and not preemptable Real-time round robin processes are the same as Real-time FIFO thread except for its preemptibility Normal Timesharing processes have lower priority than the previous two

LINUX CPU SCHEDULING: Each process has scheduling priority and a quantum associated with it quantum is decremented by one as it runs Linux schedules processes via a GOODNESS algorithm, which chooses to run the process with highest goodness The algorithm does not scale well If the number of existing processes is very large, it is inefficient to recompute all dynamic priorities at once