Operating Systemss and Multicore Programming (1DT089)

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

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

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

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

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

Chapter 1: Introduction

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

Lecture 1 Introduction (Chapter 1 of Textbook)

Chapter 1: Introduction. Chapter 1: Introduction

Chapter 1: Introduction

Introduction to Operating Systems

Chapter 1: Introduction

European University of Lefke. Instructor: Dr. Arif SARI

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on

Part I Overview Chapter 1: Introduction

CS3600 SYSTEMS AND NETWORKS

CS370 Operating Systems

CS420: Operating Systems

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

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

DM510 Operating Systems. Jacob Aae Mikkelsen

OPERATING SYSTEMS: Lesson 1: Introduction to Operating Systems

CS420: Operating Systems

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

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

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

CS370 Operating Systems

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on

Operating System Services

Four Components of a Computer System

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

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

Introduction to Computer Systems and Operating Systems

Operating System Review

Introduction to Operating Systems (Part II)

OS: An Overview. ICS332 Operating Systems

Inf2C - Computer Systems Lecture 16 Exceptions and Processor Management

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

Operating Systems Overview. Chapter 2

Announcement. Exercise #2 will be out today. Due date is next Monday

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

Part I Introduction Hardware and OS Review

Process Description and Control. Chapter 3

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on

Operating Systems Overview. Chapter 2

Process Scheduling Queues

Computer Systems II. First Two Major Computer System Evolution Steps

Operating Systems. Computer Science & Information Technology (CS) Rank under AIR 100

2.5 Hardware Protection

Hardware OS & OS- Application interface

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Introduction. What is an Operating System? A Modern Computer System. Computer System Components. What is an Operating System?

OPERATING SYSTEMS UNIT - 1

1 PROCESSES PROCESS CONCEPT The Process Process State Process Control Block 5

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

Last 2 Classes: Introduction to Operating Systems & C++ tutorial. Today: OS and Computer Architecture

CHAPTER 1 - INTRODUCTION. Jacob Aae Mikk elsen

Last class: Today: Course administration OS definition, some history. Background on Computer Architecture

Operating Systems. Introduction & Overview. Outline for today s lecture. Administrivia. ITS 225: Operating Systems. Lecture 1

Lecture 1 - Operating System Overview

CHAPTER-1: INTRODUCTION TO OPERATING SYSTEM:

EECS 3221 Operating System Fundamentals

EECS 3221 Operating System Fundamentals

Lecture 2: September 9

Announcements. Reading. Project #1 due in 1 week at 5:00 pm Scheduling Chapter 6 (6 th ed) or Chapter 5 (8 th ed) CMSC 412 S14 (lect 5)

Chapter 1: Introduction

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

OPERATING SYSTEMS OVERVIEW. Operating Systems 2015 Spring by Euiseong Seo

Misc. Third Generation Batch Multiprogramming. Fourth Generation Time Sharing. Last Time Evolution of OSs

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

Architecture and OS. To do. q Architecture impact on OS q OS impact on architecture q Next time: OS components and structure

Common Computer-System and OS Structures

CSE Opera+ng System Principles

Process Description and Control

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

by I.-C. Lin, Dept. CS, NCTU. Textbook: Operating System Concepts 8ed CHAPTER 13: I/O SYSTEMS

Operating Systems: Overview and Introduction

Operating System. Operating System Overview. Layers of Computer System. Operating System Objectives. Services Provided by the Operating System

Operating System Overview. Operating System

Some popular Operating Systems include Linux, Unix, Windows, MS-DOS, Android, etc.

Introduction CHAPTER. Practice Exercises. 1.1 What are the three main purposes of an operating system? Answer: The three main puropses are:

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Operating Systems Fundamentals. What is an Operating System? Focus. Computer System Components. Chapter 1: Introduction

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

Process Description and Control. Chapter 3

Lecture 15: I/O Devices & Drivers

Major Requirements of an OS

Introduction to Concurrency (Processes, Threads, Interrupts, etc.)

OPERATING SYSTEMS. After A.S.Tanenbaum, Modern Operating Systems, 3rd edition. Uses content with permission from Assoc. Prof. Florin Fortis, PhD

Chapter 1 Computer System Overview

Chapter 13: I/O Systems

Unit 2 : Computer and Operating System Structure

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

OPERATING SYSTEMS. G.C.E. Advanced Level ICT

What s the difference between threads/processes. Operating Systems

Lecture 4: Mechanism of process execution. Mythili Vutukuru IIT Bombay

Dinosaurs? & Dinosaur Wars. CSCI 6730 / 4730 Operating Systems. Questions? Outline & Questions. Poll? Popularity: The OS Market Share

3.1 Introduction. Computers perform operations concurrently

OPERATING SYSTEMS. P. PRAVEEN Asst.Prof, CSE

Processes and Threads. Processes and Threads. Processes (2) Processes (1)

Transcription:

Operating Systemss and Multicore Programming (1DT089) Introduction to Operating Systemss (Chapter 1) Wednesday january 23 Uppsala University 2013 karl.marklund@it.uu.se

Chapter 1: Introduction Chapter objectives: To provide a grand tour of the major components of operating systems. To describe the basic organization of computer systems. The text book used in the course

From transistor to logical gates How can transistors be used to construct logical gates? NOT NAND NOR

An inverter - Logical NOT Vin Vout A X low high 0 1 high low 1 0

Logical NOR V1 V2 Vout A or B a nor b = not (A or B) 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 1 0 1 0 Low è 0 High è 1

Logical NAND V1 V2 Vout A and B A nand B = not (A and B) 0 0 1 0 1 0 1 0 0 1 1 0 0 0 1 1 1 0 1 0 Low è 0 High è 1

Ripple adder Using a few logical gates, we can construct circuits capable of adding binary numbers. A B Cout Cin S

The von Neuman Model Central Processing Unit ALU

A quick recap of computer architecture

User 1 User 2 User 3 User N Compiler Spreadsheet Text Editor Pacman System and Application Programs Operating System Controls the hardware and coordinates its use among the various application programs for the various user. Computer Hardware

1.1.1) User View Computer system Single user, one computer (PC). Operating System Design Concerns Designed for one user to monopolize its resources. The goal is to maximize the work (or play) that the single user is performing. Designed mostly for ease of use. Some attention paid to performance and none paid to resource utilization. Terminals connected to a mainframe Users share the resources and may exchange information. Designed to maximize resource utilization: Assure that all available CPU time, memory, and I/O are used efficiently. Assure that no individual user takes more than her fair share. Workstations connected to networks of other workstations and servers. Designed to compromise between individual usability and resource utilization. The users have dedicated resources at their disposal, but they also share resources such as networking and servers (file storage, computation, printing). Handheld computers (and smart phones). Usually standalone units for individual use. Designed mostly for individual usability, but performance per unit of battery life is important as well.

1.1.2) System View From the computer s point of view, the operating system is the program most intimately involved with the hardware. The operating system can be seen as a resource allocator: CPU time Memory space File storage space I/O devices etc... An operating system Controls the hardware and coordinates its use among the various application programs for the various user.. Facing numerous and possibly conflicting requests for resources, the operating system must decide how to allocate them to specific programs and users. An operating systems is a control program, a program that manages the execution of user programs to prevent errors and improper use of the computer.

What is the definition of an operating system? The common functions of controlling and allocating resources are brought together into one piece of software: the operating system. The operating system is the program running at all times on the computer, this program is usually called the kernel. The text book used in the course

1.2.1) A typical modern computer system CPU Disk Controller USB Controller Graphics Adapter Memory

1.2.1) A typical modern computer system CPU Disk Controller USB Controller Graphics Adapter The CPU and the device controllers can execute in parallel, competing for memory cycles. Memory Controller Memory To ensure orderly access to the shared memory, a memory controller is provided whose function is to synchronize the access to the memory.

Operating System Controls the hardware and coordinates its use among the various application programs for the various users. Bootstrap Program Kept on chip (ROM or EEPROM), aka firmware. Small program executed on power up or reboot. Initializes all aspects of the system, from CPU register to device controllers to memory content. Locates and loads the kernel into memory for execution. Kernel The part of the operating system that is running at all times. On boot, starts executing the first process such as init. Waits for some event to occur... CPU Disk Controller USB Controller Graphics Adapter Computer Hardware Memory Controller Memory

What kind of events? How will the kernel know when some event has occurred?

CPU executing instructions, User Generates an interrupt signal Presses a key on the keyboard. While executing, the CPU listens for interrupt signals. When an interrupt is received, the CPU immediately stops what it is doing and transfers execution to a fixed location in memory. The CPU resumes execution of the interrupted instruction Service routine for all interrupts Examine the interrupt and jump to interrupt specific service routine. Service routine for keyboard interrupt Some action is taken handling the interrupt. When done, control is transferred back to the interrupted instruction

Interrupt handling must be fast... Only a (small) number of predefined interrupts...

CPU executing instructions, Generates interrupt #1 User While executing, the CPU listens for interrupt signals. Use an interrupt vector table in memory to look up interrupt specific service routine. Interrupt Vector Index Address 0 1 2... N -1 Presses a key on the keyboard. Service routine for interrupt # 1 in this example, a keyboard interrupt The CPU resumes execution of the interrupted instruction A common technique is to use a interrupt vector table. This makes is easy and fast to dispatch to the correct service routine (interrupt handler). Interrupt vectors are used by both Windows and Unix.

A single program cannot in general keep either the CPU or the I/0 devices busy at all times. Is this something to be worried about? If so, what can be done about it? Solution: let the OS keep several jobs (programs) in memory at the same time and switch between them.

1.4) Multiprogramming CPU The OS keeps several Jobs in memory at the same time. Job 1 Job 2 Job 3 Job 4

1.4) Multiprogramming CPU The OS keeps several Jobs in memory at the same time. Job 1 Executing Job 2 One Job is chosen for execution and the status is changed to executing. Job 3 Job 4

1.4) Multiprogramming CPU The OS keeps several Jobs in memory at the same time. Job 1 Waiting Job 2 Job 3 One Job is chosen for execution and the status is changed to executing. Eventually, the job may have to wait for some task, such as an I/O operation. The status of the executing job is changed to waiting. Job 4

1.4) Multiprogramming CPU The OS keeps several Jobs in memory at the same time. Job 1 Waiting Job 2 Job 3 One Job is chosen for execution and the status is changed to executing. Eventually, the job may have to wait for some task, such as an I/O operation. The status of the executing job is changed to waiting. Job 4

1.4) Multiprogramming CPU The OS keeps several Jobs in memory at the same time. Job 1 Waiting Job 3 Executing Job 2 One Job is chosen for execution and the status is changed to executing. Eventually, the job may have to wait for some task, such as an I/O operation. The status of the executing job is changed to waiting. Instead of being idle waiting for the task to complete, the OS simply switches to another job. Job 4

1.4) Multiprogramming CPU The OS keeps several Jobs in memory at the same time. Job 1 Job 3 Executing Job 2 One Job is chosen for execution and the status is changed to executing. Eventually, the job may have to wait for some task, such as an I/O operation. The status of the executing job is changed to waiting. Instead of being idle waiting for the task to complete, the OS simply switches to another job. Job 4 Eventually the task job 1 is waiting for will complete and job 1 will change status from waiting to ready to run.

Nice, multiprogramming keeps the CPU quite busy despite individual jobs waiting for I/O etc. This seems good if we want to maximize the CPU utilization. But......each job might execute quite some time before any other job gets a spin on the CPU...

We must ensure that the operating system maintains control over the CPU. We cannot allow a user program to get stuck in an infinite loop or to fail to call system services and never return control to the operating system. To accomplish this goal, we can use a timer. The timer can be set to interrupt the computer after a specified period. Solution?

How can we implement a variable timer? A variable timer is generally implemented by a fixed-rate clock and a counter. Every time the clock tics, the counter is decremented. When the counter reaches zero, an interrupt occurs.

1.4) Multitasking (timesharing) CPU A logical extension of multiprogramming Job 1 Executing Ready Ready to to Job 2 Job 3 Job 4

1.4) Multitasking (timesharing) CPU A logical extension of multiprogramming Job 1 Executing Job 2 On Job is chosen for execution and the status is changed to executing. Job 3 Job 4

1.4) Multitasking (timesharing) A logical extension of multiprogramming CPU Timer Interrupt Job 1 Executing Job 2 Job 3 On Job is chosen for execution and the status is changed to executing. A timer is used to enforce interrupts to be sent to the CPU at regular intervals. The status of the executing job is changed to. Timer Job 4

1.4) Multitasking (timesharing) A logical extension of multiprogramming CPU Timer Interrupt Job 1 Executing Ready Ready to to Job 2 Job 3 On Job is chosen for execution and the status is changed to executing. A timer is used to enforce interrupts to be sent to the CPU at regular intervals. The status of the executing job is changed to. Timer Job 4

1.4) Multitasking (timesharing) A logical extension of multiprogramming CPU Timer Interrupt Job 1 Executing Ready Ready to to Job 2 Job 3 On Job is chosen for execution and the status is changed to executing. A timer is used to enforce interrupts to be sent to the CPU at regular intervals. The status of the executing job is changed to. Timer Job 4

1.4) Multitasking (timesharing) A logical extension of multiprogramming CPU Timer Interrupt Job 1 Executing Ready Ready to to Job 3 Executing Job 2 On Job is chosen for execution and the status is changed to executing. A timer is used to enforce interrupts to be sent to the CPU at regular intervals. The status of the executing job is changed to. A new job is selected to utilize the CPU Timer Job 4 The switching between jobs is so fast that the user can interacts with each program as if they were all executing in parallel. An executing job can still be taken of the processor by other interrupts (for example I/O) and the status changed to waiting.

Definition A program loaded into memory and executing (or waiting) is called a process. When a process executes, it typically executes for only a short time before it either finishes or needs to perform I/O (waiting). Definition If several jobs are ready to be brought into memory, and if there is not enough room for all of them, then the OS must choose among them. Making this decision is called job scheduling. Definition If several jobs are ready to run at the same time, the OS must choose among them. Making this decision is called CPU scheduling.

What if the memory is to small to fit all processes? What if a process is to large to fit in memory?

Definition Processes can be swapped in and out of main memory to disk storage, this is called swapping. Definitions To allow execution of a process that is not completely in memory, virtual memory can be used. This allows users to run programs that are larger than the actual physical memory. Virtual memory abstracts main memory into a large, uniform array of storage, separating logical memory as viewed by the user from physical memory.

Key-presses on a keyboard might happen at any time. Even if a program is run multiple times with the same input data, the timing of the key presses will most likely vary. Read- and Write requests to disk is similar to key presses. The disk controller is external to the program and the timing of a disk operation might vary even if the same program is executed several times. Interrupts are external and asynchronous.

overflow, division by zero and bad data address are examples of internal errors in a program. For the same input, the same errors will occur at the same place every time. Exceptions are internal and synchronous. Another name for exception is trap. A trap (or exception) is a software generated interrupt. User programs can request service from the OS by generating a special system call trap.

1.5.1) Dual-Mode Operation Needs to protect the OS from user programs. Also need to protects users from each other. The approach taken by most computer systems is to provide hardware support that make it possible to differentiate among various modes of execution. At the very least we need two separate modes. User Process User Mode user process executing performs a system call return from system call mode bit = 1 Kernel (OS) trap execute the requested system call Kernel Mode mode bit = 0 When a user application request a service from the operating system (via a system call), it must transition from user to kernel mode to fulfill the request.

1.5.1) Dual-Mode Operation Needs to protect the OS from user programs. Also need to protects users from each other. How does the mode bit help us with this? The machine instructions that may cause harm are treated as privileged instructions. The hardware only allows privileged instructions to be executed in kernel mode. If an attempt is made to execute a privileged instructions in user mode, this is illegal and the hardware traps into the OS to deal with this. As for now, here is a small example set of privileged instructions The instruction to switch to kernel mode. I/O control instructions. Timer management instructions. Interrupt management instructions.

1.6) Program vs. Process A program is a passive entity - a collection of binary machine instructions on disk (or cd, usb-stick, etc...). A process is: an active entity. the unit of work in a system. a program in execution. A process need resources: CPU time State (to save the content of all registers on a context switch) memory. files and I/O devices. A single threaded process uses one program counter specifying the next instruction to be executed. A multi threaded process uses multiple program counters, each pointing to the next instruction to execute for a given thread.

1.6) Process management - preview of chapter 3-6 A process is the unit of work in a system. Such a system consists of a collection of processes: some of which are operating-system processes. and, the rest of which are user processes. All these processes can potentially execute concurrently - by multiplexing on a single CPU for example. The operating system is responsible for: Scheduling processes and threads on the CPU(s). Creating and deleting both user and system processes. Suspending and resuming processes. Providing mechanisms for process synchronization. Providing mechanisms for process communication.

1.6) Process management - preview of chapter 3-6? State PCB = Process Control Block

1.7) Memory management - preview of chapter 8 & 9 The main memory is generally the only large storage device that the CPU is able to address and access directly. CPU Memory Controller Disk USB Graphics Memory For the CPU to process data from disk, data must first be transferred to main memory by CPU-generated I/O calls. In the same way, instructions must be in memory for the CPU to execute them. The operating system is responsible for the following activities in connection with memory management: Keeping track of which parts of memory are currently being used and by whom. Deciding which processes (or parts thereof) and data to move into and out of memory. Allocating and deallocating memory space as needed.