830 likes | 891 Views
This chapter provides an overview of operating systems, their functions, and their role in a computer system. It discusses the components of a computer system, user and system viewpoints, and the operation of a computer system. The chapter also covers bootstrap programs and interrupt-driven systems.
E N D
Operating System Principles Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University
Chapter 1 Introduction • An Operating System (OS) • A program that manages the computer hardware • Provide a basis for application programs • Act as an intermediary between a user of a computer and the computer hardware • Some operating systems are designed to be • Convenient • Efficient • Some combination of the above Chapter 1 Introduction
What Operating Systems Do Computer-System Organization Computer-System Architecture Operating-System Structure Operating-System Operations Process Management Memory Management Storage Management Protection and Security Distributed Systems Special-Purpose Systems Computing Environments Summary Exercises Chapter 1 Introduction Chapter 1 Introduction
1.1 What Is an Operating System? • A computer system can be divided into: • The hardware • The operating system • The application programs • The users Chapter 1 Introduction
Computer System Components • Hardware– provides basic computing resources (CPU, memory, I/O devices) • Operating system– controls and coordinates the use of the hardware among the various application programs for the various users • Applications programs– define the ways in which the system resources are used to solve the computing problems of the users (compilers, database systems, video games, business programs) • Users (people, machines, other computers). Chapter 1 Introduction
Abstract view of the componentsof a computer system Chapter 1 Introduction
Two Viewpoints1.1.1 User View • PC • Monopolize its resources • Maximize the work • Designed for ease of use - convenient • Mainframe or minicomputer • Terminal • Share resources and may exchange information • Maximize resource utilization – efficient • Workstation • Compromise between individual usability and resource utilization • Embedded computer • Little or no user view Chapter 1 Introduction
Two Viewpoints1.1.2 System View • Resource allocator • Manage and allocate resources • CPU time, memory space, file-storage space, I/O devices • Decide between conflicting requests for efficient and fair resource use • Control program • Control the execution of user programs and operations of I/O devices . Chapter 1 Introduction
1.1.3 Defining Operating Systems • No universally accepted definition • Fundamental goal of computer systems • Execute user programs and make solving user problems easier • Toward the above goal • Computer hardware is constructed • Application programs are developed • The common functions of application programs are brought into one piece of software: the operation system • A more common definition • the one program, called the kernel, running at all times • all else are system programs and application programs Chapter 1 Introduction
What Operating Systems Do Computer-System Organization Computer-System Architecture Operating-System Structure Operating-System Operations Process Management Memory Management Storage Management Protection and Security Distributed Systems Special-Purpose Systems Computing Environments Summary Exercises Chapter 1 Introduction Chapter 1 Introduction
1.2.1 Computer-System Operation • General-purpose computer system • Consist of • One or more CPUs • A number of device controllers • CPU and device controllers • Access to shared memory • A common bus • Execute simultaneously • Competing for memory cycles • A memory controller is provided • To synchronize access to the memory Chapter 1 Introduction
A modern computer system Chapter 1 Introduction
Bootstrap program • An initial program to run • Tend to be simple • Stored in ROM (Firmware or EEPROM) • Startup procedure • Locate and load the OS kernel into memory • Start executing the OS kernel • Executing first process, such as “init” • Waiting for some event to occur Chapter 1 Introduction
Interrupt Driven • An event is signaled by an interrupt from • Hardware • Send a signal to CPU • Software – a special operation • a system call ( a monitor call) • A trap (or an exception) is a software-generated interrupt caused by • An error ( ex. division by zero) • A specific request from a user program Chapter 1 Introduction
Interrupt Driven • For each type of interrupt, an interrupt service routine is provided to deal with the interrupt. • When the CPU is interrupted, it stops what it is doing and immediately transfers execution to a fixed location. • The fixed location contains the starting address where the service routine for the interrupt is located. • The interrupt service routine executes. • On completion, the CPU resumes the interrupted computation. Chapter 1 Introduction
Interrupt time line for a single process doing output Chapter 1 Introduction
Interrupt Vector • Interrupts must be handled quickly • A predefined number of interrupts is possible • A table of pointers to interrupt routines • Interrupt vector • Stored in low memory • Indexed by a unique device number • Save the address of the interrupted instruction • Fixed location • A location indexed by the device number • System stack Chapter 1 Introduction
1.2.2 Storage Structure • Main memory • Also called random-access memory or RAM • Computer programs must reside in • The only large area the CPU can access directly • An array of memory words • load and store • Specific memory addresses • Von Neumann architecture • Instruction register • Other internal registers Chapter 1 Introduction
1.2.2 Storage Structure • Ideally, programs and data reside in main memory permanently • Not possible, because • Main memory is too small • Main memory is a volatile storage • Secondary storage • An extension of main memory • The most common device is a magnetic disk Chapter 1 Introduction
1.2.2 Storage Hierarchy • Wide variety of storage systems can be organized in a hierarchy according to • Speed • Cost • Volatility • Volatile storage • Lose contents when the power is removed • Ex. register, cache, main memory • Non-volatile storage • Keep contents all the time • Ex. magnetic disk, optical disk, magnetic tapes Chapter 1 Introduction
Storage-device hierarchy Chapter 1 Introduction
1.2.3 I/O Structure • A CPU and device controllers are connected through a common bus • A device controller • May have more than one attached device • A device driver • Provide a uniform interface to OS CPU Bus Device Controller A Device Controller B DA1 DA2 DB1 DB2 Chapter 1 Introduction
1.2.3 I/O Structure • Start an I/O operation • The CPU loads the registers within the device controller. • The device controller examines the registers to determine what actions to take. • I/O in progress • The device controller informs the CPU • Triggering an interrupt • Drawback • Produce high overhead Chapter 1 Introduction
Direct Memory Access (DMA) • Used for high-speed I/O devices able to transmit information at close to memory speeds. • Device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention. • Only one interrupt is generated per block, rather than the one interrupt per byte. • Cycle stealing • DMA controller “steals” memory cycles from the CPU. Chapter 1 Introduction
How a Modern Computer System Works Chapter 1 Introduction
What Operating Systems Do Computer-System Organization Computer-System Architecture Computer-System Structure Computer-System Operations Process Management Memory Management Storage Management Protection and Security Distributed Systems Special-Purpose Systems Computing Environment Summary Exercises Chapter 1 Introduction Chapter 1 Introduction
1.3.1 Single-Processor Systems • Use a single processor • One main CPU of executing a general-purpose instruction set • Ranging from PDAs through mainframes • Other special-purpose processors • Device-specific processors • A limited instruction set • Not run user processes • Examples • Disk • Graphics controller (GPU, Graphics Processing Unit) GeForce 6600GT (NV43) GPU Chapter 1 Introduction
More than one CPU in close communication Also known as parallel systems or tightly coupled systems Processors share Computer bus Clock Main Advantages Increased throughput Economy of scale Increased reliability graceful degradation fault tolerant Memory Peripheral devices 1.3.2 Multiprocessor Systems Chapter 1 Introduction
1.3.2 Multiprocessor Systems • Symmetric multiprocessing (SMP) • Each processor runs an identical copy of the operating system. • Many processes can run simultaneously without performance deterioration. • Most modern operating systems support SMP. • Asymmetric multiprocessing • Each processor is assigned a specific task; master processor schedules and allocated work to slave processors. • More common in extremely large systems Chapter 1 Introduction
Symmetric Multiprocessing Architecture Chapter 1 Introduction
ASUS A7M266-D Chapter 1 Introduction
1.3.3 Clustered Systems • Gather multiple CPUs to accomplish computational work • Provide high availability • General accepted definition • Clustered computers share storage and are closely linked via LAN networking Chapter 1 Introduction
1.3.3 Clustered Systems • Asymmetric clustering • one server runs the application while other servers do nothing but monitor the active server • Symmetric clustering • all N hosts are running the application and are monitoring each other Chapter 1 Introduction
1.3.3 Clustered Systems • Parallel clusters • Multiple hosts to access the same data on the shared storage • Most OSs lack such support • Clustering over a WAN • Global clusters – the machines could be anywhere in the world • Cluster technology is rapidly changing • Storage-Area-Networks (SANs) Chapter 1 Introduction
What Operating Systems Do Computer-System Organization Computer-System Architecture Operating-System Structure Operating-System Operations Process Management Memory Management Storage Management Protection and Security Distributed Systems Special-Purpose Systems Computing Environments Summary Exercises Chapter 1 Introduction Chapter 1 Introduction
Operating-System Structure • Multiprogramming • Single user cannot keep CPU and I/O devices busy at all times • Organize jobs (code and data) so CPU always has one to execute • Increase CPU utilization • A subset of total jobs in system is kept in memory • One job selected and run via job scheduling • When it has to wait (for I/O for example), OS switches to another job Chapter 1 Introduction
Memory Layoutfor a Multiprogramming System Chapter 1 Introduction
Operating-System Structure • Timesharing (multitasking) • a logical extension of multiprogramming • CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computing • Response time should be < 1 second • Each user has at least one program executing in memory • process • If several jobs ready to run at the same time • CPU scheduling • If processes don’t fit in memory, swapping moves them in and out to run • Virtual memory allows execution of processes not completely in memory Chapter 1 Introduction
What Operating Systems Do Computer-System Organization Computer-System Architecture Operating-System Structure Operating-System Operations Process Management Memory Management Storage Management Protection and Security Distributed Systems Special-Purpose Systems Computing Environments Summary Exercises Chapter 1 Introduction Chapter 1 Introduction
Operating-System Operations • OSs are event driven • An interrupt by hardware • A trap or an exception by software • An error: division by zero or invalid memory access • A specific request (system call) Chapter 1 Introduction
1.5.1 Dual-Mode Operation • Sharing system resources • OS ensures that an incorrect program cannot cause other programs to execute incorrectly • Provide hardware support to differentiate between at least two modes of operations • User mode • execution done on behalf of the user • Kernel mode (also supervisor mode, system mode, or privileged mode) • execution done on behalf of the operating system. Chapter 1 Introduction
1.5.1 Dual-Mode Operation • Mode bit - A bit added to the hardware to indicate the current mode: • Kernel (0) • User (1) • Whenever a trap or interrupt occurs, the hardware switches from user mode to kernel mode. • At boot time, the hardware starts in kernel mode. • OS runs in kernel mode. • User programs run in user mode. Chapter 1 Introduction
1.5.1 Dual-Mode Operation Trap/Interrupt • Privileged instructions • May cause harm • Executed only in the kernel mode • By the OS • Known as a system call ( also a monitor call or an OS function call) kernel user set user mode Chapter 1 Introduction
Transition from User to Kernel Mode Chapter 1 Introduction
1.5.2 Timer • OS must maintain control over the CPU • Prevent a user program from • Getting stuck in an infinite loop • Not calling system services • Use a timer • To interrupt the computer after a specific period • The period may be fixed or variable • If the timer interrupts, control transfers automatically to the OS • Instructions that modify the content of the time are clearly privileged Chapter 1 Introduction
What Operating Systems Do Computer-System Organization Computer-System Architecture Operating-System Structure Operating-System Operations Process Management Memory Management Storage Management Protection and Security Distributed Systems Special-Purpose Systems Computing Environments Summary Exercises Chapter 1 Introduction Chapter 1 Introduction
Process Management • A program • Does nothing when stored on disk • A passive entity • A process • A program in execution • Program counter • An active entity Chapter 1 Introduction
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 Chapter 1 Introduction
What Operating Systems Do Computer-System Organization Computer-System Architecture Operating-System Structure Operating-System Operations Process Management Memory Management Storage Management Protection and Security Distributed Systems Special-Purpose Systems Computing Environments Summary Exercises Chapter 1 Introduction Chapter 1 Introduction
Memory Management • CPU • Read instructions from main memory • Read/Write data from main memory • To improve both the utilization of CPU and the speed of the computer’s response to users • Keep several programs in memory • Create the need of memory management • Memory management • Must take into account many factors • Especially on the hardware design of the system Chapter 1 Introduction