Systems Architecture Seventh Edition Chapter 11 Operating Systems

  • Slides: 47
Download presentation
Systems Architecture, Seventh Edition Chapter 11 Operating Systems © 2016. Cengage Learning. All rights

Systems Architecture, Seventh Edition Chapter 11 Operating Systems © 2016. Cengage Learning. All rights reserved.

Chapter Objectives • In this chapter, you will learn to: – Describe the functions

Chapter Objectives • In this chapter, you will learn to: – Describe the functions and layers of an operating system – List the resources allocated by the operating system and describe the allocation process – Explain how an operating system manages processes and threads – Compare CPU scheduling methods – Explain how an operating system manages memory © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Operating Systems – Why Do They Exist? • Early computers didn’t need operating systems

Operating Systems – Why Do They Exist? • Early computers didn’t need operating systems because: – They were only able to execute one program at a time in batch mode – The set of hardware resources was relatively simple – Users were highly trained (they had to be!) • Increasing hardware complexity created a chain of events: – Hardware resources became more numerous and varied (e. g. , multiple storage and I/O devices – More complex and diverse hardware enabled more powerful programs but they were more difficult to write because of all the hardware control and interface issues – Hardware became powerful enough to run multiple programs at the same time but there was no easy way to keep them from interfering with one another – Programmers found themselves writing code to do the same sorts of things over and over again, such as: • Read or write data from files stored in disk • Interact with printers and other I/O devices • Manage memory contents (e. g. , implementing buffers) © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Types of Operating System Structure A. B. C. D. E. F. G. H. Simple

Types of Operating System Structure A. B. C. D. E. F. G. H. Simple Operating System Structure Monolithic Structure Layered Structure Microkernel Modular Hybrid Virtualization Structure Client Server Structure Systems Architecture, Seventh Edition

https: //www. slideshare. net/Rafi_the_rey/structure-of-operating-system Systems Architecture, Seventh Edition

https: //www. slideshare. net/Rafi_the_rey/structure-of-operating-system Systems Architecture, Seventh Edition

http: //www. expertsmind. com/learning/operating-system-structures-assignment-help -734287592. aspx Systems Architecture, Seventh Edition

http: //www. expertsmind. com/learning/operating-system-structures-assignment-help -734287592. aspx Systems Architecture, Seventh Edition

Operating System Layers • Kernel – Directly interacts with hardware via device drivers and

Operating System Layers • Kernel – Directly interacts with hardware via device drivers and “logical” commands – Allocates hardware resources to users and programs and controls access • Service Layer - A large set of utility functions, subroutines, or methods that application programs “call” to perform common tasks such as: – File I/O – Network interaction – Window management • Command layer – The common user interface elements and set of tools to manage hardware and software, for example: – Usually a graphical user interface (GUI) though command languages are also used – Programs and tools to manage files (Windows Explorer) – Tools to add or update hardware and software (Windows update, Add/remove hardware devices, …) – Tools to execute application programs (e. g. , doubleclick on an icon on the desktop or in Explorer) © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition FIGURE 11. 3 OS layers Courtesy of Course Technology/Cengage Learning

Kernel • A kernel is the central part of an operating system. It manages

Kernel • A kernel is the central part of an operating system. It manages the operations of the computer and the hardware - most notably memory and CPU time. There are two types of kernels: A microkernel, which only contains basic functionality; A monolithic kernel, which contains many device drivers. https: //simple. wikipedia. org/wiki/Kernel_(computer_scie nce) Systems Architecture, Seventh Edition

FIGURE 11. 1 Topics covered in this chapter Courtesy of Course Technology/Cengage Learning ©

FIGURE 11. 1 Topics covered in this chapter Courtesy of Course Technology/Cengage Learning © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition 9

Operating System Functions • Operating systems address the issues on the previous slide by:

Operating System Functions • Operating systems address the issues on the previous slide by: – Serving as a central point of control over hardware and software resources (e. g. , install, execute, and delete application programs) – Coordinating access to shared resources, for example: • Load two or more programs into memory at the same time and prevent them from accessing each others’ memory • Coordinate access to shared I/O devices such as printers • Coordinate access to shared storage (i. e. , a common directory structure) – Implementing access controls and authentication (usernames, passwords, and permission to run programs and to access files and I/O devices) – Providing a set of utility programs to perform functions need by multiple application programs, for example: • Managing I/O buffers • Reading from and writing to files on disk • Sending packets to/from the network • Implementing common “look and feel” features of a graphical user interface © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

OS Management Function Summary © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh

OS Management Function Summary © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition FIGURE 11. 2 OS management functions Courtesy of Course Technology/Cengage Learning

Device Drivers – Windows Properties FIGURE 11. 5 Windows device driver properties Courtesy of

Device Drivers – Windows Properties FIGURE 11. 5 Windows device driver properties Courtesy of Course Technology/Cengage Learning © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Exercise: - Lets do it right now • On a Windows computer do the

Exercise: - Lets do it right now • On a Windows computer do the following: – Right-click My Computer and select Properties – Select Device Manager – Expand the category “Sound, video, and game controllers (click the + sign) – Right-click on the audio device and select Properties – Examine the contents of the three tabs, especially the one titled Driver © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Question • How many instructions can a CPU with a single core process at

Question • How many instructions can a CPU with a single core process at a time? © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Answer ONE © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Answer ONE © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Resource Allocation • Resource allocation is a needed function whenever multiple “things” compete for

Resource Allocation • Resource allocation is a needed function whenever multiple “things” compete for access to a limited set of resources, for example: – Departments and employees competing for budget – Packages competing for space within trucks, planes, and warehouses – Vehicles competing for access to roadways and intersections • Resource allocation is the process of deciding: – – Who gets to use what resource How much of resource they get When they get it When they have to give it up • Complexity increases as the number and diversity of resources and competitors rises – For example, consider the complexity of budgeting and room scheduling in a 4 -room elementary school vs. a university © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Computer Hardware Resources • • CPU Memory – RAM – ROM – Cache Storage

Computer Hardware Resources • • CPU Memory – RAM – ROM – Cache Storage – Hard Disk Network Adapters – Ethernet (Wired and Wireless) – Video Card © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Single-Tasking Resource Allocation • If a computer supports only one running application at a

Single-Tasking Resource Allocation • If a computer supports only one running application at a time it is said to be singletasking • Only the OS and the application can run at the same time • Example is MS-DOS © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Multitasking and Resource Allocation • A multitasking environment enables multiple application programs to “run”

Multitasking and Resource Allocation • A multitasking environment enables multiple application programs to “run” concurrently (at the same time) © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Single User/Multitasking Operating System • If a computer supports two or more running application

Single User/Multitasking Operating System • If a computer supports two or more running application at a time. • Example is a Personal Computer where users performs multiple tasks © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Multi User/Multitasking Operating System • Allows multiple users to use an multiple application simultaneously

Multi User/Multitasking Operating System • Allows multiple users to use an multiple application simultaneously on a single server. • Example is a Network Server such as terminal services. © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Can Computer resources caused overhead? • System overhead: not have enough resources to run

Can Computer resources caused overhead? • System overhead: not have enough resources to run programs or application on your system – Can cause a system to run slow, halt or crash. • What are some of the most common problem with a computer system – Memory – Hard Disk – Network – CPU © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Exercise • Consider a two-person catering company with one truck and one small kitchen

Exercise • Consider a two-person catering company with one truck and one small kitchen – How often do “orders” arrive? – What resources do the people use to “fill” the orders? – How do they coordinate their use of resources? • Consider a large kitchen in a busy restaurant with hundreds of customers at a time and dozens of employees – How often do orders arrive? – What resources are used to do “fill” the orders? – How do employees coordinate their use of resources? © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Real and Virtual Resources • A real resource physically exists (e. g. , my

Real and Virtual Resources • A real resource physically exists (e. g. , my laptop has one dual core CPU and 4 GB of RAM) • A virtual resource “looks” real to the user (program) but may or may not physically exist: – My laptop is concurrently executing ten programs - each program “thinks” it has its own CPU – The sum of memory each program “thinks” it has is 10 GB © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Viewing Windows Virtual Memory Systems Architecture, Seventh Edition

Viewing Windows Virtual Memory Systems Architecture, Seventh Edition

Taking Virtualization to the Next Level • An OS virtualizes CPU, memory, secondary storage,

Taking Virtualization to the Next Level • An OS virtualizes CPU, memory, secondary storage, and I/O resources for programs – Each resource is virtualized individually – For example, a program may have exclusive control of one CPU but some of its allocated memory content may actually be stored on disk • A hypervisor is an OS that virtualizes a complete set of hardware resources collectively – Each collection of virtualized hardware resources is called a virtual machine (VM) – A traditional OS such as Linux or Windows is installed on each VM © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Hypervisors • With a hypervisor, there are two layers of virtualization 1. The hypervisor

Hypervisors • With a hypervisor, there are two layers of virtualization 1. The hypervisor virtualizes an entire computer system or cluster and divides it into VMs – the hypervisor and entire computer system are the “host” 2. “Client” OSs control each VM and virtualize individual resources for programs running within the VM © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition FIGURE 11. 4 Courtesy of Course Technology/Cengage Learning

Hypervisor Types and Applications • A bare-metal hypervisor installs directly on the computer system

Hypervisor Types and Applications • A bare-metal hypervisor installs directly on the computer system or cluster – VMware ESX, Microsoft Hyper-V, and Citrix Xen are examples – The hypervisor is a complete OS, though it is specialized to creating and managing VMs and is “bare bones” in most other respects – Used for applications such as: • Server consolidation – one hardware platform supports multiple virtual servers • Desktop virtualization – one hardware platform supports multiple “desktop” VMs • A virtualization environment is an application that installs under a traditional OS and enables VMs to be created and run within it – VMware Workstation and Microsoft Virtual PC are examples – It runs as an application, though typically with elevated privileges/priority – Used for applications such as: • Multi-platform software development and testing • Running two OSs on the same desktop or laptop machine – for example, VMware Fusion © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Process • What is a process • What happen to a program before it

Process • What is a process • What happen to a program before it executed? • What is PCB(Process Control Block) © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Process Management • From the OS’s point of view, programs (including the OS itself)

Process Management • From the OS’s point of view, programs (including the OS itself) are divided into processes to which virtual resources are allocated • Processes are further subdivided into threads – more on this in a few slides • As programs are started the OS adds information about their processes to a process list or process queue, which stores information such as: – – Identification – a process number Who owns the process What state the process is in (e. g. , running or idle) What priority the process has for resource allocation © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Exercise: Let try this now • On a Windows machine do the following: –

Exercise: Let try this now • On a Windows machine do the following: – Start -> Run, enter taskmgr, press enter (or, Ctrl-Alt-Delete and select Start Task Manager) – Click the Processes tab and click the check box to show process from all users – Right-click on the wininit. exe process, note the contents of the pop-up menu, and select Open File Location. Note the location within C: of the file, then close then Explorer window. – Click View on the Task Manager menu bar, select Columns, and check a few of the unselected columns – e. g. , • CPU Time • I/O Read Bytes • I/O Write Bytes • I/O Other Bytes – Which processes have consumed the most CPU resources? – Which processes have consumed the most I/O resources? © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Process Groups and Architecture • A process is unit of software that can be

Process Groups and Architecture • A process is unit of software that can be in a running or idle state and to which any virtual resource can be allocated • A process can create, or spawn, other processes by calling the appropriate OS service layer function • A parent process spawns one or more child processes – the entire group of related processes is a process family © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Threads • To allow further subdivision of programs/processes without the above problems, most OSs

Threads • To allow further subdivision of programs/processes without the above problems, most OSs use process components called threads • A thread is: – A separate unit of executable code – Owned and controlled by a process – A “lightweight” process: • Allocated CPU time by the OS • Shares other resources (e. g. , memory, open files, network ports) with its parent process and other related threads © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

 • A process that can spawn and concurrently execute multiple threads is aid

• A process that can spawn and concurrently execute multiple threads is aid to be multithreaded Multithreading is a process of executing multiple threads simultaneously. So at this point we will ask our selves what a thread is. A thread is a lightweight subprocess, a smallest unit of processing. It is a separate path of execution. It shares the memory area of process. So in short, Multithreading is a technique that allows a program or a process to execute many tasks concurrently. at the same time and parallel. It allows a process to run its tasks in parallel mode on a single processor system. https: //www. quora. com/What-is-multithreading © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Thread States • Threads move among three states: – Ready – Not currently executing

Thread States • Threads move among three states: – Ready – Not currently executing on a CPU but can be allocated to one – Running – Actively executing on a CPU – Blocked – Waiting for a resource or for an error to be resolved, thus not eligible for the running state • The OS dispatches a thread from the ready state to the running state © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition FIGURE 11. 8 Thread movement between states Courtesy of Course Technology/Cengage Learning

Scheduling • How does the OS decide what thread(s) will be dispatched (scheduled) next?

Scheduling • How does the OS decide what thread(s) will be dispatched (scheduled) next? – Or, stated another way, on what bases is the dispatching decision made? • There are two general scheduling methods and variations on each: – Priority-based – Real-time © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Priority-Based Scheduling • Priority-based scheduling determines which thread(s) in the running are most important

Priority-Based Scheduling • Priority-based scheduling determines which thread(s) in the running are most important and dispatches them next © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Exercise • On a Windows machine – Start task manager – Click the Processes

Exercise • On a Windows machine – Start task manager – Click the Processes tab – Click the button or check box to show processes from all users – Right-click on winlogin. exe, mouse over Set Priority, and view the current priority – Check a few other processes – Download PVIEW. EXE and start it – Select the process winlogon and examine the number and priority of each thread – Do the same check for a few other processes © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Real-Time Scheduling • Real-time scheduling guarantees that a process will receive whatever resources (including

Real-Time Scheduling • Real-time scheduling guarantees that a process will receive whatever resources (including CPU cycles) are needed to “keep up with its workload” – A thread cycle is one unit of “work” performed by the thread (e. g. , process one transaction or data sample) – OS must know the maximum number of CPU cycles required to complete one thread cycle and must track consumption • Few OSs support real-time scheduling due to the complexity involved © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Memory Allocation • Like CPU cycles, memory is a resource that must be allocated

Memory Allocation • Like CPU cycles, memory is a resource that must be allocated to each process • In multitasking OSs, memory is divided into fixed-size partitions and one or more partitions are allocated to each active process FIGURE 11. 15 Several processes and the OS loaded into 250 MB fixed -size memory partitions © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition Courtesy of Course Technology/Cengage Learning

Memory Allocation Memory allocation is a process by which computer programs and services are

Memory Allocation Memory allocation is a process by which computer programs and services are assigned with physical or virtual memory space. Memory allocation is the process of reserving a partial or complete portion of computer memory for the execution of programs and processes. https: //www. techopedia. com/definition/27492/memoryallocation Systems Architecture, Seventh Edition

Memory Fragmentation • Processes change over time: – Start, execute, terminate – Grow and

Memory Fragmentation • Processes change over time: – Start, execute, terminate – Grow and shrink • As processes change over time the memory allocated to them becomes fragmented: – Memory partitions allocated to a process become scattered throughout physical memory – Fragmentation is a performance problem for OSs that allocate memory contiguously – corrected through compaction which is slow – OSs that allocate memory non-contiguously don’t need to compact memory © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Virtual Memory Management • A single-threaded process: – May be spread over many memory

Virtual Memory Management • A single-threaded process: – May be spread over many memory partitions – Only one process instruction at a time can be executed – Thus, only one of the process’ allocated memory partitions is “active” at any one time • Virtual memory management (VMM) is a memory allocation and management technique that takes advantage of the above fact: – Memory partitions are allocated to process chunks as before, but – Process chunks may be temporarily written to disk when not in “active” use © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

VMM Terminology • Processes are divided into pages – fixed size chunks, e. 6.

VMM Terminology • Processes are divided into pages – fixed size chunks, e. 6. , 4 KB • Memory is divided into page-sized chunks called page frames – same size as process pages • A page table stores information about all pages of a single process Table 11. 3 Portion of a process’s page table Courtesy of Course Technology/Cengage Learning © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Exercise • On a Windows machine: – Right-click My Computer and select Properties –

Exercise • On a Windows machine: – Right-click My Computer and select Properties – Select Advanced system settings – Click the Advanced tab and click Settings in the Performance group – Click the Advanced tab – Click Change in the Virtual memory area – Examine but don’t change the settings © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Memory Protection • Memory protection refers to OS and/or hardware protection of memory allocated

Memory Protection • Memory protection refers to OS and/or hardware protection of memory allocated to one process from reads and (especially) writes from other processes • Memory protection is both a security and reliability issue: – Prevent processes from reading important data or overwriting data/instructions in other processes (e. g. , a virus) – Prevent one process from accidentally crashing another when it “misuses” memory • The protection mechanism is simple though tedious – check every read and write operation to ensure that the referenced location “belongs” to the process trying to perform the operation – Requires some mechanism for tracking process ownership of memory locations (the page table(s) can be extended for this purpose) – Requires processing overhead for every memory reference – a potential performance bottleneck © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition

Summary • • • Operating system overview Resource allocation Process management CPU allocation Memory

Summary • • • Operating system overview Resource allocation Process management CPU allocation Memory allocation © 2016. Cengage Learning. All rights reserved. Systems Architecture, Seventh Edition