Chapter 6 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

Chapter 15 Address Translation Chien-Chung Shen CIS, UD
CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
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.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
OS Spring’03 Introduction Operating Systems Spring 2003.
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?
Process Description and Control A process is sometimes called a task, it is a program in execution.
OS Spring’04 Introduction Operating Systems Spring 2004.
1 OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features.
1 CSC 2405: Computer Systems II Spring 2012 Dr. Tom Way.
1 CS503: Operating Systems Part 1: OS Interface Dongyan Xu Department of Computer Science Purdue University.
Introduction to Embedded Systems
Protection and the Kernel: Mode, Space, and Context.
CS533 Concepts of Operating Systems Jonathan Walpole.
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.
Architecture Support for OS CSCI 444/544 Operating Systems Fall 2008.
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.
The Structure of Processes (Chap 6 in the book “The Design of the UNIX Operating System”)
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
The Stack This is a special data structure: –The first item to be placed into the stack will be the last item taken out. Two basic operations: –Push: Places.
Scheduling Lecture 6. What is Scheduling? An O/S often has many pending tasks. –Threads, async callbacks, device input. The order may matter. –Policy,
Chapter 2 Introduction to OS Chien-Chung Shen CIS, UD
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.
Operating System Structure A key concept of operating systems is multiprogramming. –Goal of multiprogramming is to efficiently utilize all of the computing.
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.
1.4 Hardware Review. CPU  Fetch-decode-execute cycle 1. Fetch 2. Bump PC 3. Decode 4. Determine operand addr (if necessary) 5. Fetch operand from memory.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
Concurrency, Processes, and System calls Benefits and issues of concurrency The basic concept of process System calls.
Lecture 26 Virtual Machine Monitors. Virtual Machines Goal: run an guest OS over an host OS Who has done this? Why might it be useful? Examples: Vmware,
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Managing Processors Jeff Chase Duke University. The story so far: protected CPU mode user mode kernel mode kernel “top half” kernel “bottom half” (interrupt.
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
Scheduler activations Landon Cox March 23, What is a process? Informal A program in execution Running code + things it can read/write Process ≠
1.1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 1: Introduction What Operating Systems Do √ Computer-System Organization.
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.
Introduction to Operating Systems Concepts
Introduction to Operating Systems
Limited Direct Execution
Operating Systems CMPSC 473
Anton Burtsev February, 2017
Protection of System Resources
Scheduler activations
Mechanism: Limited Direct Execution
Day 08 Processes.
Day 09 Processes.
Structure of Processes
Memory Protection: Kernel and User Address Spaces
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
CSE 153 Design of Operating Systems Winter 18
Lecture Topics: 11/1 General Operating System Concepts Processes
Architectural Support for OS
Chapter 10 And, Finally... The Stack
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
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.
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Architectural Support for OS
Presentation transcript:

Chapter 6 Limited Direct Execution Chien-Chung Shen CIS, UD cshen@cis.udel.edu

Virtualization Mechanism Virtualize CPU via time sharing Two challenges performance – with minimum overhead control – retain control of CPU attaining performance while maintaining control Need hardware support mode bit Technique: Limited Direct Execution

Direction Execution without Limits 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

Limited Direct Execution “Direct Execution” – run programs directly on CPU Two issues if we just run a program, how can OS make sure the program doesn’t do anything that we don’t want it to do, while still running it efficiently? when we are running a process, how does OS stop it from running and switch to another process (i.e., how does OS implement time sharing)? Without limits on running programs, the OS would not be in control of anything

#1 Restricted Operations Advantage of direct execution: fast - program runs natively on hardware CPU and thus executes as quickly as one would expect What if the process wishes to perform some kind of restricted operation (such as I/O request or memor allocation)? How to perform restricted operation? OS and H/W work together protected control transfer

Protected Control Transfer Hardware assists OS by providing different modes of execution mode bit user mode - applications do not have full access to hardware resources kernel mode - OS has access to the full resources of the machine special instructions to trap into the kernel and return-from-trap back to user-mode programs instructions that allow OS to tell the hardware where the trap table resides in memory

System Calls Allow kernel to carefully expose certain key pieces of functionalities (access files, create process, IPC, etc.) to user programs trap instruction jump into kernel and raise privilege level to kernel mode push PC/SP onto per-process kernel stack return-from-trap instruction pop PC/SP off stack return to calling program and reduce privilege level to user mode Setup trap table (interrupt vector) at boot time

Limited Direct Execution OS @ boot (kernel mode) Hardware initialize trap table remember address of syscall handler OS @ run (kernel mode) Hardware Program (user mode) Create entry for process list Allocate memory for program Load program into memory Setup user stack with argv Fill kernel stack with reg/PC return-from-trap restore regs from kernel stack move to user mode jump to main Run main() ... Call system call trap into OS save regs to kernel stack move to kernel mode jump to trap handler Handle trap Do work of syscall jump to PC after trap return from main (via exit() ) Free memory of process Remove from process list

#2 Switching between Processes If one process is running on CPU, OS is not running if OS is not running, how can it do anything at all? How can OS regain control of CPU so it can switch between processes? non-cooperative approach: OS takes control – need hardware support – timer interrupt – when interrupt raised, interrupt handler in OS runs cooperative approach - process gives up CPU periodically when making system calls (e.g., yield) or does something illegal (illegal memory access) – what about infinite loop?

Timer Interrupt At boot time, OS inform hardware of which code to run when (timer) interrupts occur OS starts the timer When interrupt occurs, hardware save the context (machine state) of the currently running process such that a subsequent return-from-trap instruction could resume its execution

Saving and Restoring Context OS regains control of CPU cooperatively via system call or forcefully via timer interrupt Scheduler decides who to run next Context switch save context – execute assembly code to save PC, general registers, kernel stack pointer of “currently-running” process restore context – restore registers, PC, and switch to the kernel stack of the soon-to-be-running process

Switching Stack Kernel enters switch code in the context of the interrupted process and returns in the context of the soon-to-be-executing process Two types of register saves/restores when timer interrupt occurs, user register state of running process is implicitly saved by hardware into kernel stack of that process when OS decides to switch from A to B, kernel register state is explicitly saved by software (i.e., OS) in memory in the process structure of the process moves the system from running as if it just trapped into the kernel from A to as if it just trapped into the kernel from B

Concurrency What happens when timer interrupt occurs during system call? What happens when interrupt occurs during the handling of an earlier interrupt? Two possible solutions disabling interrupts during interrupt processing locking to protect concurrent access to internal kernel data structures