Limited Direct Execution

Slides:



Advertisements
Similar presentations
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Advertisements

Memory Protection: Kernel and User Address Spaces  Background  Address binding  How memory protection is achieved.
Chapter 6 Limited Direct Execution
CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
A. Frank - P. Weisberg Operating Systems Process Scheduling and Switching.
CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Dr. Mohamed Hefeeda.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
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.
OS Spring’03 Introduction Operating Systems Spring 2003.
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
1 Last Class: Introduction Operating system = interface between user & architecture Importance of OS OS history: Change is only constant User-level Applications.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Threads CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
OS Spring’04 Introduction Operating Systems Spring 2004.
1 OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features.
Protection and the Kernel: Mode, Space, and Context.
80386DX.
CSC 501 Lecture 2: Processes. Process Process is a running program a program in execution an “instantiation” of a program Program is a bunch of instructions.
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.
Chapter 2: Computer-System Structures 2.1 Computer System Operation 2.5 Hardware Protection 2.6 Network Structure.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Scheduling Lecture 6. What is Scheduling? An O/S often has many pending tasks. –Threads, async callbacks, device input. The order may matter. –Policy,
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
1 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.
Lecture Topics: 10/29 Architectural support for operating systems –timers –kernel mode –system calls –protected instructions.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
Concurrency, Processes, and System calls Benefits and issues of concurrency The basic concept of process System calls.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
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.
Chapter 6 Limited Direct Execution Chien-Chung Shen CIS/UD
Virtualizing the CPU: Processes 1. How to provide the illusion of many CPUs? CPU virtualizing – The OS can promote the illusion that many virtual CPUs.
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
Chapter 2: Computer-System Structures
Virtualization Virtualize hardware resources through abstraction CPU
Memory Protection: Kernel and User Address Spaces
CS 6560: Operating Systems Design
Mechanism: Address Translation
Mechanism: Limited Direct Execution
Day 08 Processes.
Day 09 Processes.
Memory Protection: Kernel and User Address Spaces
Memory Protection: Kernel and User Address Spaces
Memory Protection: Kernel and User Address Spaces
Computer-System Architecture
Module 2: Computer-System Structures
Lecture Topics: 11/1 General Operating System Concepts Processes
Architectural Support for OS
Operating Systems Lecture 3.
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
CSE 451: Operating Systems Winter 2007 Module 2 Architectural Support for Operating Systems Brian Bershad 562 Allen Center 1.
Computer System Structures
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
CS333 Intro to Operating Systems
Architectural Support for OS
Chapter 2: Computer-System Structures
Chapter 2: Computer-System Structures
Module 2: Computer-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
Mechanism: Address Translation
Memory Protection: Kernel and User Address Spaces
Lecture Topics: 11/20 HW 7 What happens on a memory reference Traps
Presentation transcript:

Limited Direct Execution Operating Systems CS 550 Spring 2017 Kenneth Chiu

How to virtualize a CPU? How can we achieve virtualization of a CPU so that each process has the illusion that itself has the entire CPU? Time-sharing (or time-multiplexing) the CPU: run one process for a little while, then run another one, and so forth.

Challenges of time-sharing a CPU Performance How can we implement virtualization without adding excessive overhead to the system? Control How can we run processes efficiently while retaining control over the CPU? Attaining performance while maintaining control is thus one of the central challenges in building an operating system.

Direct execution protocol (without limits) Essential idea: to run the program directly on the CPU. OS Program Create entry for process list Allocate memory for program Load program into memory Set up stack with argc/argv Clear registers Execute call main() Run main() Execute return from main Free memory of process Remove from process list Problem: There is no mechanism to prevent the program from running forever and take over the machine.

Switching Between Processes Switching between processes (i.e., a context switch) should be simple. The OS should just decide to stop one process and start another. What’s the big deal? If the OS is not running (CPU is running the user processes), how can it do anything at all? How can the operating system regain control of the CPU so that it can switch between processes?

The cooperative approach Assumption: the OS trusts the processes of the system to behave reasonably. Processes that run for too long are assumed to periodically give up the CPU so that the OS can decide to run some other task. Scenarios where user processes give up the CPU Most processes transfer control of the CPU to the OS quite frequently by making system calls. Processes also transfer control to the OS when they do something illegal. Systems using the cooperative approach Systems often include an explicit yield system call, which does nothing except to transfer control to the OS so it can run other processes.

The non-cooperative approach How can the OS gain control of the CPU even if processes are not being cooperative? Short answer: relying on the timer interrupts

Limited direct execution protocol – timer interrupt OS kernel Hardware Program Initialize trap table during boot time Start interrupt timer start timer interrupt CPU in X ms Process A … Timer interrupt Save regs(A) to k-stack(A) Move to kernel mode Jump to trap handler Handle the trap Call switch() routine save regs(A) to proc-struct(A) restore regs(B) from proc-struct(B) switch to k-stack(B) return-from-trap (into B) restore regs(B) from k-stack(B) move to user mode jump to B’s PC Process B … - Restore regs from kernel stack - Move to user mode - Jump to main

Concurrent traps/interrupts You may be wondering … What happens when, during a system call, a timer interrupt occurs? What happens when you’re handling one interrupt and another one happens? Possible solutions: Disable interrupts during a interrupt processing. Sophisticated locking schemes to protect concurrent access to internal data structures. This enables multiple activities to be on-going within the kernel at the same time. Will be covered when discussing concurrency issues Nested Of course, the OS has to be careful in doing so; disabling interrupts for too long could lead to lost interrupts, which is (in technical terms) bad.