Lecture 2 Page 1 CS 111 Summer 2015 I/O, Modularity and Virtualization CS 111 Operating System Principles Peter Reiher.

Slides:



Advertisements
Similar presentations
Interactive lesson about operating system
Advertisements

Lecture 13 Page 1 CS 111 Online File Systems: Introduction CS 111 On-Line MS Program Operating Systems Peter Reiher.
WHAT IS AN OPERATING SYSTEM? An interface between users and hardware - an environment "architecture ” Allows convenient usage; hides the tedious stuff.
Lecture 12 Page 1 CS 111 Online Devices and Device Drivers CS 111 On-Line MS Program Operating Systems Peter Reiher.
CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
OS2-1 Chapter 2 Computer System Structures. OS2-2 Outlines Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Dr. Mohamed Hefeeda.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
1: Operating Systems Overview
CS 104 Introduction to Computer Science and Graphics Problems Operating Systems (4) File Management & Input/Out Systems 10/14/2008 Yang Song (Prepared.
OPERATING SYSTEM OVERVIEW
OS Spring’03 Introduction Operating Systems Spring 2003.
Chapter 7 Interupts DMA Channels Context Switching.
1 Today I/O Systems Storage. 2 I/O Devices Many different kinds of I/O devices Software that controls them: device drivers.
OS Spring’04 Introduction Operating Systems Spring 2004.
Secondary Storage Management Hank Levy. 8/7/20152 Secondary Storage • Secondary Storage is usually: –anything outside of “primary memory” –storage that.
Disk and I/O Management
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower.
LOGO OPERATING SYSTEM Dalia AL-Dabbagh
Operating System Review September 10, 2012Introduction to Computer Security ©2004 Matt Bishop Slide #1-1.
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Chapter 1 Computer System Overview Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William.
Lecture 4 Page 1 CS 111 Spring 2015 Modularity and Virtualization CS 111 Operating Systems Peter Reiher.
Composition and Evolution of Operating Systems Introduction to Operating Systems: Module 2.
CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment.
2: Computer-System Structures
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.
IT253: Computer Organization
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Lecture 3 Page 1 CS 111 Online Disk Drives An especially important and complex form of I/O device Still the primary method of providing stable storage.
1: Operating Systems Overview 1 Jerry Breecher Fall, 2004 CLARK UNIVERSITY CS215 OPERATING SYSTEMS OVERVIEW.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
Chapter 13 – I/O Systems (Pgs ). Devices  Two conflicting properties A. Growing uniformity in interfaces (both h/w and s/w): e.g., USB, TWAIN.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
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.
Assoc. Prof. Dr. Ahmet Turan ÖZCERİT.  What Operating Systems Do  Computer-System Organization  Computer-System Architecture  Operating-System Structure.
Lecture 4 Page 1 CS 111 Online Modularity and Virtualization CS 111 On-Line MS Program Operating Systems Peter Reiher.
IT3002 Computer Architecture
Processor Memory Processor-memory bus I/O Device Bus Adapter I/O Device I/O Device Bus Adapter I/O Device I/O Device Expansion bus I/O Bus.
Lecture 2 Page 1 CS 111 Summer 2013 Hardware, Modularity, and Virtualization CS 111 Operating System Principles Peter Reiher.
بسم الله الرحمن الرحيم MEMORY AND I/O.
Lecture 2 Page 1 CS 111 Summer 2014 Hardware, Modularity, and Virtualization CS 111 Operating System Principles Peter Reiher.
Device Management Mark Stanovich Operating Systems COP 4610.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Lecture 4 Page 1 CS 111 Online Modularity and Memory Clearly, programs must have access to memory We need abstractions that give them the required access.
Lecture 4 Page 1 CS 111 Summer 2013 Scheduling CS 111 Operating Systems Peter Reiher.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Modularity Most useful abstractions an OS wants to offer can’t be directly realized by hardware Modularity is one technique the OS uses to provide better.
Operating System Structure
Swapping Segmented paging allows us to have non-contiguous allocations
Modularity and Memory Clearly, programs must have access to memory
Module 2: Computer-System Structures
Lecture Topics: 11/1 General Operating System Concepts Processes
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
Secondary Storage Management Brian Bershad
Chapter 2: Operating-System Structures
Module 2: Computer-System Structures
Secondary Storage Management Hank Levy
Module 2: Computer-System Structures
Chapter 2: Operating-System Structures
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Module 2: Computer-System Structures
Chapter 13: I/O Systems.
Presentation transcript:

Lecture 2 Page 1 CS 111 Summer 2015 I/O, Modularity and Virtualization CS 111 Operating System Principles Peter Reiher

Lecture 2 Page 2 CS 111 Summer 2015 Outline The role of I/O in operating systems Organizing systems via modularity Virtualization and operating systems

Lecture 2 Page 3 CS 111 Summer 2015 I/O Architecture I/O is: – Varied – Complex – Error prone Bad place for the user to be wandering around The operating system must make I/O friendlier Oriented around handling many different devices via busses using device drivers

Lecture 2 Page 4 CS 111 Summer 2015 Sequential vs. Random Access Devices Sequential access devices – Byte/block N must be read/written before byte/block N+1 – May be read/write once, or may be rewindable – Examples: magnetic tape, printer, keyboard Random access devices – Possible to directly request any desired byte/block – Getting to that byte/block may or may not be instantaneous – Examples: memory, magnetic disk, graphics adaptor They are used very differently – Requiring different handling by the OS

Lecture 2 Page 5 CS 111 Summer 2015 Busses Something has to hook together the components of a computer – The CPU, memory, various devices Allowing data to flow between them That is a bus A type of communication link abstraction

Lecture 2 Page 6 CS 111 Summer 2015 A Simple Bus main bus controller device CPU memory control address data interrupts

Lecture 2 Page 7 CS 111 Summer 2015 Devices and Controllers Device controllers connect a device to a bus – Communicate control operations to device – Relay status information back to the bus, manage DMA, generate device interrupts Device controllers export registers to the bus – Writing into registers controls device or sends data – Reading from registers obtains data/status Register access method varies with CPU type – May use special instructions (e.g., x86 IN/OUT) – May be mapped onto bus just like memory

Lecture 2 Page 8 CS 111 Summer 2015 Direct Polled I/O Method of accessing devices via direct CPU control – CPU transfers data to/from device controller registers – Transfers are typically one byte or word at a time – May be accomplished with normal or I/O instructions CPU polls device until it is ready for data transfer – Received data is available to be read – Previously initiated write operations are completed +Very easy to implement (both hardware and software) −CPU intensive, wastes CPU cycles on I/O control −Leaves devices idle waiting for CPU when other tasks running

Lecture 2 Page 9 CS 111 Summer 2015 Direct Memory Access Essentially, use the bus without CPU control – Move data between memory and device controller Bus facilitates data flow in all directions between: – CPU, memory, and device controllers CPU can be the bus-master – Initiating data transfers with memory, device controllers But device controllers can also master the bus – CPU instructs controller what transfer is desired – Device controller does transfer w/o CPU assistance – Device controller generates interrupt at end of transfer Interrupts tell CPU when DMA is done

Lecture 2 Page 10 CS 111 Summer 2015 Memory Issues Different types of memory handled in different ways Cache memory usually handled mostly by hardware – Often OS not involved at all RAM requires very special handling – To be discussed in detail later Disks and flash drives treated as devices – But often with extra OS support

Lecture 2 Page 11 CS 111 Summer 2015 Disk Drives An especially important and complex form of I/O device – Gradually being replaced by SSDs Still the primary method of providing stable storage – Storage meant to last beyond a single power cycle of the computer A place where physics meets computer science – Somewhat uncomfortably

Lecture 2 Page 12 CS 111 Summer 2015 Some Important Disk Characteristics Disks are random access devices (mostly...) – With complex usage, performance, and scheduling Key OS services depend on disk I/O – Program loading, file I/O, paging – Disk performance drives overall performance Disk I/O operations are subject to overhead – Higher overhead means fewer operations/second – Careful scheduling can reduce overhead – Clever scheduling can improve throughput, delay

Lecture 2 Page 13 CS 111 Summer 2015 Disk Drives – A Physical View

Lecture 2 Page 14 CS 111 Summer 2015 Disk Drives – A Logical View cylinder (10 corresponding tracks) platter surface track sectors

Lecture 2 Page 15 CS 111 Summer 2015 Seek Time At any moment, the heads are over some track – All heads move together, so all over the same track on different surfaces If you want to read another track, you must move the heads The time required to do that is seek time Seek time is not constant – Amount of time to move from one track to another depends on start and destination – Usually reported as an average

Lecture 2 Page 16 CS 111 Summer 2015 Rotational Delay Once you have the heads over the right track, you need to get them to the right sector The head is over only one sector at a time If it isn’t the right sector, you have to wait for the disk to rotate over that one Like seek time, not a constant – Depends on which sector you’re over – And which sector you’re looking for – Also usually reported as an average Also called latency

Lecture 2 Page 17 CS 111 Summer 2015 Transfer Time Once you’re on the correct track and the head’s over the right sector, you need to transfer data You don’t read/write an entire sector at a time There is some delay associated with reading every byte in the sector All sectors are usually the same size So transfer time is usually constant

Lecture 2 Page 18 CS 111 Summer 2015 Disk Drives and Controllers The disk drive is not directly connected to the bus It is connected to a disk drive controller – Special hardware designed for this task There may be several disk drives attached to the same controller – Which then multiplexes its attention between them Many disks have their controller bundled with them (e.g., SCSI disks)

Lecture 2 Page 19 CS 111 Summer 2015 Why Is This An Issue For the OS? When you go to disk, it could be fast or slow – If you go to disk a lot, that matters The OS can make choices that make it faster or slower – Deciding where to put a piece of data on disk – Deciding when to perform an I/O – Reordering multiple I/Os to minimize seek time and latency – Perhaps optimistically performing I/Os that haven’t been requested

Lecture 2 Page 20 CS 111 Summer 2015 Optimizing Disk I/O Don't start I/O until disk is on-cylinder or near sector – I/O ties up the controller, locking out other operations – Other drives seek while one drive is doing I/O Minimize head motion – Do all possible reads in current cylinder before moving – Make minimum number of trips in small increments Encourage efficient data requests – Have lots of requests to choose from – Encourage cylinder locality – Encourage largest possible block sizes – All by OS design choices, not influencing programs/users

Lecture 2 Page 21 CS 111 Summer 2015 Algorithms to Control Head Movement First come, first served – Just do them in the order they happen Shortest seek time first – Always go with the request that’s closest to the current head position – Since requests keep arriving, can cause starvation Scan/Look (AKA the Elevator Algorithm) – Service all requests in one direction, then go in the other direction – No starvation, but may take longer

Lecture 2 Page 22 CS 111 Summer 2015 Head Travel With Various Algorithms Scan/Look (elevator algorithm) total head motion: 450 cylinders First Come First Served total head motion: 880 cylinders Shortest Seek First total head motion: 321 cylinders

Lecture 2 Page 23 CS 111 Summer 2015 Modularity Most useful abstractions an OS wants to offer can’t be directly realized by hardware Modularity is one technique the OS uses to provide better abstractions Divide up the overall system you want into well-defined communicating pieces Critical issues: – Which pieces to treat as modules – How to organize the modules – Interfaces to modules

Lecture 2 Page 24 CS 111 Summer 2015 What Does An OS Do? At minimum, it enables one to run applications – Preferably several on the same machine – Preferably several at the same time At abstract level, what do we need to do that? – Interpreters (to run the code) – Memory (to store the code and data) – Communications links (to communicate between apps and pieces of the system) This suggests the kinds of modules we’ll need

Lecture 2 Page 25 CS 111 Summer 2015 Starting Simple We want to run multiple programs – Without interference between them – Protecting one from the faults of another We’ve got a multicore processor to do so – More cores than programs We have RAM, a bus, a disk, other simple devices What abstractions should we build to ensure that things go well?

Lecture 2 Page 26 CS 111 Summer 2015 A Simple System Processor 1 Processor 2 Processor 3 Processor 4 Program 1 Program 2 Program 3 Program 4 Memory Disk Network A machine boundary

Lecture 2 Page 27 CS 111 Summer 2015 Exploiting Modularity We’ll obviously have several SW elements to support the different user programs Desirable for each to be modular and self- contained – With controlled interactions Gives cleaner organization Easier to prevent problems from spreading Easier to understand what’s going on Easier to control each program’s behavior

Lecture 2 Page 28 CS 111 Summer 2015 Subroutine Modularity Why not just organize the system as a set of subroutines? – All in the same address space A simplifying assumption Allowing easy in-memory communication System subroutines call user program subroutines as needed – And vice versa Soft modularity

Lecture 2 Page 29 CS 111 Summer 2015 How Would This Work? Each program is a self-contained set of subroutines – Subroutines in the program call each other – But not subroutines in other programs Shared services offered by other subroutines – Which any program can call Perhaps some “master routine” that calls subroutines in the various programs Soft because no OS HW/SW enforces modularity – Important resources (like the stack) are shared – Only proper program behavior protects one program from the mistakes of another

Lecture 2 Page 30 CS 111 Summer 2015 Illustrating the Problem Processor 1 Processor 2 Processor 3 Processor 4 Program 1 Program 2 Program 3 Program 4 Memory Disk Network Stack for Program 1 Stack for Program 4 Stack for Program 2 Stack for Program 3 Now Program 4 is in trouble Even though it did nothing wrong itself

Lecture 2 Page 31 CS 111 Summer 2015 Hardening the Modularity Processor 1 Processor 2 Processor 3 Processor 4 Program 1 Program 2 Program 3 Program 4 Memory 1 Memory 2 Memory 3 Memory 4 Four separate machines Perhaps in very different places Each program has its own machine

Lecture 2 Page 32 CS 111 Summer 2015 System Services In This Model Some activities are local to each program Other services are intended to be shared – Like a file system This functionality can be provided by a client/server model The system services are provided by the server The user programs are clients The client sends message to server to get help OS uses HW/SW to enforce boundaries

Lecture 2 Page 33 CS 111 Summer 2015 Benefits of Hard Modularity With hard modularity, something beyond good behavior enforces module boundaries Here, the physical boundaries of the machine A client machine literally cannot touch the memory of the server – Or of another client machine No error or attack can change that – Though flaws in the server can cause problems Provides stronger guarantees all around

Lecture 2 Page 34 CS 111 Summer 2015 Downsides of Hard Modularity The hard boundaries prevent low-cost optimizations In client/server organizations, doing anything with another program requires messages – Inherently more expensive than memory accesses If the boundary sits between components requiring fast interactions, possibly very bad Must either give programs pieces of resources or time multiplex use of resources – More complexity to do this right

Lecture 2 Page 35 CS 111 Summer 2015 Virtualization Provide the illusion of a complete resource to each program that uses it – Hide hard modularity’s time/space divisions Possible to provide an entire virtual machine per process Use shared hardware to instantiate the various virtual devices or machines System software (i.e., the operating system) and perhaps special hardware handle it

Lecture 2 Page 36 CS 111 Summer 2015 The Virtualization Concept Program 1 Processor Memory Disk Network Program 2 Program 3 Program 4 Virtual machines A single physical machine

Lecture 2 Page 37 CS 111 Summer 2015 The Trick in Virtualization All the virtual machines share the same physical hardware But each thinks it has its own machine Must be sure that one virtual machine doesn’t affect behavior of the others – Intentionally or accidentally With the least possible performance penalty – Given that there will be a penalty merely for sharing at all

Lecture 2 Page 38 CS 111 Summer 2015 Performance and Virtualization To achieve good performance, can’t run many instructions “virtualized” – Most instructions must go directly to the processor – Rather than be mapped into multiple instructions via virtualization Similarly for access to other HW – Can’t afford to put lots of virtualization SW in the usual path The trick is to virtualize the minimal set of accesses

Lecture 2 Page 39 CS 111 Summer 2015 Abstractions for Virtualizing Computers Some kind of interpreter abstraction – A thread Some kind of communications abstraction – Bounded buffers Some kind of memory abstraction – Virtual memory For a virtualized architecture, the operating system provides these kinds of abstractions

Lecture 2 Page 40 CS 111 Summer 2015 Threads Encapsulates the state of a running computation So what does it need? – Something that describes what computation is to be performed – Something that describes where it is in the computation – Something that maintains the state of the computation’s data

Lecture 2 Page 41 CS 111 Summer 2015 OS Handling of Threads One (or more) threads per running program The OS chooses which thread to run – To share a processor, the OS must be able to cleanly stop and start threads While one thread is using a processor, no other thread should interfere with its use To run a thread, OS must: – Load its code and data into memory – Set up HW control structures (e.g., the PC) – Transfer control to the thread

Lecture 2 Page 42 CS 111 Summer 2015 Time Slicing Virtualization Processor Memory Disk Network Program 1 Program 2 Program 3 Program 4 Processor Memory Disk Network Processor Memory Disk Network

Lecture 2 Page 43 CS 111 Summer 2015 Wait a Minute...? How does the OS do all that? It’s just a program itself – With its own interpreter, memory, etc. It must use the same physical resources as all the other threads Basically, the OS itself is a thread It creates and manages other threads Using privileged supervisor mode to safely and temporarily break virtualization boundaries

Lecture 2 Page 44 CS 111 Summer 2015 The OS and Virtualization Processor Memory Disk Network Program 1 Program 2 Program 3 Program 4 Operating System

Lecture 2 Page 45 CS 111 Summer 2015 Providing Contained Environments What must a thread manager control to keep each thread isolated from the others? Well, what can each thread do? – Run instructions Make sure it can only run its own – Access some memory Make sure it can only access its own – Communicate to other threads Make sure communication uses a safe abstraction

Lecture 2 Page 46 CS 111 Summer 2015 What Does This Boil Down To? Running threads have access to certain processor registers – Program counter, stack pointer, others – Thread manager must ensure those are all set correctly Running threads have access to some or all pieces of physical memory – Thread manager must ensure that a thread can only touch its own physical memory Running threads can request services (like communications) – Thread manager must provide safe access to those services

Lecture 2 Page 47 CS 111 Summer 2015 Setting Up a User-Level VM Processor Memory Disk Network Program 1 Program 2 Program 3 Program 4 Operating System PC SP Status info

Lecture 2 Page 48 CS 111 Summer 2015 Protecting Threads Normal threads usually run in user mode Which means they can’t touch certain things – In particular, each others’ stuff For certain kinds of resources, that’s a problem – What if two processes both legitimately need to write to the screen? – Do we allow unrestricted writing and hope for the best? – Don’t allow them to write at all? Instead, trap to supervisor mode

Lecture 2 Page 49 CS 111 Summer 2015 Trapping to Supervisor Mode To allow a program safe access to shared resources The trap goes to trusted code – Not under control of the program And performs well-defined actions – In ways that are safe E.g., program not allowed to write to the screen directly – But traps to OS code that writes it safely

Lecture 2 Page 50 CS 111 Summer 2015 Modularity and Memory Clearly, programs must have access to memory We need abstractions that give them the required access – But with appropriate safety What we’ve really got (typically) is RAM RAM is pretty nice – But it has few built-in protections So we want an abstraction that provides RAM with safety

Lecture 2 Page 51 CS 111 Summer 2015 What’s the Safety Issue? We have multiple threads running Each requires some memory Modern architectures typically have one big pool of RAM How can we share the same pool of RAM among multiple processes? – Giving each what it needs – Not allowing any to harm the others

Lecture 2 Page 52 CS 111 Summer 2015 Domains A simple memory abstraction Give each process access to some range of the physical memory – Its domain – Different domain for each process Allow process to read/write/execute memory in its domain And not touch any memory outside its domain

Lecture 2 Page 53 CS 111 Summer 2015 Mapping Domains Program 1 Program 2 Program 3 Program 4 Processor Memory Disk Network Every process gets its own piece of memory No process can interfere with other processes’ memory

Lecture 2 Page 54 CS 111 Summer 2015 What Do Domains Require? Threads will issue instructions – Perhaps using arbitrary memory addresses Only honor addresses in the thread’s domain – Any other address should be caught as an error Hard modularity here requires HW support E.g., a domain register – Specifies the domain associated with the thread currently using the processor – By listing the low and high addresses that bound the domain

Lecture 2 Page 55 CS 111 Summer 2015 The Memory Manager Hardware or software that enforces the bounds of the domain register When thread reads or writes an address, memory manager checks the domain register If within bounds, do the memory operation If not, throw an illegal memory reference exception – Trapping to supervisor mode Only trusted code (i.e., the OS) can change the domain register

Lecture 2 Page 56 CS 111 Summer 2015 The Domain Register Concept Processor Memory Disk Network Program 1 Program 4 Domain Register All Program 1 references must be within these bounds All Program 4 references must be within these bounds Enforced by hardware

Lecture 2 Page 57 CS 111 Summer 2015 Multiple Domains Limiting a process to a single domain is not too convenient The concept is easy to extend – Simply allow multiple domains per process Obvious way to handle this is with multiple domain registers – One per allocated domain

Lecture 2 Page 58 CS 111 Summer 2015 The Multiple Domain Concept Program 1 Processor Memory Disk Network Domain Registers

Lecture 2 Page 59 CS 111 Summer 2015 Handling Multiple Domains Programs can request more domains – But the OS must set them up What does the program get to ask for? – A specific range of addresses? – Or a domain of a particular size? Latter is easier – What if requested set of addresses are already used by another program? – Memory manager can choose a range of addresses of requested size

Lecture 2 Page 60 CS 111 Summer 2015 Domains and Access Permissions One can typically do three types of things with a memory address – Read its contents – Write a new value to it – Execute an instruction located there System can provide useful effects if it does not allow all modes of use to all addresses Typically handled on a per-domain basis – E.g., read-only domains Requires extra bits in domain registers And other hardware support

Lecture 2 Page 61 CS 111 Summer 2015 What If Program Uses a Domain Improperly? E.g., it tries to write to a read-only domain A permission error exception – Different than an illegal memory reference exception But also handled by a similar mechanism Probably want it to be handled by somewhat different code in the OS Remember discussion of trap handling in previous lecture?

Lecture 2 Page 62 CS 111 Summer 2015 Do We Really Need to Switch Processes for OS Services? When we trap or make a request for a domain, must we change processes? – We lose context doing so Instead, run the OS code for the process – Which requires changing to supervisor mode – Context for process is still available But what about safety? – Use domain access modes to ensure safety We don’t do this for all OS services...

Lecture 2 Page 63 CS 111 Summer 2015 Domains in Kernel Mode Allow user threads to access certain privileged domains – Like code to handle hardware traps – Code must be in a user-accessible domain But can’t allow arbitrary access to those privileged domains A supervisor (AKA kernel) mode access bit is set on such domains – So thread only accesses them when in kernel mode

Lecture 2 Page 64 CS 111 Summer 2015 How Does a Thread Get to Kernel Mode? Can’t allow thread to arbitrarily put itself in kernel mode any time – Since it might do something unsafe Instead, allow entry to kernel mode only in specific ways – In particular, only at specific instructions – These are called gates – Typically implemented in hardware using instruction like SVC (supervisor call)