Operating Systems Engineering Based on MIT 6.828 (2012, lec3) Recitation 2: OS Organization.

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.
Memory Management Questions answered in this lecture: How do processes share memory? What is static relocation? What is dynamic relocation? What is segmentation?
OS Memory Addressing.
Chapter 6 Limited Direct Execution
CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
X86 segmentation, page tables, and interrupts 3/17/08 Frans Kaashoek MIT
Virtual Memory Virtual Memory Management in Mach Labels and Event Processes in Asbestos Ingar Arntzen.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
Introduction to Kernel
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.
Early OS security Overview by: Greg Morrisett Cornell University, Edited (by permission) for CSUS CSc250 by Bill Mitchell.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
1 CS503: Operating Systems Part 1: OS Interface Dongyan Xu Department of Computer Science Purdue University.
System Calls 1.
Protection and the Kernel: Mode, Space, and Context.
80386DX.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
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.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Background: Operating Systems Brad Karp UCL Computer Science CS GZ03 / M th November, 2008.
PA0 due 60 hours. Lecture 4 Memory Management OSTEP Virtualization CPU: illusion of private CPU RAM: illusion of private memory Concurrency Persistence.
Operating Systems Lecture November 2015© Copyright Virtual University of Pakistan 2 Agenda for Today Review of previous lecture Hardware (I/O, memory,
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 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Introduction to Operating Systems and Concurrency.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
Processes and Virtual Memory
Microprocessor system architectures – IA32 tasks Jakub Yaghob.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
12/2/091 What is an Operating System Andy Konwinski CS61CL Dec 2, 2009 Lecture 13 UCB CS61CL F09 Lec 13.
Protection of Processes Security and privacy of data is challenging currently. Protecting information – Not limited to hardware. – Depends on innovation.
What is a Process ? A program in execution.
OS Memory Addressing. Architecture CPU – Processing units – Caches – Interrupt controllers – MMU Memory Interconnect North bridge South bridge PCI, etc.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Memory Protection: Kernel and User Address Spaces Andy Wang Operating Systems COP 4610 / CGS 5765.
Introduction to Operating Systems Concepts
Computer System Structures
Computer Organization & Design 计算机组成与设计
CS 3214 Computer Systems Lecture 9 Godmar Back.
Introduction to Kernel
Introduction to Operating Systems
Operating Systems Engineering
Memory Protection: Kernel and User Address Spaces
Operating System Structure
CS490 Windows Internals Quiz 2 09/27/2013.
x86 segmentation, page tables, and interrupts
KERNEL ARCHITECTURE.
OS Virtualization.
Lecture 28: Virtual Memory-Address Translation
Memory Protection: Kernel and User Address Spaces
Introduction to Operating Systems
Memory Protection: Kernel and User Address Spaces
Memory Protection: Kernel and User Address Spaces
Operating Systems Lecture 3.
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
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.
Operating Systems: A Modern Perspective, Chapter 3
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Operating Systems Structure
Operating Systems Structure
Memory Protection: Kernel and User Address Spaces
Presentation transcript:

Operating Systems Engineering Based on MIT (2012, lec3) Recitation 2: OS Organization

Overall OS Design Two major aspects: What should the main components be? What should the interfaces look like? To answer that, we need to ask: Why have an OS at all? Why not a library?

OS Requirements One key requirement: Support for multiple activities Concurrent or at least Pseudo-Concurrent Which requires: Resource multiplexing Activity isolation Interaction between activities

Overall OS Design Helpful approach – use abstractions Disk  File system Network card  Sockets CPU and Memory  Processes Not all OS designs are created equal

Focus on xv6 An educational OS based on UNIX V6 only a few abstractions \ services Processes File system I/O (via file descriptors)

xv6 – Processes A process is a running program A process can have: A Share of the CPU Private memory File descriptors Parent process Child processes …

xv6 – Processes Uses resources through kernel services File system Memory allocations Interaction with other processes … Kernel is contacted via system calls Very traditional design

xv6 – A Monolithic Kernel Kernel is a big program Contains all services, low level hardware mechanisms Entire kernel runs with full privileges Good side – easy subsystem interactions Bad sides – complex interactions  bugs no isolation in the kernel

Sidestep – Kernel Types A monolithic kernel is but one option What has to be in the kernel? Could FS be a user library? Why? Why not? There are models for smaller kernels Microkernel Exokernel Nonkernel

Isolation The most constraining requirement Determines much of the base design xv6’s unit of isolation – a process

xv6 – Process Isolation Prevent process X from spying on Y Prevent process X from corrupting Y Separated memory, file descriptors Prevent resource exhaustion (fairness) Protect kernel from processes Defensive tactic Against buggy programs Against malicious programs

xv6 – Isolation Mechanisms User/Kernel mode flag System call abstraction Address spaces Timeslicing

User/Kernel Mode Flag Called CPL in x86 Bottom two bits of the cs register CPL=0 – kernel mode – privileged CPL=3 – user mode – not privileged cs:CPL

User/Kernel Mode Flag CPL is the base to almost every isolation Writes to control registers (cs, for instance) Writes to certain flags Memory access I/O Port access However, setting CPL=3 is not enough Kernel needs to manage policy

System calls Call from user to kernel – needs to change CPL Can this be done? set CPL=0 jmp sys_open User defined! How about a combined instruction that forces the user to jump to a kernel address?

System calls - x86 solution Kernel sets allowed entry points int instruction sets CPL=0 and jumps Saves the values of cs and eip on stack System call returns with iret Restores old cs and eip Should these instructions be privileged?

Address spaces How can we isolate process memory? Use of x86 paging hardware MMU maps addresses: virtual to physical On instruction fetchs On data load and store No direct access to physical addresses

x86 Page Tables Basically, an array of entries, each maps a 4KB range of “virtual” addresses Each such 4KB region is a page Kernel switches page tables when switching processes Supervisor bit protects kernel

Hardware Support for Isolation Q: Can you have process isolation without HW support for kernel mode? A: Yes, but using HW support is relatively easy and the most popular approach

Timeslicing Still need to isolate the CPU Processes might be uncooperative Non-yielding infinite loop HW provides a periodic clock interrupt Same mechanism as system calls Enables preemptive context switching Kernel needs to save state – seamless to processes Has its problems, but extremely popular