Operating Systems CSE 411 Multi-processor Operating Systems Multi-processor Operating Systems Dec. 8 2006 - Lecture 30 Instructor: Bhuvan Urgaonkar.

Slides:



Advertisements
Similar presentations
Chapter 6: Process Synchronization
Advertisements

Background Concurrent access to shared data can lead to inconsistencies Maintaining data consistency among cooperating processes is critical What is wrong.
Process Synchronization. Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores.
Bilgisayar Mühendisliği Bölümü GYTE - Bilgisayar Mühendisliği Bölümü Multithreading the SunOS Kernel J. R. Eykholt, S. R. Kleiman, S. Barton, R. Faulkner,
Cache Coherent Distributed Shared Memory. Motivations Small processor count –SMP machines –Single shared memory with multiple processors interconnected.
IT Systems Multiprocessor System EN230-1 Justin Champion C208 –
Review: Chapters 1 – Chapter 1: OS is a layer between user and hardware to make life easier for user and use hardware efficiently Control program.
CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
Threads Irfan Khan Myo Thein What Are Threads ? a light, fine, string like length of material made up of two or more fibers or strands of spun cotton,
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Dr. Mohamed Hefeeda.
1 Multiprocessors. 2 Idea: create powerful computers by connecting many smaller ones good news: works for timesharing (better than supercomputer) bad.
Architectural Support for Operating Systems. Announcements Most office hours are finalized Assignments up every Wednesday, due next week CS 415 section.
Processes 1 CS502 Spring 2006 Processes Week 2 – CS 502.
CS533 Concepts of Operating Systems Class 7 Integrated Task and Stack Management.
1 Last Class: Introduction Operating system = interface between user & architecture Importance of OS OS history: Change is only constant User-level Applications.
Operating Systems CS208. What is Operating System? It is a program. It is the first piece of software to run after the system boots. It coordinates the.
CPS110: Implementing threads/locks on a uni-processor Landon Cox.
PRASHANTHI NARAYAN NETTEM.
1 Lecture 20: Protocols and Synchronization Topics: distributed shared-memory multiprocessors, synchronization (Sections )
1 OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features.
Operating Systems CSE 411 CPU Management Oct Lecture 13 Instructor: Bhuvan Urgaonkar.
Operating Systems CSE 411 CPU Management Sept Lecture 11 Instructor: Bhuvan Urgaonkar.
CPU Scheduling - Multicore. Reading Silberschatz et al: Chapter 5.5.
Computer System Architectures Computer System Software
Operating System A program that controls the execution of application programs An interface between applications and hardware 1.
Operating Systems CMPSC 473 Threads September 16, Lecture 7 Instructor: Bhuvan Urgaonkar.
Multiple Processor Systems. Multiprocessor Systems Continuous need for faster and powerful computers –shared memory model ( access nsec) –message passing.
Cosc 4740 Chapter 6, Part 3 Process Synchronization.
Fast Multi-Threading on Shared Memory Multi-Processors Joseph Cordina B.Sc. Computer Science and Physics Year IV.
Concurrency, Mutual Exclusion and Synchronization.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS-Related Hardware.
Processes and Threads Processes have two characteristics: – Resource ownership - process includes a virtual address space to hold the process image – Scheduling/execution.
ECE200 – Computer Organization Chapter 9 – Multiprocessors.
Operating Systems CSE 411 Kernel synchronization, deadlocks Kernel synchronization, deadlocks Dec Lecture 31 Instructor: Bhuvan Urgaonkar.
Computers Operating System Essentials. Operating Systems PROGRAM HARDWARE OPERATING SYSTEM.
Computer Science Lecture 7, page 1 CS677: Distributed OS Multiprocessor Scheduling Will consider only shared memory multiprocessor Salient features: –One.
Kernel Locking Techniques by Robert Love presented by Scott Price.
Operating Systems CSE 411 Introduction and Overview Sept Lecture 2 Instructor: Bhuvan Urgaonkar.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
Processes & Threads Introduction to Operating Systems: Module 5.
Operating Systems CSE 411 CPU Management Dec Lecture Instructor: Bhuvan Urgaonkar.
1 Lecture 1: Computer System Structures We go over the aspects of computer architecture relevant to OS design  overview  input and output (I/O) organization.
1 Lecture 19: Scalable Protocols & Synch Topics: coherence protocols for distributed shared-memory multiprocessors and synchronization (Sections )
Operating Systems CSE 411 Revision and final thoughts Revision and final thoughts Dec Lecture 33 Instructor: Bhuvan Urgaonkar.
Kernel Synchronization in Linux Uni-processor and Multi-processor Environment By Kathryn Bean and Wafa’ Jaffal (Group A3)
Chapter 4 Threads, SMP, and Microkernels Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E.
Chapter 11 System Performance Enhancement. Basic Operation of a Computer l Program is loaded into memory l Instruction is fetched from memory l Operands.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Tutorial 2: Homework 1 and Project 1
Operating Systems CMPSC 473
Sarah Diesburg Operating Systems COP 4610
Lecture 18: Coherence and Synchronization
Lecture 21: Synchronization and Consistency
Lecture 2 Part 2 Process Synchronization
Multithreaded Programming
Concurrency: Mutual Exclusion and Process Synchronization
Lecture 25: Multiprocessors
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 153 Design of Operating Systems Winter 19
Lecture 24: Multiprocessors
Chapter 6: Synchronization Tools
Chapter 2 Operating System Overview
Lecture 19: Coherence and Synchronization
Operating System Overview
Lecture 18: Coherence and Synchronization
Sarah Diesburg Operating Systems CS 3430
Presentation transcript:

Operating Systems CSE 411 Multi-processor Operating Systems Multi-processor Operating Systems Dec Lecture 30 Instructor: Bhuvan Urgaonkar

Grading Concerns Exam 1 distribution –80+ –70+ –60+ –50+ –40+ –40- Exam 2 distribution –80+ : 4 –70+ : 5 –60+ : 9 –50+ : 18 –40+ : 17 –40- : 7 Performance on homeworks/quizzes/projects has been much better than on exams Project 3 will be made easier More time for Project 2 Last quiz to replace homework 5 –Will be long and comprehensive –Will help you prepare for the final exam A, A- B+, B B-, C+ C, C-, …

Multi-processor Computers Asymmetric –Master processor runs the kernel –Other processors run user code Symmetric –Each server is self-scheduling Single run queue or per -processor run queue –Scheduling and synchronization more complex

Overview of Symmetric Multiprocessor (SMP) More CPUs: more processing power but more contention for the bus RAM CPU 0 CPU 1 HW cache

Hardware features of Modern SMPs Common memory –All CPUs connected to a common bus –Hardware circuit called memory arbiter inserted between the bus and each RAM chip Serializes accesses to memory Actually there is an arbiter even in uni-processors –Why: Remember DMA? Hardware support for cache synchronization –Contents of the cache and memory maintain their consistency at the hardware level just as in a uni-processor –Cache snooping: Whenever a CPU modifies its cache, it must check if the same data is contained in another cache, and if so, notify it of the update Note: Implemented in hardware, not of concern to the kernel

Hardware features of Modern SMPs (contd.) Distributed Interrupt Processing –Being able to deliver interrupt to any CPU crucial to exploit the parallelism of the SMP architecture –Special hardware for routing interrupts to the right processors –Interprocessor interrupts Used fot TLB consistency among other things

OS Issues for SMP How should the CPU scheduler work? How should synchronization work?

CPU Scheduling in a Multi-processor Kernel and user code can now run on N processors –A multi-threaded process may span multiple CPUs Uni-processor: Scheduler picks a process to run Multi-processor: Scheduler picks a process and the CPU on which it will run A process may move from one CPU to another during its lifetime Two main factors affecting scheduler design –Cache affinity: Would like to run a process on the same CPU –Load balancing: Would like to keep all CPUs equally busy –These are often at odds with each other: Why?

Proportional Fair Scheduling in SMPs What will happen if we have two threads with weights 1 and 10 and a Lottery scheduler on a dual-processor? Not all combinations of weights are feasible! Given k threads with weights w1, …, wk, and p processors, can you think of a feasibility criterion?

Symmetric Multi-threading Idea: Create multiple virtual processors on a physical processor –Illusion provided by hardware –Called hyper-threading in Intel machines –The OS sees the machine as an SMP –Each virtual processor has its own set of registers and interrupt handling, cache is shared Why: Possibility of better parallelism, better utilization How does it concern the OS? –From a correctness point of view: it does not –From an efficiency point of view: the scheduler could exploit it to do better load balancing

Synchronization in SMPs

Synchronization building blocks: Atomic Instructions An atomic instruction for a uni-processor would not be atomic on an SMP unless special care is taken –In particular, any atomic instruction needs to write to a memoy location –Recall TestAndSet, Swap Need special support from the hardware –Hardware needs to ensure that when a CPU writes to a memory location as part of an atomic instruction, another CPU can not write the same memory location till the first CPU is finished with its write Given above hardware support, OS support for synchronization of user processes same as in uni-processors –Semaphores, monitors Kernel synchronization raises some special considerations –Both in uni- and multi-processors

Kernel synchronization

Interlude: Back to the past: A little background (mostly revision) Recall: A kernel is a “server” that answers requests issued in two possible ways –A process causes an exception (E.g., page fault, system call) –An external device sends an interrupt Definition: Kernel Control Path –The set of instructions executed in the kernel mode to handle a kernel request –Similar to a process, except much more rudimentary No descriptor of any kind –Most modern kernels are “re-entrant” => Multiple KCPs may be executing simultaneously Synchronization problems can occur if two KCPs update the same data –How to synchronize KCP access to shared data/resources?

How to synchronize KCP access to shared data? Can use semaphores or monitors Not the best solution in multi-processors Consider two KCPs running on different CPUs –If the time to update a shared data structure is very short, then semaphores may be an overkill Solution: Spin Locks –Do busy wait instead of getting blocked! –The kernel programmer must decide when to use spin locks versus semaphores –Spin locks are useless in uni-processors: Why?

Two other mechanisms for easy to achieve kernel synchronization Non-preemptible kernel design –A KCP can not be pre-empted by another one Useful only certain KCPs, such as those that have no synch. issues with interrupt handlers –Not enough for multi-processors since multiple CPUs can concurrently access the same data structure –Adopted by many Oses including versions of Linux upto 2.4 –Linux 2.6 is pre-emptible: faster dispatch times for user processes Interrupt disabling –Disable all hardware interrupts before entering a critical section and re-enable them right after leaving it –Works for uni-processor in certain situations The critical section should not incur an exception whose handler has synchronization issues with it The CS should not get blocked –What if the CS incurs a page fault? –Does not work for multi-processors Interrupts must be