Operating Systems CS 340 Introduction PDF
Document Details
Uploaded by Deleted User
Princess Nourah Bint Abdulrahman University
Tags
Summary
This document is an introduction to operating systems, focusing on computer system organization, operating system structure, and operation. It also covers different types of computer systems, such as client-server systems.
Full Transcript
Princess Nora University Computer Sciences Department Operating Systems CS 340 1 Chapter-1 Introduction Introduction Chapter 1 Introduction 1. What Operating Systems Do 2. Computer-System Organization 3. Computer-System Architecture 4. Operating-System Structure...
Princess Nora University Computer Sciences Department Operating Systems CS 340 1 Chapter-1 Introduction Introduction Chapter 1 Introduction 1. What Operating Systems Do 2. Computer-System Organization 3. Computer-System Architecture 4. Operating-System Structure 3 OBJECTIVES: To describe the basic organization of computer systems. To provide a grand tour of the major components of operating systems. To give an overview of the many types of computing environments. 4 What is an Operating System? 5 What is an Operating System? A software that acts as an intermediary between a user of a computer and the computer hardware Operating system goals: Execute user programs and make solving user problems easier Use the computer hardware in an efficient manner 6 About “Efficiency” Efficiency Time Space (i.e. speed/performance) 7 Computer System Structure Computer System Consists of four components: 1. Hardware : provides basic computing resources (e.g. :CPU, memory, I/O devices) 2. Operating system: controls the hardware and coordinates its use among the various application programs for the various users. 3. Application programs : define the ways in which the system resources are used to solve the computing problems of the users e.g.: (Word processors, compilers, web browsers, database systems, video games) 4. Users. 8 Four Components of a Computer System 9 Four Components of a Computer System 10 What Operating Systems Do? (User View) 1. User View: OS of PC’s designed to achieve ease of use and good performance Don’t care about resource utilization OS of mobile devices like smartphones and tablets designed to achieve usability and battery life. OS in multi-users computer such as mainframe or minicomputer must maximize resource utilization in first place. 11 What Operating Systems Do? (System View) 2- System View: OS is a resource allocator Manages all resources (e.g. CPU time, memory space, file- storage space, I/O devices…etc.) Decides between conflicting requests of many programs (/users). OS is a control program Controls execution of programs to prevent errors It is especially concerned with the operation and control of I/O devices. 12 Operating System Definition Operating System (OS) Definition: It is a software that manage the computer hardware and provide an environment for application programs to run What constitutes an OS? Kernel: The one program running at all times on the computer System program which are associated with the operating system but are not necessarily part of the kernel. 13 Computer-System Organization 14 Computer-System Organization 1. Computer-System Operation 2. Storage Structure 3. I/O Structure 15 Computer System Organization 1-Computer-system operation A general-purpose computer system consists of: One or more CPU RAM connecting to CPU and device controllers through common bus Multiple device controllers that are connected through a common bus Device Controller – is a special-purpose processor that can operate an I/o device. Each device controller is responsible of a specific type of device (e.g. disk drives, audio devices, and video displays). The CPU and the device controllers can execute concurrently. A general-purpose computer system Computer System Organization 1-Computer-system operation (cont..) Computer Startup: Bootstrap program is loaded at power-up or reboot Typically stored in ROM, generally known as firmware Initializes all aspects of system Loads operating system kernel and starts execution ROM : read-only memory,→ Once data has been written onto a ROM chip, it cannot be removed and can only be read. Firmware: Firmware is software that is embedded in a piece of hardware. You can think of firmware simply as "software for hardware.“ Typical examples of devices containing firmware are embedded systems (such as traffic lights, consumer appliances, and digital cameras ) The firmware contained in these devices provides the control program for the device. 18 Computer System Organization 1-Computer-system operation(cont..) The interrupt is signal that gets the attention of the CPU. It generated from either the hardware or the software HW– generated interrupts→ sending a signal to the CPU through system bus. E.g. when a key is pressed or when the mouse is moved SW– generated interrupts → by executing a special operation called a system call. E.g. when I/O is required or when error (trap) occurs such as division by zero. What happened when CPU is interrupted? When the CPU is interrupted, it stops what it is doing and immediately transfers execution to a fixed location. The fixed location usually 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. 19 Computer System Organization 2-Storage Structure (cont..) 20 Computer System Organization 2-Storage Structure (cont..) Storage systems organized in hierarchy Speed Cost size Volatility Caching It is copying information into faster storage system. Caches can be installed to improve performance where a large access-time or transfer-rate disparity exists between two components. The design of a complete memory system must balance all the factors just discussed: It must use only as much expensive memory as necessary while providing as much inexpensive, nonvolatile memory as possible. 21 Computer System Organization 2-Storage Structure (cont..) Main memory (RAM)–The CPU can load instructions only from memory, so any programs to run must be stored there. All forms of memory provide an array of words. Each word has its own address. Interaction is achieved through a sequence of load or store instructions to specific memory addresses. The load instruction>>> moves a word from RAM to CPU’s register The store instruction>>> moves the content of a CPU’s register to RAM CPU automatically loads instructions from main memory for execution. 22 Computer System Organization 2-Storage Structure (cont..) Typical instruction-execution cycle : 1. CPU Fetches an instruction from memory and stores that instruction in the instruction register. 2. The instruction is decoded and may cause operands to be fetched from memory and stored in some internal register. 3. The instruction on the operands is executed 4. The result may be stored back in memory. 23 Computer System Organization 2-Storage Structure (cont..) Storing programs and data in RAM permanently is impossible because: RAM is too small to store all needed programs and data permanently. RAM is volatile storage device that loses its contents when power is turned off. 24 Computer System Organization 3- I/O Structure Storage is only one of many types of I/O devices within a computer. A large portion of OS code is dedicated to managing I/O, because of: Its importance to the reliability and performance of a system The varying nature of the devices. Reliability can be used to understand how well the service will be available in context of different real-world conditions 25 Computer System Organization 3- I/O Structure The CPU and the device controllers can execute concurrently , competing for memory cycles. So, a memory controller is provided whose function is to synchronize access to the memory. Each device controller is in charge of a particular device type Each device controller has a local buffer Each device controller type has an operating system device driver to manage it I/O is from the device to local buffer of controller Device controller informs CPU that it has finished its operation by causing an interrupt 26 Computer System Organization 3- I/O Structure How I/O operation performed? System Devise Devise Call Operating application Driver Controller I/O device system (SW) (HW) 27 Computer-System Architecture 28 Computer-System Architecture A computer system can be organized according to the number of general- purpose processors used. SINGLE-PROCESSOR SYSTEM : It has one CPU capable of executing a general-purpose instruction set, including instructions from user processes. MULTIPROCESSOR SYSTEM: It has two or more processors in close communication, sharing the computer bus and some times the clock, memory, and peripheral devices. 29 Computer-System Architecture Single-processor systems It has one CPU capable of executing a general-purpose instruction set, including instructions from user processes. Most systems use a single processor (PDAs through mainframes) Almost all systems have other special-purpose processors The use of special-purpose microprocessors is common and does not turn a single-processor system into a multiprocessor. 30 Computer-System Architecture About special-purpose processors : They may come in the form of device-specific processors, such as disk, keyboard controllers Special-purpose processors run a limited instruction set and do not run user processes. For example: a disk-controller microprocessor receives a sequence of requests from the main CPU and implements its own disk queue and scheduling algorithm. This arrangement relieves the main CPU of the overhead of disk scheduling. 31 Computer-System Architecture MULTIPROCESSOR SYSTEMS Also known as parallel systems, tightly-coupled systems Two Types: symmetric multiprocessing & asymmetric multiprocessing Advantages include: Throughput : number of 1. Increased throughput processes that complete more work is performed their execution per time unit (e.g. 10 processes /sec) 2. Economy of scale Multiprocessor systems can cost less than equivalent multiple single- processor systems, because they can share peripherals, mass storage, and power supplies. 3. Increased reliability the failure of one processor will not halt the system, only slow it down. 32 Computer-System Architecture (cont..) ❑ MULTIPROCESSOR SYSTEMS Cons (--): OS must carefully control I/O to ensure that the data reach the appropriate processor. since the CPUs are separate, one may be sitting idle while another is overloaded, resulting in inefficiencies. 33 Computer-System Architecture (cont..) BASIS FOR SYMMETRIC ASYMMETRIC MULTIPROCESSOR COMPARISON SYSTEMS MULTIPROCESSING (SMP) TYPES – (CONT.) MULTIPROCESSING (ASMP) Basic SMP means that all processors are This scheme defines a boss–worker peers; NO boss–worker relationship. relationship exists between The boss processor schedules and processors. allocates work to the worker Each processor can run system processors. code & user code Only boss processor executes system Each processor is self-scheduling, code & worker processors execute The most common systems use user code (SMP), Communication All processors communicate with Processors need not communicate as another processor by a shared they are controlled by the boss memory. processor. Failure If a processor fails, the computing If a boss processor fails, a worker is capacity of the system reduces. turned to the boss processor to continue the execution. If a worker processor fails, its task is switched to other processors. 34 Computer-System Architecture (cont..) Symmetric Multiprocessing Architecture All modern operating systems—including Windows, Mac OS X, and Linux—now provide support for SMP. 35 Computer-System Architecture (cont..) o Processors were originally developed with only one core. o The core : is the part of the processor that actually performs the reading and executing of the instruction. o Single-core processors can process only one instruction at a time. Multi-cores chips. o It is a recent trend in CPU design is to include multiple computing cores on a single chip. 36 A Dual-Core Design oMulti-cores chips can be more efficient than multiple chips with single cores because: 1. on-chip communication is faster than between-chip communication Dual-core processor contains two cores (Such as Intel Core Duo). 2. one chip with multiple cores Multi-core systems are especially suited uses significantly less power for server systems such as database and than multiple single-core Web servers. chips. 37 Operating System Structure 38 Operating System Structure Multiprogramming environment: Single program cannot keep CPU and I/O devices busy at all times. Multiprogramming increases CPU utilization by organizing jobs (code and data) so that the CPU always has one to execute. CPU utilization: the time percentage that the CPU is busy (/not idle). 39 Operating System Structure Multiprogramming idea is as follows: The operating system keeps several jobs in memory simultaneously. One job selected and run via job scheduling. When it has to wait (for I/O for example), OS switches to another job Eventually, the first job finishes waiting and gets the CPU back. As long as at least one job needs to execute, the CPU is never idle. 40 Operating System Structure Memory Layout for Multiprogrammed System RAM is too small to accommodate all jobs, the jobs are kept initially on the disk in the job pool. This pool consists of all processes residing on disk awaiting allocation of main memory. 41 Operating System Structure Time sharing (or multitasking) system: It is a logical extension of multiprogramming. In time-sharing systems, the CPU executes multiple jobs by switching among them, but the switches occur so frequently that the users can interact with each program while it is running. The CPU time is shared by different processes, so it is called as “Time sharing Systems”. Time slice is defined by the OS, for sharing CPU time between processes. CPU is taken away from a running process when the allotted time slice expires. Eg.: Unix, etc 42 Operating System Structure A time-shared operating system allows many users to share the computer simultaneously. each user is given the impression that the entire computer system is dedicated to his use. Each user has at least one separate program in memory. A process : is a program loaded into memory and executing 43 Operating System Operation 44 Operating System Operation In order to ensure the proper execution of the operating system, we must be able to distinguish between the execution of operating-system code and user defined code. Dual-Mode Operation user mode kernel mode (also called supervisor mode, system mode, or privileged mode). Dual-mode operation allows OS to protect itself and other system components Mode bit provided by hardware 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 Transition from User to Kernel Mode 46 Thank you End of Chapter 1 47 Some Helpful Notes Some terminologies : Usability = ease of use Utilization= efficiency Performance= speed Synchronize = manage the timing Job=process=task job pool= job queue= input queue System overhead = more work must be performed by the system (e.g. more load) What is computer resource? Computer resource is any physical or virtual component of limited availability within a computer system. Every device connected to a computer system is a resource. Every internal system component is a resource.Virtual system resources include files 48 Some Helpful Notes (cont.) Load & store operations between RAM & CPU is different from Load & store operations between RAM & storage devices Between RAM & CPU : The load instruction>>> moves a word from RAM to CPU’s register The store instruction>>> moves the content of a CPU’s register to RAM Between RAM & Storage Devices : The load instruction>>> moves a word from storage device to RAM. The store instruction>>> moves a word from RAM to storage device. 49 Example of Multi-users environment – Client-Server computing Client-Server Computing Many systems now servers, responding to requests generated by clients Server systems can be broadly categorized as: Compute-server system : Client can send a request to perform an action (for example, read data). In response, the server executes the action and sends the results to the client (i.e. database server) File-server system Provides interface for clients to store and retrieve files (i.e. Web server) 50 Example of Multi-users environment – Client-Server computing 51