Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Similar documents
Operating Systems Course 2 nd semester 2016/2017 Chapter 1: Introduction

Chapter 1: Introduction

Chapter 1: Introduction. Chapter 1: Introduction

To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization

Chapter 1: Introduction

7/20/2008. What Operating Systems Do Computer-System Organization

Four Components of a Computer System

Chapter 1: Introduction

Operating Systemss and Multicore Programming (1DT089)

European University of Lefke. Instructor: Dr. Arif SARI

Lecture 1 Introduction (Chapter 1 of Textbook)

OPERATING SYSTEMS: Lesson 1: Introduction to Operating Systems

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on

CS3600 SYSTEMS AND NETWORKS

DM510 Operating Systems. Jacob Aae Mikkelsen

CPSC 341 OS & Networks. Introduction. Dr. Yingwu Zhu

Chapter 2: Operating-System Structures. Operating System Concepts 8 th Edition

Operating System Services

Chapter 1: Introduction Dr. Ali Fanian. Operating System Concepts 9 th Edit9on

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on

CS370 Operating Systems

Chapter 1: Introduction. Operating System Concepts 8 th Edition,

Lecture 2 - Fundamental Concepts

Course Details. Operating Systems with C/C++ Course Details. What is an Operating System?

Computer-System Architecture (cont.) Symmetrically Constructed Clusters (cont.) Advantages: 1. Greater computational power by running applications

Operating Systems. Lecture Course in Autumn Term 2015 University of Birmingham. Eike Ritter. September 22, 2015

CS420: Operating Systems

CS420: Operating Systems

CS370 Operating Systems

What Operating Systems Do An operating system is a program hardware that manages the computer provides a basis for application programs acts as an int

Operating System Review

OPERATING SYSTEMS OVERVIEW. Operating Systems 2015 Spring by Euiseong Seo

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

OPERATING SYSTEMS. Prescribed Text Book Operating System Principles, Seventh Edition By Abraham Silberschatz, Peter Baer Galvin and Greg Gagne

Introduction to Operating Systems

EECS 3221 Operating System Fundamentals

EECS 3221 Operating System Fundamentals

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on

Module 2: Computer-System Structures. Computer-System Architecture

OPERATING SYSTEMS UNIT - 1

UNIT 2. OPERATING SYSTEM STRUCTURES

Chapter 2: Operating-System Structures

Module 1 Introduction/OS Overview

Four Components of a Computer System. Operating System Concepts 7 th Edition, Jan 12, 2005

Chapter 13: I/O Systems

Chapter 2: Operating-System Structures. Chapter 2: Operating-System Structures. Objectives. Operating System Services

CSC Operating Systems Spring Lecture - II OS Structures. Tevfik Ko!ar. Louisiana State University. January 17 th, 2007.

Announcements. Operating System Structure. Roadmap. Operating System Structure. Multitasking Example. Tevfik Ko!ar

Operating Systems (2INC0) 2018/19. Introduction (01) Dr. Tanir Ozcelebi. Courtesy of Prof. Dr. Johan Lukkien. System Architecture and Networking Group

Chapter 2: Operating-System Structures

Operating Systems. Overview. Dr Alun Moon. Computing, Engineering and Information Sciences. 27th September 2011

Chapter 1: Introduction. Operating System Concepts 8th Edition,

Chapter 2: Operating-System Structures

COURSE OVERVIEW & OPERATING SYSTEMS CONCEPT Operating Systems Design Euiseong Seo

Chapter 2: Operating-System Structures. Operating System Concepts Essentials 8 th Edition

Chapter 2: Operating-System

Introduction to Computer Systems and Operating Systems

CS420: Operating Systems. OS Services & System Calls

Module 3: Operating-System Structures

1.1 Introduction. Fig.1.1 Abstract view of the components of a computer system.

OS: An Overview. ICS332 Operating Systems

Unit 2 : Computer and Operating System Structure

TDDI04, K. Arvidsson, IDA, Linköpings universitet Operating System Structures. Operating System Structures Overview. Operating System Services

CHAPTER 1 - INTRODUCTION. Jacob Aae Mikk elsen

Chapter 1: Introduction Operating Systems MSc. Ivan A. Escobar

OPERATING SYSTEMS Lecture Notes. Prepared by K.Rohini, Assistant Professor, CSE Department, GVPCEW.

Introduction. TDDI04, K. Arvidsson, IDA, Linköpings universitet Contents. What is an Operating System (OS)?

Chapter 2: Operating-System Structures

Introduction to Operating Systems (Part II)

OS and Computer Architecture. Chapter 3: Operating-System Structures. Common System Components. Process Management

Operating System Concepts 9 th Edit9on

Part I Overview Chapter 1: Introduction

Operating Systems: Internals and Design Principles, 7/E William Stallings. Chapter 1 Computer System Overview

Introduction. Operating Systems (Fall/Winter 2018) Yajin Zhou ( Zhejiang University

Operating Systems. Lecture 09: Input/Output Management. Elvis C. Foster

Lecture 1 - Operating System Overview

The Lesson Plan of OS. The syllabus of OS. Access the lesson plan and syllabus at

Common Computer-System and OS Structures

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - VII CPU Scheduling - II. Louisiana State University

Roadmap. Multilevel Queue Scheduling. Multilevel Queue. Example of Multilevel Feedback Queue. Multilevel Feedback Queue. Tevfik Ko!

Chapter 3: Operating-System Structures

Last class: OS and Architecture. OS and Computer Architecture

Last class: OS and Architecture. Chapter 3: Operating-System Structures. OS and Computer Architecture. Common System Components

CSC Operating Systems Fall Lecture - II OS Structures. Tevfik Ko!ar. Louisiana State University. August 27 th, 2009.

Announcements. Computer System Organization. Roadmap. Major OS Components. Processes. Tevfik Ko!ar. CSC Operating Systems Fall 2009

Operating-System Structures

Lecture 2 Operating System Structures (chapter 2)

Operating-System Structures

I/O Systems. Amir H. Payberah. Amirkabir University of Technology (Tehran Polytechnic)

Chapter 13: I/O Systems

Instruction Cycle. Computer-System Architecture. Computer-System Operation. Common Functions of Interrupts. Chapter 2: Computer-System Structures

Chapter 2: Operating-System Structures. Operating System Concepts 9 th Edit9on

CS330: Operating System and Lab. (Spring 2006) I/O Systems

Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - II OS Structures. University at Buffalo. OS Design and Implementation

Chapter 3: Operating-System Structures

OS Design Approaches. Roadmap. System Calls. Tevfik Koşar. Operating System Design and Implementation. CSE 421/521 - Operating Systems Fall 2013

Operating-System Structures

NETW3005 Operating Systems Lecture 1: Introduction and history of O/Ss

OS Design Approaches. Roadmap. OS Design Approaches. Tevfik Koşar. Operating System Design and Implementation

Transcription:

Ricardo Rocha Department of Computer Science Faculty of Sciences University of Porto Slides based on the book Operating System Concepts, 9th Edition, Abraham Silberschatz, Peter B. Galvin and Greg Gagne, Wiley Chapters 1 and 2

Motivation What is an Operating System? Hardware alone is not particularly easy to use, thus some kid of software is required Different software programs usually require common operations to operate the hardware resources A good idea would be to brought together into one piece of software the common functions of controlling and allocating hardware resources This common piece of software can be seen as the operating system DCC-FCUP # 1

What is an Operating System? How can we then define an operating system or what is part of an operating system? Sorry, but no universally accepted definition A good approximation is Everything a vendor ships when you order an operating system, but varies wildly A more restricted definition is The one program running at all times on the computer, everything else is either a system program (ships with the operating system) or an application program An operating system is what manages a computer s hardware Acts as an intermediary between the user and the hardware Provides a basis for application programs Some operating systems are designed to make the computer system convenient to use, others are designed to use the computer hardware in an efficient manner, and others to be some combination of the two DCC-FCUP # 2

What Operating Systems Should Do? Shared computers, such as mainframes, workstations and/or servers, must keep all users happy The operating system is designed to maximize resource utilization and to assure that all available CPU time, memory, and I/O are used efficiently and fairly between all users PCs are optimized for the single-user experience rather than the requirements of multiple users The operating system is designed mostly for ease of use, with some attention paid to performance and almost none paid to resource utilization DCC-FCUP # 3

What Operating Systems Should Do? Mobile computers, such as smartphones and tablets, are optimized for usability and battery life The operating system is designed mostly for ease of use, with particular attention paid to resource utilization Many computers, such as embedded computers in home devices and automobiles, have little or no user interface The operating system is designed to run with no/minimal user intervention DCC-FCUP # 4

Computer System Structure A computer system can be divided into four main components: Hardware the basic system resources (CPU, memory, I/O devices, ) Operating system controls and coordinates use of hardware among various applications and users Programs define the way in which the system resources are used to solve the users needs (word processors, web browsers, database systems, video games, compilers, ) Users (people, other programs/computers) DCC-FCUP # 5

Operating System Principles Operating system as a resource allocator/controller Acts as a manager of all resources: CPU time, memory space, I/O devices, Decides between conflicting requests for efficient and fair resource use Prevents errors and improper use of the computer Especially important where many users access the same resources Operating system as a facilitator Provides facilities/services that everyone needs Make application programming easier, faster, less error-prone Especially concerned with the operation of various programs Most features reflect both principles For example, file system is needed by everyone (facilitator) but must be efficiently used and protected (controller) DCC-FCUP # 6

Operating System Major Components Modern operating system usually include the following major components: Process management Memory management Storage management I/O management DCC-FCUP # 7

Main activities Process Management Creating, suspending, resuming and terminating (user/system) processes Providing mechanisms for process communication Providing mechanisms for process synchronization Providing mechanisms for deadlock handling DCC-FCUP # 8

Main activities Memory Management Allocating and deallocating memory space as needed Tracking which parts of memory are currently being used and by whom Deciding which processes/data to move into and out of memory and when DCC-FCUP # 9

Main activities Storage Management Providing uniform, logical view of information storage (abstracts physical properties into files and directories logical view) Supporting primitives to create, delete and manipulate files and directories Supporting access control policies to determine who can access what Mapping/backing up files onto nonvolatile secondary storage media DCC-FCUP # 10

Main activities I/O Management Hide peculiarities of hardware devices from the user General device-driver interface Drivers for specific hardware devices Responsible for memory management of I/O including: Buffering storing data temporarily while it is being transferred Caching storing parts of data in faster storage for performance Spooling the overlapping of output of one job with input of other jobs DCC-FCUP # 11

Operating System Common Services Operating systems provide an environment for the execution of programs and, for that, they provide specific services to programs and users DCC-FCUP # 12

Operating System Common Services The services provided differ from one operating system to another, but we can identify common classes: User interfaces to allow effective operation and control of the system Program execution to load a program into memory and to run that program I/O operations to provide a means to do I/O operations File systems to allow effective manipulation of files and directories Communications to allow exchange of information between processes on the same computer or between computers over a network Error detection to be constantly aware of possible errors that may occur in the CPU/ memory hardware, in I/O devices or in user programs in order to take the appropriate action to ensure correct and consistent computing DCC-FCUP # 13

Operating System Common Services Another set of services exists not for helping the user but rather for ensuring the efficient operation of the system itself: Resource allocation when multiple processes are running concurrently, the available resources (such as CPU cycles, main memory, file storage, I/O devices) must be efficiently allocated to each of them Accounting to keep track of which users use how much and what kinds of computer resources Protection and security to avoid concurrent processes to interfere with each other or with the OS itself and to secure the system from outsiders DCC-FCUP # 14

Multiprogramming One of the most important aspects of operating systems is the ability to have multiple programs running Multiprogramming increases CPU utilization by organizing jobs so that the CPU can always execute one job. The idea is as follows: The operating system begins to execute one job via job scheduling Eventually, the job may have to wait for some task, such as an I/O operation In a non-multiprogrammed system, the CPU would sit idle In a multiprogrammed system, the operating system switches to another job. When that job needs to wait, the CPU switches again to another job, and so on. 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 DCC-FCUP # 15

Multitasking (or Time Sharing) Multiprogramming increases CPU utilization, but does not necessarily provide for user interaction with the computer system Multitasking (or time sharing) is a logical extension of multiprogramming that increases response time in which CPU switches jobs so frequently that users can interact with each job while it is running Gives the impression that the entire computer system is dedicated to a user s use, even though it is being shared among many users Time-sharing is based on the idea that while any single user would make inefficient use of a computer, a large group of users together would not Developing a system supporting multitasking was, at the time, a completely different concept: the state of each user and their programs would have to be kept in the system and then switched between quickly (response time should be < 1 second) DCC-FCUP # 16

Computer Startup Bootstrap program, generally known as firmware, is loaded at power-up or reboot Typically stored in read-only memory (ROM or EPROM) Initializes all aspects of the system Loads operating system kernel and starts its execution Once the kernel is loaded, it can start providing services to the users Some services are provided outside of the kernel, by system processes that are loaded at boot time (on UNIX, the first system process is the init process that starts many other system processes) Once this phase is complete, the system is fully booted, and starts waiting for some event to occur DCC-FCUP # 17

Interrupts The occurrence of an event is usually signaled by an interrupt from either the hardware or the software Hardware devices may trigger an interrupt at any time by sending a signal to the CPU to communicate that they require attention from the OS Software may trigger an interrupt by executing a special operation called a system call When the CPU is interrupted, it suspends the current activity, saving its state, and immediately transfers execution to a fixed function called an interrupt handler to deal with the event An interrupt vector contains the addresses of all the interrupt service routines On completion, the CPU resumes the interrupted computation Interrupt architecture must save the address of the interrupted instruction DCC-FCUP # 18

I/O Devices General-purpose computer systems consist of several device controllers (hardware components) that are connected through a common bus Some examples are the USB controller, the PCI controller, the IDE controller, the SCSI controller, Each device controller is in charge of a specific type of device (for example, a SCSI controller can be in charge of 4 SCSI devices) A device controller maintains some local buffer storage and a set of specialpurpose registers The device controller is responsible for moving data between the devices it controls and its local buffer storage To communicate with each device controller, operating systems require a specific device driver (software component) The device driver understands the device controller and provides the rest of the operating system with a uniform interface to the device DCC-FCUP # 19

I/O Devices To start an I/O operation, the device driver loads the appropriate registers within the device controller The controller, in turn, examines the contents of these registers to determine what action to take (e.g., read a character from the keyboard) The controller then starts the transfer of data from the device to its local buffer Once the I/O operation has completed, the device controller informs the device driver via an interrupt The device driver then returns control to the operating system DCC-FCUP # 20

Interrupt Timeline DCC-FCUP # 21

Direct Memory Access (DMA) 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 For high-speed I/O devices, able to transmit information at close to memory speeds, this problem is solved by using direct memory access Examples of hardware devices that use DMA include disk drive controllers, graphics cards, network cards, sound cards, Device controller transfers blocks of data from its own buffer storage directly to main memory, without device driver (CPU) intervention 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 DCC-FCUP # 22

Putting All Together CPU device driver memory device controller DCC-FCUP # 23

CPU Protection We cannot allow a user program to get stuck or fail and never return control back to the operating system To accomplish this goal, we can use a timer A timer can be set to interrupt the computer after a specified period The operating system sets a counter Every time the clock ticks, the counter is decremented When the counter reaches 0, an interrupt occurs If the timer interrupts, control transfers automatically to the operating system, which may treat the interrupt as a fatal error or may give the program more time to continue executing Before turning over control back to the user, the operating system ensures that the timer is set to interrupt DCC-FCUP # 24

Dual-Mode Operation A properly designed operating system must ensure that an incorrect or malicious program cannot cause other programs to execute incorrectly Examples include software errors (division by zero, infinite loops, ), processes modifying parts of others or even parts of the operating system The approach taken by most computer systems is to provide hardware support that allows us to differentiate among, at least, two separate modes of operation: User mode Kernel mode (also called supervisor, system or privileged mode) Dual-mode operation allows the operating system to protect itself and other system components DCC-FCUP # 25

Dual-Mode Operation A mode bit, provided by the hardware, indicates the current mode: Allows to distinguish when system is running user code or kernel code Some instructions, designated as privileged instructions, are only executable in kernel mode (instructions for I/O control, timer management, interrupt management, ) Interrupts or system calls change mode to kernel, return from interrupts or system calls reset it to user mode DCC-FCUP # 26

System Calls System calls provide an interface to the operating system services Typically written in a high-level language (C or C++) System calls are mostly accessed via a high-level Application Program Interface (API) rather than direct system call use Most common APIs are Win32 API for Windows, POSIX API for POSIXbased systems (including virtually all versions of UNIX, Linux, and Mac OS X), and Java API for the Java virtual machine (JVM) Why use APIs rather than invoking directly the system calls? Program portability, the same program must compile and run on any system that supports the same API System calls can be more detailed and difficult to work with than the API available to an application programmer (nevertheless, many of the POSIX and Windows APIs are similar to the native system calls provided by the OS) DCC-FCUP # 27

Example of System Calls System call sequence to copy the contents of one file to another file DCC-FCUP # 28

System Call Implementation Typically, a number is associated with each system call and the system call interface maintains a table indexed according to these numbers The system call interface invokes the intended system call in the OS kernel and returns status of the system call and any return values The caller need to know nothing about how the system call is implemented Just needs to obey API and understand what OS will do as a result Most details of OS interface are hidden from the programmer by the API DCC-FCUP # 29

System Call Implementation DCC-FCUP # 30

Examples of Types of System Calls System calls can be grouped roughly into six major categories: Process control File manipulation Device manipulation Information maintenance Communication Protection DCC-FCUP # 31