Chapter 1-Introduction (1).pptx
Document Details
Uploaded by GracefulMossAgate
Full Transcript
Chapter 1 Introduction Dr Babar Shah 1 Objectives Define operating system (OS) and its role Discuss the services provided by OS Explain the main components of a computer (resources) and how OS manages each resource Explain the different computer architectures and environments 2 ...
Chapter 1 Introduction Dr Babar Shah 1 Objectives Define operating system (OS) and its role Discuss the services provided by OS Explain the main components of a computer (resources) and how OS manages each resource Explain the different computer architectures and environments 2 What is An Operating System? A software/program that acts as an intermediary between a user of a computer and the computer hardware (resources) Operating system goals: Hide complexity of the system to the user by providing interface (graphical or command line interface) Execute user programs and make solving user problems easier Use and manage the computer hardware in an efficient manner 3 Four Components of a Computer System Computer system can be divided into four components: Hardware – provides basic computing resources Operating system Controls and coordinates use of hardware among various applications and users Application programs – define the ways in which the system resources are used to solve the computing problems of the users Central Processing Unit (CPU), memory, I/O devices Word processors, compilers, web browsers, database systems, video games Users People, machines, other computers 4 Operating System Definition 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 Kernel: part of OS that is running all the time when computer is on 5 Computer Startup bootstrap program is loaded at power-up or reboot Typically stored in ROM or EPROM, generally known as firmware Initializes all aspects of system Locates the operating system kernel and loads it into memory to start running 6 Computer System Organization Computer-system operation One or more CPUs, device controllers connect through common bus providing access to shared memory Concurrent execution of CPUs and devices competing for memory cycles 7 Computer-System Operation I/O devices and the CPU can execute concurrently Each device controller is in charge of a particular device type has a local buffer and registers Central Processing Unit CPU (CPU) Composed of control unit, ALU, and registers Controls the operation of the computer Performs data processing functions I/O is from the device to local buffer of controller Device drivers part of OS communicate with device controllers Device controller informs CPU that it has finished its operation by causing an interrupt 8 Operating-System Operations An operating system is interrupt driven Interrupt driven (hardware and software) Hardware interrupt by one of the devices Software interrupt (exception or trap): Software error (e.g., division by zero) Request for operating system service Other process problems include infinite loop, processes modifying each other or the operating system 9 Desirable Hardware Features Memory protection • While the user program (process) is executing, it must not alter the memory area of other processes and kernel Timer • Prevents a job (process) from monopolizing the system Privileged instructions • Can only be executed by the OS Interrupts • Gives OS more flexibility in controlling user programs 10 [W. Stallings book] Storage Structure Main memory (RAM or memory) – only large storage media that the CPU can access directly Random access volatile Secondary storage – extension of main memory that provides large nonvolatile storage capacity Hard disks – rigid metal or glass platters covered with magnetic recording material The disk controller determines the logical interaction between the device and the computer Solid-state disks – faster than hard disks, nonvolatile Becoming more popular 11 Storage Hierarchy Storage systems organized in hierarchy Speed Cost Volatility Caching – Information in use copied from slower to faster storage temporarily Cache: a small and fast memory that sits between main memory and CPU. (May be located on CPU chip) Cache is smaller than main memory Main memory can be viewed as a cache for secondary storage 12 Computer-System Architecture Most systems use a single general-purpose processor Most systems have special-purpose processors as well Multiprocessors systems growing in use and importance Also known as parallel systems, tightly-coupled systems Advantages include: 1. Increased throughput 2. Economy of scale 3. Increased reliability – graceful degradation or fault tolerance Two types: 1. Asymmetric Multiprocessing – each processor is assigned a specie task. 2. Symmetric Multiprocessing – each processor performs all tasks 13 Symmetric Multiprocessing Architecture Processor 0 Processor 1 Processor 3 3 processors, each with its own CPU Each CPU processor has its own set of registers and a local cache All processors share physical memory over the system bus. 14 A Dual-Core Design Multi-chip and multicore Systems containing all chips Framework containing multiple separate systems 15 Clustered Systems Like multiprocessor systems, but multiple systems working together Usually sharing storage via a storage-area network (SAN) Provides a high-availability service which survives failures Some clusters are for high-performance computing (HPC)q 16 Operating System Structure Multiprogramming (Batch system) needed for efficiency Single user cannot keep CPU and I/O devices busy at all times Multiprogramming organizes jobs (code and data) so CPU always has one to execute 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 Timesharing (multitasking) is logical extension in which 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 17 Memory Layout for Multiprogrammed System Note: Process and job are used interchangeably 18 Program B Wait Run Wait Run Wait Combined Run Run A B Wait Run Run A B Wait Uni-programming and Multiprogramming Time (b) Multiprogrammingwith two programs Program A Run Wait Run Wait Program A Run Wait Program B Wait Run Program C Wait Run Wait Run Wait Run Wait Wait Run Wait Run Run Run A B C Wait Time (a) Uniprogramming Combined Run Run Run A B C Wait Time (c) Multiprogramming with threeprograms Program A Run Wait Run The processor spends a certain Program B Wait Run amountWait of Run time executing, until it reachesRun an Run I/O instruction;Run it must Run Combined Wait A B A B then wait until that I/O instruction Time concludes (b) before proceeding Multiprog ramming with two programs Program A Run Wait Run Wait Wait Wait Wait Figure2.5 MultiprogrammingExample Memory is expanded to hold three, four, or more programs and switch among all of them [W. Stallings book] 19 Operating-System Operations (cont.) 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 Certain areas of memory are protected from user access Some instructions designated as privileged, only executable in kernel mode System call changes mode to kernel, return from call resets it to user 20 Transition from User to Kernel Mode Timer to prevent infinite loop / process hogging resources Timer is set to interrupt the computer after some time period Keep a counter that is decremented by the physical clock. Operating system set the counter (privileged instruction) When counter is zero generate an interrupt Set up before scheduling process to regain control or terminate program that exceeds allotted time 21 Operating System Services OS services include Program execution Process management Memory management Storage management Mass-storage management Access I/O devices Error detection and response Accounting Security 22 Will be seen in details in following chapters 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. Process needs resources to accomplish its task CPU, memory, I/O, files, etc. Examples of operating system operations on processes: Creation and termination of both user and system processes Inter-process communication (chapter 3) 23 Memory Management To execute a program all (or part) of the instructions must be in memory All (or part) of the data that is needed by the program must be in memory. Memory management determines what is in memory and when Memory management activities Keeping track of which parts of memory are currently being used and by whom Allocating and deallocating memory space as needed 24 Storage Management 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 Backup to manipulate files and directories files onto stable (non-volatile) storage media 25 Mass-Storage Management Usually, disks used to store data that does not fit in main memory or data that must be kept for a “long” period of time OS activities include Free-space management Storage allocation Disk scheduling 26 Migration of data “A” from Disk to Register Multitasking environments must be careful to use most recent value, no matter where it is stored in the storage hierarchy Multiprocessor environment must 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 27 Protection and Security Protection – any mechanism for controlling access of processes or users to resources defined by the OS Security – defense of the system against internal and external attacks Huge range, including denial-of-service, worms, viruses, identity theft, theft of service Systems generally first distinguish among users, to determine who can do what User identities (user IDs, security IDs) include name and associated number, one per user User ID then associated with all files, processes of that user to determine access control Group identifier (group ID) allows set of users to be defined and controls managed, then also associated with each process, file 28 Types of Operating Systems Operating systems come in different flavors depending on the computing environment: Stand-alone general purpose machines Mobile: Handheld smartphones, tablets, etc Distributed computing- Client-Server computing environment Peer-to-peer computing environment Cloud computing environment Embedded systems More details – see file: Types of Operating Systems-Chapter 1 29 Sources Textbook: Silberschatz, Operating System Concepts References: W. Stallings, Operating Systems: Internals And Design Principles, 9/E Andrew Tanenbaum & Herbert Bos, Modern Operating Systems, 4/E https://www.cs.unc.edu/~porter/courses/cse306/s13/slides/ 30