Chapter 2 The OS, the Computer, and User Programs Copyright © 2008.

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

Computer System Overview
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
Chapter 5 Processes and Threads Copyright © 2008.
OS2-1 Chapter 2 Computer System Structures. OS2-2 Outlines Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
6-1 I/O Methods I/O – Transfer of data between memory of the system and the I/O device Most devices operate asynchronously from the CPU Most methods involve.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Computer System Overview
1 Process Description and Control Chapter 3. 2 Process Management—Fundamental task of an OS The OS is responsible for: Allocation of resources to processes.
OS Spring’03 Introduction Operating Systems Spring 2003.
Abhinav Kamra Computer Science, Columbia University 2.1 Operating System Concepts Silberschatz, Galvin and Gagne  2002 Chapter 2: Computer-System Structures.
Computer System Overview
Chapter 7 Interupts DMA Channels Context Switching.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
1 Last Class: Introduction Operating system = interface between user & architecture Importance of OS OS history: Change is only constant User-level Applications.
Operating Systems Béat Hirsbrunner Main Reference: William Stallings, Operating Systems: Internals and Design Principles, 6 th Edition, Prentice Hall 2009.
OS and the Computer System  Some OS programs exist permanently in the system area of the memory to monitor and control activities in the computer system.
OS Spring’04 Introduction Operating Systems Spring 2004.
Chapter 1: IntroductionDhamdhere: Operating Systems— A Concept-Based Approach Slide No: 1 Copyright ©2005 Overview of Operating Systems Chapters 1 and.
1 OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features.
1 Computer System Overview Chapter 1 Review of basic hardware concepts.
General System Architecture and I/O.  I/O devices and the CPU can execute concurrently.  Each device controller is in charge of a particular device.
Computer Systems Overview. Page 2 W. Stallings: Operating Systems: Internals and Design, ©2001 Operating System Exploits the hardware resources of one.
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.
2.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 2: Computer-System Structures Computer System Operation I/O Structure.
CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 2: Computer-System Structures Computer System Operation I/O Structure.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Chapter 2: Computer-System Structures
1 CSE Department MAITSandeep Tayal Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
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.
Operating Systems and Networks AE4B33OSS Introduction.
1 Chapter 2: Computer-System Structures  Computer System Operation  I/O Structure  Storage Structure  Storage Hierarchy  Hardware Protection  General.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Operating System Structure A key concept of operating systems is multiprogramming. –Goal of multiprogramming is to efficiently utilize all of the computing.
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.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
Concurrency, Processes, and System calls Benefits and issues of concurrency The basic concept of process System calls.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 2: Computer-System Structures Computer System Architecture and Operation.
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.
Review of Computer System Organization. Computer Startup For a computer to start running when it is first powered up, it needs to execute an initial program.
Computer Systems Overview. Lecture 1/Page 2AE4B33OSS W. Stallings: Operating Systems: Internals and Design, ©2001 Operating System Exploits the hardware.
1 Computer System Overview Chapter 1. 2 Operating System Exploits the hardware resources of one or more processors Provides a set of services to system.
Introduction to Operating Systems Concepts
Chapter 2: Computer-System Structures(Hardware)
Chapter 2: Computer-System Structures
Modeling Page Replacement Algorithms
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Computer System Overview
Computer-System Architecture
Module 2: Computer-System Structures
Modeling Page Replacement Algorithms
Architectural Support for OS
Module 2: Computer-System Structures
Computer System Overview
Chapter 1 Computer System Overview
Architectural Support for OS
Chapter 2: Computer-System Structures
Chapter 2: Computer-System Structures
Module 2: Computer-System Structures
Module 2: Computer-System Structures
Presentation transcript:

Chapter 2 The OS, the Computer, and User Programs Copyright © 2008

Operating Systems, by Dhananjay Dhamdhere Copyright © Introduction Fundamental Principles of OS Operation The Computer OS Interaction with the Computer and User Programs

Operating Systems, by Dhananjay Dhamdhere Copyright © Fundamental Principles of OS Operation The kernel of the OS is the collection of routines that form the core of the operating system –Implements control functions –Set of services to user programs –Exists in memory during operation of the OS An interrupt diverts the CPU to execution of the kernel code A software interrupt is used by programs to communicate their requests to the kernel

Operating Systems, by Dhananjay Dhamdhere Copyright © Fundamental Principles of OS Operation (continued) CPU has two modes of operation: –Kernel mode CPU can execute all instructions Kernel operates with CPU in this mode so that it can control computer operations –User mode CPU cannot execute instructions that could interfere with other programs or with the OS if used indiscriminately CPU is put in this mode to execute user programs

Operating Systems, by Dhananjay Dhamdhere Copyright © The Computer

Operating Systems, by Dhananjay Dhamdhere Copyright © The Computer (continued) The CPU Memory Management Unit (MMU) Memory Hierarchy Input/Output Interrupts

Operating Systems, by Dhananjay Dhamdhere Copyright © The CPU Two features of the CPU are visible to user programs or the OS: –General-purpose registers (GPRs) Also called program-accessible registers Hold data, addresses, index values, or the stack pointer during execution of a program –Control registers Contain information that controls or influences operation of the CPU Set of control registers is called the program status word (PSW)

Operating Systems, by Dhananjay Dhamdhere Copyright ©

Operating Systems, by Dhananjay Dhamdhere Copyright © The CPU (continued) CPU can operate in two modes: –Kernel mode Can execute privileged instructions OS puts CPU in kernel mode when it is executing instructions in the kernel –User mode Cannot execute privileged instructions OS puts CPU in user mode while executing user programs Mode (M) field of PSW contains 0 if CPU is in privileged mode and 1 if it is in user mode

Operating Systems, by Dhananjay Dhamdhere Copyright © State of the CPU GPRs and PSW contain the information needed to know what the CPU is doing –State of the CPU Kernel saves state of CPU when it takes away the CPU from program –When program is to be resumed, it reloads the saved CPU state into GPRs and PSW

Operating Systems, by Dhananjay Dhamdhere Copyright © Example 2.1: State of the CPU (Contd)

Operating Systems, by Dhananjay Dhamdhere Copyright © Memory Management Unit (MMU) Virtual memory is an illusion of memory that may be larger than the real memory of a computer –Implemented using noncontiguous memory allocation and the MMU CPU passes the address of data or instruction used in an instruction to MMU –It is called the logical addresses MMU translates logical address to physical address

Operating Systems, by Dhananjay Dhamdhere Copyright © Memory hierarchy The memory hierarchy provides a large and fast memory, at a low cost –It is an arrangement of several memories with different access speeds and sizes The CPU accesses only the fastest memory; i.e., the cache If a required byte is not present in the memory being accessed, it is loaded there from a slower memory

Operating Systems, by Dhananjay Dhamdhere Copyright ©

Operating Systems, by Dhananjay Dhamdhere Copyright © Memory Hierarchy (continued) When CPU performs a cache lookup, a cache hit or miss may occur –Hit ratio (h) of the cache is the fraction of bytes accessed by the CPU that score a hit in the cache t ema = h × t cache + (1 – h) × (t tra + t cache ) = t cache + (1 – h) × t tra where t ema = effective memory access time, t cache = access time of cache, and t tra = time taken to transfer a cache block from memory to cache.

Operating Systems, by Dhananjay Dhamdhere Copyright © Memory Hierarchy (continued) Operation of memory is analogous to operation of a cache –Blocks of bytes (pages) are transferred from disk to memory or from memory to disk –But, Memory management and transfer of blocks between memory and disk are performed by SW In the cache, the transfer is performed by HW Memory hierarchy comprising MMU, memory, and the disk is called the virtual memory

Operating Systems, by Dhananjay Dhamdhere Copyright © Memory Hierarchy (continued) Memory protection is implemented by checking whether a memory address used by a program lies outside the memory area allocated to it –Control registers used: base and size (also called limit) –Address of first byte = –Address of last byte = + – 1

Operating Systems, by Dhananjay Dhamdhere Copyright © Example 2.2: Basics of Memory Protection interrupt Execution of Load instruction causes protection violation

Operating Systems, by Dhananjay Dhamdhere Copyright © Input/Output

Operating Systems, by Dhananjay Dhamdhere Copyright © Interrupts An event is a situation that requires OS’s attention –Designer associates an interrupt with each event Purpose is to report occurrence of the event to OS and enable it to perform event handling actions Interrupt action saves CPU state and loads new contents into the PSW and GPRs –CPU starts executing instructions of an interrupt servicing routine (ISR) in the kernel

Operating Systems, by Dhananjay Dhamdhere Copyright © Interrupts (continued)

Operating Systems, by Dhananjay Dhamdhere Copyright ©

Operating Systems, by Dhananjay Dhamdhere Copyright © OS Interaction with the Computer and User Programs OS interacts with the computer to –know information about events, so that it can service them –restore CPU state to resume a program after servicing an interrupt Programs need to use services of the OS for purposes such as initiating an I/O operation –The method to cause an interrupt and pass requirement to the OS is known as a System call Will learn about: –Controlling Execution of Programs –Interrupt Servicing –System Calls

Operating Systems, by Dhananjay Dhamdhere Copyright © Controlling Execution of Programs 1.When user program starts, PSW should contain: a.Program counter (PC) field b.Mode (M) field, set to user mode (1) c.Memory protection information (MPI) field contains start address in memory and size of program d.Interrupt mask (IM) field, set to enable interrupts 2.When program is interrupted, CPU state (PSW and GPRs) are saved Program table or process control block (PCB) 3.When program is resumed, its CPU state is restored

Operating Systems, by Dhananjay Dhamdhere Copyright © Interrupt Servicing Context save saves CPU state of the program The scheduler selects a a program for execution

Operating Systems, by Dhananjay Dhamdhere Copyright © Interrupt Servicing (continued)

Operating Systems, by Dhananjay Dhamdhere Copyright © Interrupt Servicing (continued) Two approaches for nested interrupt servicing: –Disable nested interrupts through masking –Handle nested interrupts─preemptible kernel

Operating Systems, by Dhananjay Dhamdhere Copyright © System Calls

Operating Systems, by Dhananjay Dhamdhere Copyright © Example 2.4: System Call in a Hypothetical OS CPU provides the SI instruction to cause a software interrupt OS provides system call for obtaining current time –Code is 78: Instruction SI 78 causes a SW interrupt 78 is entered in IC field of PSW before it is saved Interrupt vector for program contains aaa in PC –CPU is switched to routine with start address aaa –It finds that IC is 78 and determines that program needs time of day Time is returned to program in a standard location, typically a data register

Operating Systems, by Dhananjay Dhamdhere Copyright © System Calls (continued)

Operating Systems, by Dhananjay Dhamdhere Copyright © Summary An interrupt is a special signal sent to CPU to indicate occurrence of an event –It transfers control to the OS –A system call is a SW interrupt A program uses it to request OS services CPU’s control registers govern its functioning –Program status word (PSW) is the collection of these OS kernel saves CPU state when interrupt occurs –i.e., PSW and GPRs CPU has two modes of operation controlled by mode (M) field of PSW –User mode and kernel mode

Operating Systems, by Dhananjay Dhamdhere Copyright © Summary (continued) Memory hierarchy provides the same effect as a fast and large memory, at a low cost –Contains: A very fast and small cache memory A slower and larger RAM A disk Effective memory access time depends on cache hit ratio I/O system uses direct memory access (DMA) to permit CPU and I/O system to operate independently