Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Princess Nora University Faculty of Computer & Information Systems Computer science Department Operating Systems (CS 340 D) (Chapter-1) 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? 6 A program 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 Operating System Functions 7 Process Management Memory Management File Management Device Management Command Interpretation Security Computer System Structure Consists of four components 1. Hardware : provides basic computing resources (CPU, memory, I/O devices) 2. Operating system: Controls and coordinates (use, hardware, applications) 3. Application programs : “define the ways in which the system resources are used to solve the computing problems of the users” ex: (Word processors, compilers, web browsers, database systems, video games) 4. Users : People, machines, other computers 8 Four Components of a Computer System 9 Four Components of a Computer System 10 The operating system’s Role 1- User View: Category Explanation and Example OS is designed to Single User desktop and laptop computers ease of use Multiple Users mainframe or minicomputer maximize resource utilization Workstations users connected to networks of other workstations and servers. compromise between individual usability and resource utilization. Handheld computers individual users and they are connected to networks through cellular or other wireless technologies. individual usability and performance per unit of battery life is important as well. Embedded computers If the computers have little or no user view run without user intervention (minimize usability) 11 The operating system’s Role (cont.) 2- System View: OS is a resource allocator OS is a control program • Manages all resources (e.g. CPU time, memory space, • Controls execution of file-storage space, I/O programs to prevent errors devices…etc) • Decides between conflicting requests of many users access the same mainframe or minicomputer 12 • It is especially concerned with the operation and control of I/O devices. Operating System Definition Operating System Definition: It is a software that manage the computer hardware and provide an environment for application programs to run A more common definition: “The one program running at all times on the computer” usually called the kernel. What constitutes an OS? Kernel system program application program 13 Computer-System Organization 14 Computer-System Organization 1. Computer-System Operation 2. Storage Structure 3. I/O Structure 15 Computer System Organization Computer-system operation A general-purpose computer system consists of: One or more CPU Multiple device controllers that are connected through a common bus RAM connecting to CPU and device controllers through common bus 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, competing for memory cycles . So, a memory controller is provided whose function is to synchronize access to the memory. 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. •Firmware is held in non-volatile memory 18 Computer System Organization 1-Computer-system operation(cont..) The interrupt is signal that gets the attention of the CPU and is usually generated when I/O is required. It generated from either the hardware or the software Hardware sending a signal to the CPU through system bus. Software by executing a special operation called a system call. For example: • Interrupt driven by hardware ( e.g. when a key is pressed or when the mouse is moved). • Software interrupts are generated by a program when I/O is required. Software error or request creates exception or trap ( e.g. division by zero, request for operating system service ) A trap is a software-generated interrupt caused either by an error or a user request • Other process problems include infinite loop, processes modifying each other or the operating system 19 Computer System Organization 1-Computer-system operation(cont..) Dual-Mode and Multimode 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 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 Transition from User to Kernel Mode 21 Computer System Organization 2-Storage Structure Main memory – only large storage media that the CPU can access directly Secondary storage – extension of main memory that provides large nonvolatile storage capacity Magnetic disks – rigid metal or glass platters covered with magnetic recording material 22 Computer System Organization More expensive and faster 2-Storage Structure (cont..) 23 volatile can be volatile or non volatile Nonvolatile Storage Hierarchy 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: 24 It must use only as much expensive memory as necessary while providing as much inexpensive, nonvolatile memory as possible. Computer System Organization 2-Storage Structure(cont..) 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. 25 Storage Structure (cont.) Typical instruction-execution cycle : 1. 2. 3. 4. 26 Fetches an instruction from memory and stores that instruction in the instruction register . The instruction is decoded and may cause operands to be fetched from memory and stored in some internal register. The instruction on the operands is executed The result may be stored back in memory. Storage Structure (cont.) Storing programs and data in RAM permanently is impossible because: 27 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. Computer System Organization 3-I/O Structure A large portion of OS code is dedicated to managing I/O, because of: 28 Its importance to the reliability and performance of a system The varying nature of the devices. Computer System Organization 3-I/O Structure(cont..) A device controller maintains some local buffer storage and a set of special-purpose registers. The device controller is responsible for moving the data between the peripheral devices that it controls and its local buffer storage. Operating systems have a device driver for each device controller. This device driver understands the device controller 29 Computer System Organization 3-I/O Structure(cont..) DC : Responsible for moving data between Device Controller (DC) Peripherals devices that it controls eg: keyboard Local buffer storage Understand how? OS 30 Device Driver (DD) + Set of special purpose registers I/O Structure (cont.) Typical I/O operation: (method #1) 31 The device driver loads the appropriate registers within the device controller. The device controller, examines the contents of these registers to determine what action to take (such as “read “a character from the keyboard”). The controller starts the transfer of data from the device to its local buffer. Once the transfer of data is complete, the device controller informs the device driver via an interrupt that it has finished its operation. The device driver then returns control to the operating system, possibly returning the data or a pointer to the data if the operation was a read. This form of interrupt-driven I/O is fine for moving small amounts of data but can produce high overhead when used for bulk data movement such as disk I/O. I/O Structure (cont.) Direct memory access I/O operation: (method #2) This method is used to solve the problem of moving bulk data without causing OS overhead >>>> (to improve performance) What is direct memory access (DMA) ? 32 After setting up buffers, pointers, and counters for the I/O device, the device controller transfers an entire block of data directly to or from its own buffer storage to memory, with no intervention by the CPU. Only one interrupt is generated per block, to tell the device driver that the operation has completed, rather than the one interrupt per byte generated for low-speed devices. While the device controller is performing these operations, the CPU is available to accomplish other work. Computer-System Architecture 33 Computer-System Architecture Single-processor systems : MULTIPROCESSOR SYSTEMS have two or more processors in close communication, sharing the computer bus and some times the clock, memory, and peripheral devices.. 34 one CPU Computer-System Architecture Single-processor systems 35 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. Computer-System Architecture 36 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. Computer-System Architecture MULTIPROCESSOR SYSTEMS Also known as parallel systems, tightly-coupled systems have two or more processors in close communication, sharing the computer bus and some times the clock, memory, and peripheral devices. Advantages include: 1. Increased throughput 2. Economy of scale 3. Multiprocessor systems can cost less than equivalent multiple singleprocessor systems, because they can share peripherals, mass storage, and power supplies. Increased reliability 37 more work is performed the failure of one processor will not halt the system, only slow it down. Computer-System Architecture (cont..) MULTIPROCESSOR SYSTEMS TYPES – (CONT.): Asymmetric Multiprocessing o Each processor is assigned a specific task. o master-slave relationship o A master processor controls the system; It schedules and allocates work to the slave processors. 38 Symmetric Multiprocessing (SMP) o Each processor performs all tasks within the operating system. (peer =equal rank) o Each processor has its own set of registers & cache o All processors share physical memory. Symmetric Multiprocessing Architecture 39 Computer-System Architecture (cont..) SMP pros (++): many processes can run simultaneously —N processes can run if there are N CPUs— SMP 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. All modern operating systems—including Windows, Mac OS X, and Linux—now provide support for SMP. 40 Computer-System Architecture (cont..) o o o Processors were originally developed with only one core. The core : is the part of the processor that actually performs the reading and executing of the instruction. 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. 41 A Dual-Core Design oMulti-cores chips can be more efficient than multiple chips with single cores because: 1. Dual-core processor contains two cores (Such as Intel Core Duo). Multi-core systems are especially suited for server systems such as database and Web servers. 42 on-chip communication is faster than between-chip communication 2. one chip with multiple cores uses significantly less power than multiple single-core chips. Operating System Structure 43 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. Multiprogramming idea is as follows: 44 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. Memory Layout for Multiprogrammed System 45 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. Operating System Structure Time sharing (or multitasking) system: It is a logical extension of multiprogramming. 46 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 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 47 Thank you End of Chapter 1 48 Some Helpful Notes Some terminologies : 49 Usability = ease of use Utilization= efficiency Performance= speed Synchronize = manage the timing System overhead = more work must be performed by the system (e.g. more load) Some Helpful Notes (cont.) Load & store operations between RAM & CPU is different from Load & store operations between RAM & storage devices 50 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 : moves a word from storage device to RAM. The load instruction>>> The store instruction>>> moves a word from RAM to storage device .