OS Spring’04 Introduction Operating Systems Spring 2004.

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 3 Process Description and Control
Chapter 6 Limited Direct Execution
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
A. Frank - P. Weisberg Operating Systems Process Scheduling and Switching.
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
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.
Operating Systems CS208. What is Operating System? It is a program. It is the first piece of software to run after the system boots. It coordinates the.
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.
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Exceptions, Interrupts & Traps
Chapter 2 The OS, the Computer, and User Programs Copyright © 2008.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
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.
Protection and the Kernel: Mode, Space, and Context.
Chapter 3 Process Description and Control Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Chapter 3 Process Description and Control Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
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.
2.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 2: Computer-System Structures Computer System Operation I/O Structure.
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment.
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.
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 ECE344 Ashvin Goel ECE University of Toronto OS-Related Hardware.
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,
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.
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.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
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.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
WORKING OF SCHEDULER IN OS
Introduction to Operating Systems Concepts
CS 3214 Computer Systems Lecture 9 Godmar Back.
Operating Systems CMPSC 473
Intro to Processes CSSE 332 Operating Systems
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Computer-System Architecture
Module 2: Computer-System Structures
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Exceptions Control Flow
Architectural Support for OS
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
Module 2: Computer-System Structures
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.
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Architectural Support for OS
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
Presentation transcript:

OS Spring’04 Introduction Operating Systems Spring 2004

OS Spring’04 What is Operating System?  It is a program!  It is the first piece of software to run after boot  It coordinates the execution of all other software User programs  It provides various common services needed by users and applications

OS Spring’04 Today ’ s plan  Course overview, bibliography, administrative questions  Operating system functionality  Hardware support for the operating system

OS Spring’04 Course plan  Lectures: How to build an operating system Theoretical background  Exercises: How to use the computer/OS effectively

OS Spring’04 Bibliography  Notes by Dror Feitelson Will be published weekly  Operating System Concepts, by A. Silberschatz, P. Galvin, G. Gagne  Operating Systems Internals and Design Principles, by W. Stallings  See the notes for more references

OS Spring’04 Exercises Administration  5 mandatory programming exercises  40% of final grade  Working in pairs  No copying allowed  Late submission penalty: - 2 (#days + 1)  Bonus and irurim: automatic 3 points bonus (up to 100), lost on irur.  Newsgroups, TA hours, …

OS Spring’04 The Operating System controls the machine User Application Operating System Hardware OS Kernel Hard ware gcc gdb emacs vi date grep xterm netscape diff

OS Spring’04 A better picture Hardware Operating System Privileged instructions System calls Machine instructions Application One Hardware One Operating System Many applications

OS Spring’04 The OS is a reactive program  It is idly waiting for events If there is no active program, idle loop!  When an event happens, the OS reacts It handles the event  E.g., schedules another application to run  The event handling must take as little time as possible  Event types Interrupts and system calls

OS Spring’04 A typical scenario 1.OS executes and chooses (schedules) an application to run 2. Application runs CPU executes app ’ s instructions OS is not involved 3.The system clock interrupts the CPU Clock interrupt handler is executed The handler is an OS function

OS Spring’04 A typical scenario (continued) 4. In handler: OS may choose another application to run Context switch 5. The chosen application runs directly on the hardware 6. The app. performs a system call to read from a file

OS Spring’04 A typical scenario (continued) 7.The sys. call causes a trap into the OS  OS sets up the things for I/O and puts the application to sleep  OS schedules another application to run 8.The third application runs Note: At any given time only one program is running: OS or a user application

OS Spring’04 The running application state diagram Application code runs OS runs Sleep Ready To run Interrupt/ System call Wait for I/O completion I/O completed Schedule Resume execution of the app. code

OS Spring’04 The OS performs Resource Management  Resources for user programs CPU, main memory, disk space  OS internal resources Disk space for paging memory (swap space) Entries in system tables  Process table, open file table Statically allocated

OS Spring’04 CPU management  How to share one CPU among many processes  Time slicing: Each process is run for a short while and then preempted  Scheduling: The decision about which application to run next

OS Spring’04 Memory management  Programs need main memory frames to store their code, data and stack  The total amount of memory used by currently running programs usually exceed the available main memory  Solution: paging Temporarily unused pages are stored on disk (swapped out) When they are needed again, they are brought back into the memory (swapped in)

OS Spring’04 The OS supports abstractions  Creates an illusion that each application got the whole machine to run on In reality: an application can be preempted, wait for I/O, have its pages being swapped out, etc …  File and file system Data on disks are stored in blocks Disk controllers can only write/read blocks

OS Spring’04 Hardware support for OS  Support for bootstrap  Support for executing certain instructions in a protected mode  Support for interrupts  Support for handling interrupts  Support for system calls  Support for other services

OS Spring’04 CPU execution modes  CPU supports (at least) 2 execution modes:  User mode The code of the user programs  Kernel (supervisor, privileged, monitor, system) mode The code of OS  The execution mode is indicated by a bit in the processor status word (PSW)

OS Spring’04 Kernel Mode  Almost unrestricted control of the hardware: Special CPU instructions Unrestricted access to memory, disk, etc …

OS Spring’04 Instructions available only in the Kernel mode  To load/store special CPU registers  E.g., registers used to define the accessible memory addresses isolate simultaneously active applications from one another  To map memory pages to the address space of a specific process  Instructions to set the interrupt priority level  Instructions to activate I/O devices

OS Spring’04 Protecting Kernel mode  OS code executes in the Kernel mode Interrupt, system call  Only the OS code is allowed to be executed in the Kernel mode  The user code must never be executed in the Kernel mode The program counter (PC) is set to point to the OS code when the CPU goes to the Kernel mode

OS Spring’04 Switching to the Kernel mode  Change the bit in the PSW  Set PC to point to the appropriate OS code The interrupt handler code The system call code

OS Spring’04 Interrupts  Interrupts is the way by which hardware informs OS of special conditions that require OS ’ attention  Interrupt causes the CPU not to execute the next instruction  Instead, the control is passed to OS

OS Spring’04 Handling interrupts  Interrupt handler is a piece of the OS code intended to do something about the condition which caused the interrupt Pointers to the interrupt handlers are stored in the interrupt vector The interrupt vector is stored at a pre- defined memory location

OS Spring’04 Handling Interrupts (II)  When an interrupt occurs: The CPU enters kernel mode, and Passes control to the appropriate interrupt handler The handler address is found using the interrupt number as an index into the interrupt vector:  Jump &int[interrupt#]

OS Spring’04 Interrupt vector  The interrupt vector address and the interrupt numbering is a part of the hardware specification  Operating system loads handler addresses into the interrupt vector during the boot

OS Spring’04 Interrupt types  Asynchronous interrupts are generated by external devices at unpredictable times  Internal (synchronous) interrupts are generated synchronously by CPU as a result of an exceptional condition An error condition A temporary problem

OS Spring’04 System calls  Used to request a service from the OS A collection of the system calls is the OS API Packaged as a library  Typical system calls Open/read/write/close the file Get the current time Create a new process Request more memory

OS Spring’04 Handling system calls  An application executes a special trap (syscall) instruction Causes the CPU to enter kernel mode and set PC to a special system entry point (gate routine)  The gate routine address is typically stored in a predefined interrupt vector entry Intel architecture: int[80] A single entry serves all system calls (why?)

OS Spring’04 An example open(“/tmp/foo”): store the system call number and the parameters in a predefined kernel memory location; trap(); retrieve the response from a predefined kernel memory location; return the response to the calling application; trap(): jump &int[80]; // transfer control to the gate routine Gate routine: switch(sys_call_num) { case OPEN: … } USER: KERNEL:

OS Spring’04 Other hardware support  Memory management unit (MMU): Translating virtual address into a physical address Support for “ used ” ( “ reference ” ) bit for memory pages  Direct memory access (DMA) Frees the CPU from handling I/O