Module 1 – Introduction/OS Overview

Slides:



Advertisements
Similar presentations
Operating-System Structures
Advertisements

Interactive lesson about operating system
Processes Management.
Operating System Structures
Chap 2 System Structures.
Operating-System Structures
CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Dr. Mohamed Hefeeda.
Chapter 2: Operating-System Structures
1/28/2004CSCI 315 Operating Systems Design1 Operating System Structures & Processes Notice: The slides for this lecture have been largely based on those.
Cs238 Lecture 3 Operating System Structures Dr. Alan R. Davis.
Modified from Silberschatz, Galvin and Gagne ©2009 CS 446/646 Principles of Operating Systems Lecture 1 Chapter 1: Introduction.
Common System Components
Lecture 1: Introduction CS170 Spring 2015 Chapter 1, the text book. T. Yang.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: Operating-System Structures Modified from the text book.
Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System.
What do operating systems do? manage processes manage memory and computer resources provide security features execute user programs make solving user.
Chapter 1: Introduction. 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts What is an Operating System? A program that acts as an intermediary.
Process Management A process is a program in execution. It is a unit of work within the system. Program is a passive entity, process is an active entity.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 1: Introduction.
Objectives To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 1: Introduction.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: System Structures.
Four Components of a Computer System. Computer System Components Users (people, machines, other computers) Applications programs – define the ways in.
Chapter 2: Operating-System Structures. 2.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 14, 2005 Operating System.
OS provide a user-friendly environment and manage resources of the computer system. Operating systems manage: –Processes –Memory –Storage –I/O subsystem.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Operating Systems CSCI 411.
Chapter 1: Introduction. 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 1: Introduction What Operating Systems Do (previous.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: Operating-System Structures.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
3.1 Operating System Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual.
1.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Caching Important principle, performed at many levels in a computer (in.
Shan Gao Fall 2007 Department of Computer Science Georgia State University.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 3 Operating-System Structures Slide 1 Chapter 3 Operating-System Structures.
A. Frank - P. Weisberg Operating Systems Structure of Operating Systems.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
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.
Chapter 1 Basic Concepts of Operating Systems Introduction Software A program is a sequence of instructions that enables the computer to carry.
2.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition System Programs (p73) System programs provide a convenient environment.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 3: Operating-System Structures System Components Operating System Services.
Introduction to Operating System. 1.1 What is Operating System? An operating system is a program that manages the computer hardware. It also provides.
Operating System (Reference : OS[Silberschatz] + Norton 6e book slides)
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Chapter 1: Introduction Narzu Tarannum(NAT) Reff: BIS.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 1: Introduction.
Chapter 1: Introduction. 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Objectives To provide a grand tour of the major operating.
Introduction to Operating Systems Concepts
Computer System Structures
Module 3: Operating-System Structures
Chapter 1: Introduction
Chapter 2: System Structures
Operating System Structure
Introduction to Operating System (OS)
Chapter 1: Introduction
Chapter 1: Introduction
Chapter 2: Operating-System Structures
Chapter 2: System Structures
Chapter 3: Operating-System Structures
Chapter 1 Introduction to Operating System
Chapter 2: Operating-System Structures
Introduction to Operating Systems
Outline Chapter 2 (cont) OS Design OS structure
Chapter 2: Operating-System Structures
Chapter 1: Introduction
Chapter 2: Operating-System Structures
System calls….. C-program->POSIX call
Chapter 2: Operating-System Structures
Operating Systems Structure
Presentation transcript:

Module 1 – Introduction/OS Overview Reading: Chapter 1 and 2 (Silberchatz) Objective: Quick overview of computer system organization – the processor (CPU), memory, and input/output, architecture and general operations. Introduce operating systems to understand its role and principal functions.

Organization Computer System Operating System

Computer System Organization Operating System Device Controllers Memory CPU Bus Hardware Organization Computer System Operating System

Computer System Organization Computer-system operation One or more CPUs, device controllers connected through common bus providing access to shared memory Concurrent execution of CPUs and devices competing for memory cycles

Computer System Organisation Operating System Device Controllers Memory CPU Bus Hardware Storage Structure Secondary Storage Organisation Main Memory Computer System Operating System

Storage Structure Primary storage Secondary storage Main memory, directly accessible by the CPU Program must be in main memory in order to be executed Main memory usually not large enough to hold all programs and data Main memory is volatile – loses contents on power loss/reboot Secondary storage holds large quantities of data, permanently In general, we have a hierarchy of storage devices varying by speed, cost, size and volatility

Storage-Device Hierarchy

Computer System Organisation Operating System Device Controllers Memory CPU Bus Interrupt Driven Direct I/O Hardware I/O Structure Storage Structure DMA Secondary Storage Organisation Main Memory Computer System Operating System

I/O Structure Controller has registers for accepting commands and transferring data (i.e. data-in, data-out, command, status) Device driver for each device controller talks to the controller The driver is the one who knows details of controller Provides uniform interface to kernel I/O operation Device driver loads controller registers appropriately Controller examines registers, executes I/O

I/O Structure How does the driver know when the I/O completes? Periodically read the status register Called direct I/O Low overhead if I/O is fast If I/O is slow, lots of busy waiting Any idea how to deal with slow I/O? Do something else and let the controller signal device driver (raising an interrupt) that I/O has completed Called interrupt-driven I/O More overhead, but gets rid of busy waiting

Interrupt Timeline

I/O Structure Interrupt – driven I/O still has lots of overhead if used for bulk data transfer An interrupt for each byte is too much Ideas? Have a smart controller that can talk directly with the memory Tell the controller to transfer block of data to/from memory The controller raises interrupt when the transfer has completed Called Direct Memory Access (DMA)

How a Modern Computer Works

Computer System Organisation Operating System Device Controllers Memory CPU Bus Interrupt Driven Direct I/O Hardware Single * processor I/O Structure Multi processor Architecture Storage Structure DMA Secondary Storage Clusters Distributed Organisation Main Memory Computer System Operating System

Computer-System Architecture Single-processor system From PDAs to mainframes Almost all have special-purpose processors for graphics, I/O Not considered multiprocessor Multi-processor systems Increase throughput Economy of scale Increased reliability Asymmetric multiprocessing Each processor assigned a specific task Symmetric multiprocessing (SMP) most common All processors perform tasks within the OS Clusters, distributed systems

Computer System Organisation Operating System Device Controllers Memory CPU Bus Interrupt Driven Direct I/O Hardware Single * processor I/O Structure Multi processor Architecture Storage Structure DMA Secondary Storage Clusters Distributed Organisation Main Memory Computer System Services User Interface GUI or CLI What is it? Operating System User View

The Role of the Operating System

User View of a Computer This is my box, only I am using it i.e. desktop system with one user monopolizing its resources OS maximizes the work (or play) user is performing OS designed mostly for ease of use, not for resource utilization Handheld systems – usability + low hardware demands This is The Big Holy Computer, I am blessed to get some CPU time i.e. mainframe or minicomputer OS is designed to maximize resource use (CPU, memory, I/O) Communism in practice - Let’s share our computers i.e. workstations connected to networks of servers Dedicated and shared resources OS compromises between individual usability and resource utilization What? There is a computer inside?! Embedded systems designed to run without user intervention

Why Operating Systems? If there are several users/applications sharing the computer i.e. Big Holy Computer who should get which resources? when? what is each user/application allowed to do? how should we bill the users? Ok, ok, if there are many users/programs, something has to manage them, but what if there is single user? (i.e. for my desktop/PDA)? hardware abstraction I might still want to run several applications concurrently

What Operating Systems Do? Give me a 1-2 sentence summary of what OS does OS is program most involved with the hardware hardware abstraction OS is a resource allocator Manages all resources Decides between conflicting requests for efficient and fair resource use OS is a control program Controls execution of programs to prevent errors and improper use of the computer

Defining Operating Systems So, what is an operating system? No universally accepted definition “Everything a vendor ships when you order an operating system” is good approximation But varies wildly (see system programs) “The one program running at all times on the computer” is the one generally used in this course This is the kernel Everything else is either a system program (ships with the operating system) or an application program Ha! What does it mean “running at all times”? When I am playing Tetris, Tetris is running on the CPU, no?

System Programs Are these part of the Operating System? Whatever is not in the kernel, but is shipped with the OS Of course, depends on the OS and the vendor Provide a lot of system-type functionality, i.e. most commands you type in Unix CLI are not shell commands, but standalone system programs that perform system tasks Most users’ view of the operation system is defined by system programs, not the actual system calls

System Programs System programs provide a convenient environment for program development and execution. They can be divided into: File management – i.e. copy, rm, ls, mkdir Status information – i.e. ps, who, regedit File modification - editors Programming language support – i.e. cc, javac Program loading and execution – loaders, debuggers Communications – ssh, ftp Application programs – browsers, spreadsheets, games Also called system utilities

Operating System Services Services provided to user programs: I/O operations User program cannot directly access I/O hardware, OS does the low level part for them Communications Both inter-process on the same computer, and between computers over a network via shared memory or through message passing Error detection Errors do occur: in the CPU and memory hardware, in I/O devices, in user programs OS should handle them appropriately to ensure correct and consistent computing Low level debugging tools really help

Operating System Services (Cont.) Services for ensuring efficient operation of the system itself Resource allocation and management Needed when there are multiple users/ multiple jobs running concurrently Some resources need specific management code CPU cycles, main memory, file storage Others can be managed using general code - I/O devices Accounting Which users use how much and what kinds of computer resources Protection and security Between different processes/users in the computer From the outsiders in a networked computer system Protection: ensuring that all access to system resources is controlled Security: user authentication, defending against external I/O devices from invalid access attempts

OS interface for users - CLI Command Line Interface allows direct command entry from keyboard Command interpreter is itself a program that reads command lines typed in by the user Often called a shell (UNIX terminology) Execution of commands accomplished in one of two ways The command interpreter executes the command itself Programming instructions allow command interpreters to execute “shell” programs The command is used to invoke a separate program (system program)

OS interface for users - GUI User-friendly desktop metaphor interface Usually mouse, keyboard, and monitor Icons represent files, programs, actions, etc Various mouse buttons over objects in the interface cause various actions (provide information, options, execute function, open directory Invented at Xerox PARC Many systems now include both CLI and GUI interfaces Microsoft Windows is GUI with CLI “command” shell Apple Mac OS X as “Aqua” GUI interface with UNIX kernel underneath and shells available Solaris and Linux are CLI with optional GUI interfaces (Java Desktop, KDE)

CLI vs GUI So, which one is better? What would your grandma prefer? True hacker would never use GUI! By definition, anybody using GUI is wimp, not a true hacker! Depends on what you want to do… GUI benefits Intuitive, easy to use Ha! If well designed…not always. CLI benefits Easier to execute complex commands

OS Interfaces CLI and GUI – interfaces for the user What other interfaces the Operating Systems have? Interface to the programs running on the computer and requesting OS services System Call interface Interface to the hardware Interrupts, drivers device controllers Shall talk about the System Call interface a little later We will talk about the interface to the hardware in Ch13 - Kernel I/O subsystem

Computer System Organisation Operating System Device Controllers Memory CPU Bus Interrupt Driven Direct I/O Hardware Single * processor I/O Structure Multi processor Architecture Storage Structure DMA Secondary Storage Clusters Distributed Organisation Main Memory Computer System Services User Interface GUI or CLI Input/Output Management What is it? Process Manag. Operating System User View Memory Management Operation Dual Mode

A Short History of Operating Systems Problem in 60’s Computers expensive, need to efficiently utilize them Single job cannot efficiently use the computer CPU idle when doing I/O, I/O devices idle when computing Solution: Multiprogramming Keeping several jobs in memory in order to efficiently utilize resources One job selected and run via job scheduling When it has to wait (for I/O for example), OS switches to another job In general, no guarantee of low response time

A Short History of Operating Systems Later on: computers becoming cheaper, but many resources still expensive (fast laser printers, mass storage, …) Share the resources in the network Every user wants to have fast interactive environment Solution: Timesharing (multitasking): Switch jobs frequently, even if they would like to compute more (preemption) Timer interrupts are used for preemption If several jobs ready to run at the same time  CPU scheduling

A Short History of Operating Systems Lots of stuff invented to make this work well If processes don’t fit in memory, swapping moves them in and out Virtual memory allows execution of processes not completely in memory Introduced in 60’s and 70’s for mainframes Early PCs started simple and primitive (MS-DOS) Advanced stuff added later as computing power and user requirements grew

Operating-System Operations OS is interrupt driven Interrupts raised by hardware and software Mouse click, division by zero, request for operating system service Timer interrupt (i.e. process in an infinite loop), memory access violation (processes trying to modify each other or the operating system) Some operations should be performed only by a trusted party Accessing hardware, memory-management registers A rogue user program could damage other programs, steal the system for itself, … Solution: dual-mode operation

Transition from User to Kernel Mode Dual-mode operation allows OS to protect itself and other system components User mode and kernel mode Mode bit provided by hardware Provides ability to distinguish when system is running user code or kernel code Some instructions designated as privileged, only executable in kernel mode System call changes mode to kernel, return from call resets it to user

System Calls Programming interface to the services provided by the OS Process control i.e. launch a program File management i.e. create/open/read a file, list a directory Device management i.e. request/release a device Information maintenance i.e. get/set time, process attributes Communications i.e. open/close connection, send/receive messages

System Calls Typically written in a high-level language (C or C++) Called from user program by invoking trap instruction Software interrupt that sets the mode bit to kernel mode and jumps to the appropriate routine, chosen from the system call table based on the provided trap number Linux example: http://docs.cs.up.ac.za/programming/asm/derick_tut/syscalls.html Upon completion, the mode is switched back to user mode and status of the system call and any return values are returned

API – System Call – OS Relationship

System Calls Mostly accessed by programs via a high-level Application Program Interface (API) rather than direct system call use Three most common APIs: Win32 API for Windows POSIX API for POSIX-based systems UNIX, Linux, and Mac OS X Java API for the Java virtual machine (JVM) The caller need know nothing about how the system call is implemented Just needs to obey API and understand what OS will do as a result call Most details of OS interface hidden from programmer by API Managed by run-time support library (set of functions built into libraries included with compiler)

Standard C Library Example C program invoking printf() library call, which calls write() system call

Process Management Program is passive, process is active, unit of work within system Single-threaded process has one program counter specifying location of the next instruction to execute Process executes instructions sequentially, one at a time, until completion Multi-threaded process has one program counter per thread Typically system has many processes, some user, some operating system, running concurrently on one or more CPUs Process needs resources to accomplish its task CPU, memory, I/O, files Initialization data When process terminates, its resources need to be reclaimed OS needs to facilitate interaction between processes

Process Management Activities The operating system is responsible for the following activities in connection with process management: Creating and deleting both user and system processes Suspending and resuming processes Providing mechanisms for process synchronization Providing mechanisms for process communication Providing mechanisms for deadlock handling

Computer Startup and Execution How does a computer start? bootstrap program is loaded at power-up or reboot Typically stored in ROM or EEPROM, generally known as firmware Basic hardware initialization (CPU registers, memory) Loads operating system kernel and starts execution How does execution look like? Typical situation: User program runs, kernel waits for an event to occur Interrupt from either hardware or software Hardware can trigger an interrupt at any time Software triggers interrupt by executing system call Stops current execution, transfers execution to a fixed location Interrupt service routine is executed, then the execution is resumed where it was interrupted Usually a service routine for each device / function Interrupt vector dispatches interrupt to appropriate routine

Example: MS-DOS execution Simple, single-user process control (a) At system startup (b) running a program

Example: Unix Shell When you log in, a shell program is launched for you Shell interprets the command line and launches the programs you specify So, what happens when you type mkdir rrr and press enter? The shell asks the system to launch a program called ‘mkdir’ with command line argument ‘rrr’ It actually has to figure out where is that program located … … and then tell the kernel to launch it In Unix, the launching of a program is actually two-step process: fork() system call to make a new process - copy of itself exec() system call to replace the shell body of this new process by the body of the program We will talk about this in detail when discussing process management

Example: Unix Shell The ‘mkdir’ program creates a directory ‘rrr’ and returns exit status to the parent process (i.e. the shell) by making system call exit() Now, what is the shell process doing meanwhile? By default: waiting until the launched process finishes Launching foreground process But you can also launch a process in the background – in such case the shell continues immediately

Memory Management Program being executed needs its data and instructions in the main memory We want to execute several programs concurrently, possibly with memory requirements larger than the available physical memory Memory management determines what is in memory and when. Goal: optimizing CPU utilization and computer response to users Memory management activities Keeping track of which parts of memory are currently being used and by whom Deciding which processes (or parts thereof) and data to move into and out of memory Allocating and de-allocating memory space as needed

Storage Management OS provides uniform, logical view of information storage Abstracts physical properties to logical storage unit - file Each medium is controlled by device (i.e. disk drive, tape drive) Varying properties include access speed, capacity, data-transfer rate, access method (sequential or random) File-System management Files usually organized into directories Access control on most systems to determine who can access what OS activities include Creating and deleting files and directories Primitives to manipulate files and directories Mapping files onto secondary storage Backup files onto stable (non-volatile) storage media

Mass-Storage Management Usually disks used to store what won’t fit in memory Proper management is of central importance Entire speed of computer operation hinges on the disk subsystem and its algorithms OS activities Free-space management Storage allocation Disk scheduling Some storage need not be fast Tertiary storage includes optical storage, magnetic tape Still must be managed Varies between WORM (write-once, read-many-times) and RW (read-write)

Caching Important principle, performed at many levels in a computer (in hardware, operating system, software) Information in use copied from slower to faster storage temporarily Faster storage (cache) checked first to determine if information is there If it is, information used directly from the cache (fast) If not, data copied to cache and used there Cache is smaller than storage being cached Cache management important design problem Cache size and replacement policy Why caching works? Principle of locality (temporal, spatial)

Performance of Various Levels of Storage Movement between levels of storage hierarchy can be explicit or implicit

I/O Subsystem One purpose of OS is to hide peculiarities of hardware devices from the user I/O subsystem responsible for Memory management of I/O including buffering (storing data temporarily while it is being transferred) Caching (storing parts of data in faster storage for performance) Spooling (the overlapping of output of one job with input of other jobs) General device-driver interface Drivers for specific hardware devices

Migration of Integer A from Disk to Register Multitasking environments must be careful to use most recent value, does not matter where it is stored in the storage hierarchy Multiprocessor environments usually provide cache coherency in hardware such that all CPUs have the most recent value in their cache Distributed environment situation even more complex Several copies of a datum can exist

A Kernel I/O Structure

Computer System Organisation Operating System Device Controllers Memory CPU Bus Interrupt Driven Direct I/O Hardware Single * processor I/O Structure Multi processor Architecture Storage Structure DMA Secondary Storage Clusters Distributed Organisation Main Memory Computer System Services User Interface GUI or CLI Input/Output Management What is it? Process Manag. Operating System User View Memory Management Operation Dual Mode Virtual Machine Design issues Structure Different Flavors Layer MicroKernel Modules

Operating System Design and Implementation The design is primarily affected by choice of hardware and the type of system Batch, time-shared, single-user, multi-user, distributed, real-time, general purpose User goals and System goals User goals – operating system should be convenient to use, easy to learn, reliable, safe, and fast System goals – operating system should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient Implementation Traditionally in assembler Nowadays mostly in C, with small assembler sections (drivers, saving/restoring registers)

Operating System Structure Internal structure of different OSes can vary widely As the requirements vary widely Low hardware resources, simple functionality Simple, monolithic structure More functionality & resources Layered structure MSDOS and traditional Unix are OS-es with monolithic structure that uses some layering Even more functionality & resources, focus on clean design and flexibility Microkernel structure (MACH, QNX, early Windows NT) Flexibility & efficiency Modular structure (Solaris, Windows NT)

MS-DOS Layer Structure

Layered Approach The operating system is divided into a number of layers (levels), each built on top of lower layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface. With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers

Traditional UNIX System Structure UNIX was created as a simple, relatively low functionality alternative to the complex mainframe OS-es of that time

Microkernel System Structure Moves as much from the kernel into “user” space Communication takes place between user modules using message passing Benefits: Easier to extend a microkernel Easier to port the operating system to new architectures More reliable (less code is running in kernel mode) More secure Detriments: Performance overhead of user space to kernel space communication

Modules Most modern operating systems implement kernel modules Uses object-oriented approach Each core component is separate Each talks to the others over known interfaces Each is loadable as needed within the kernel

Virtual Machines A virtual machine takes the layered approach to its logical conclusion. It treats hardware and the operating system kernel as though they were all hardware A virtual machine provides an interface identical to the underlying bare hardware The VM creates the illusion of multiple processes, each executing on its own processor with its own (virtual) memory

System Models (a) Nonvirtual machine (b) virtual machine

Virtual Machines - Implementation How to create several VM when we have only one set of hardware resources? Sharing resources CPU Time-shared scheduling Printers/card readers Spooling Memory Virtual memory HD Ha! Its not possible to have full HD for each VM! Other problems: real-time aspects

Advantages/Disadvantages of Virtual Machines Complete protection/isolation of system resources between VMs Perfect vehicle for operating-systems research and development If the OS you are developing crashes, just restart the VM Useful when you have applications for different OSs Disadvantage No direct sharing of resources between different VMs Difficult to implement completely

Example: VMware Architecture

The Java Virtual Machine

We are not going to talk about Distributed systems Real-time embedded systems Multimedia systems Handheld systems Different computing environments Peer to peer computing Web-based computing

Computer System Organisation Operating System Device Controllers Memory CPU Bus Interrupt Driven Direct I/O Hardware Single * processor I/O Structure Multi processor Architecture Storage Structure DMA Secondary Storage Clusters Distributed Organisation Main Memory Computer System Services User Interface GUI or CLI Input/Output Management What is it? Process Manag. Operating System User View Memory Management Operation Dual Mode Virtual Machine Design issues Structure Different Flavors Layer MicroKernel Modules