Multiprogramming. Evolution of OS. Today. Comp 104: Operating Systems Concepts 28/01/2013. Processes Management Scheduling & Resource Allocation

Similar documents
Introduction. CS3026 Operating Systems Lecture 01

Operating Systems Process description and control

Contents. Today's Topic: Introduction to Operating Systems

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Processes. OS Structure. OS Structure. Modes of Execution. Typical Functions of an OS Kernel. Non-Kernel OS. COMP755 Advanced Operating Systems

Processes. Process Management Chapter 3. When does a process gets created? When does a process gets terminated?

Operating Systems Overview. Chapter 2

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

OPERATING SYSTEM SUPPORT (Part 1)

Processes, PCB, Context Switch

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

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7

3.1 Introduction. Computers perform operations concurrently

Process Description and Control. Chapter 3

What is an Operating System? A Whirlwind Tour of Operating Systems. How did OS evolve? How did OS evolve?

Lecture Topics. Announcements. Today: Operating System Overview (Stallings, chapter , ) Next: Processes (Stallings, chapter

Process. Discussion session 3 1/30/2016

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)

Introduction to Processes in Computer Systems SEEM

Processes. Sanzheng Qiao. December, Department of Computing and Software

Process a program in execution; process execution must progress in sequential fashion. Operating Systems

W4118 Operating Systems. Junfeng Yang

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

Processes and More. CSCI 315 Operating Systems Design Department of Computer Science

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

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

Process Description and Control. Chapter 3

OPERATING SYSTEMS OVERVIEW

Processes and Threads

OPERATING SYSTEM. Functions of Operating System:

Introduction to Operating System. Dr. Aarti Singh Professor MMICT&BM MMU

Process Concepts 8/21/2014. CS341: Operating System. Scheduling: Theoretical Analysis

Learning Outcomes. Processes and Threads. Major Requirements of an Operating System. Processes and Threads

OPERATING SYSTEMS. COMS W1001 Introduction to Information Science. Boyi Xie

Operating System. Operating System Overview. Structure of a Computer System. Structure of a Computer System. Structure of a Computer System

Process Description and Control

* What are the different states for a task in an OS?

CSC 539: Operating Systems Structure and Design. Spring 2006

Lecture 3: Processes. CMPUT 379, Section A1, Winter 2014 January 13, 15 and 17

Operating System Overview. Chapter 2

Chapter 3 Processes. Process Concept. Process Concept. Process Concept (Cont.) Process Concept (Cont.) Process Concept (Cont.)

Module 1. Introduction:

Major Requirements of an OS

Dr. D. M. Akbar Hussain DE5 Department of Electronic Systems

Process Description and Control. Chapter 3

CSC 453 Operating Systems

Subject: Operating System (BTCOC403) Class: S.Y.B.Tech. (Computer Engineering)

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

Process Description and Control

COSC243 Part 2: Operating Systems

Unix Processes. What is a Process?

Introduction to Computer Science. Polly Huang NTU EE

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

Module 1: Introduction

ENGR 3950U / CSCI 3020U Midterm Exam SOLUTIONS, Fall 2012 SOLUTIONS

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

Operating System Overview. Operating System

CSE 153 Design of Operating Systems Fall 2018

Process Concepts. CSC400 - Operating Systems. 3. Process Concepts. J. Sumey

TYPES OF OPERATING SYSTEMS. Dimple Juneja

Announcements. Program #1. Reading. Due 2/15 at 5:00 pm. Finish scheduling Process Synchronization: Chapter 6 (8 th Ed) or Chapter 7 (6 th Ed)

Killing Zombies, Working, Sleeping, and Spawning Children

Chapter 3: Processes. Operating System Concepts 8 th Edition,

Chapter 3: Processes. Operating System Concepts 9 th Edit9on

REVIEW OF COMMONLY USED DATA STRUCTURES IN OS

Module 1: Introduction. What is an Operating System?

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

Introduction to Process in Computing Systems SEEM

OPERATING SYSTEMS. P. PRAVEEN Asst.Prof, CSE

CHAPTER 3 - PROCESS CONCEPT


PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

CSE325 Principles of Operating Systems. Processes. David P. Duggan February 1, 2011

CPS221 Lecture: Operating System Functions

Chapter 3: Processes. Operating System Concepts 8th Edition,

Slide 6-1. Processes. Operating Systems: A Modern Perspective, Chapter 6. Copyright 2004 Pearson Education, Inc.

Operating System Overview. Chapter 2

Chapter 13: I/O Systems

Processes. Process Scheduling, Process Synchronization, and Deadlock will be discussed further in Chapters 5, 6, and 7, respectively.

Chap 4, 5: Process. Dongkun Shin, SKKU

CSC 2405: Computer Systems II

Process Description and Control. Major Requirements of an Operating System

Lecture 17: Threads and Scheduling. Thursday, 05 Nov 2009

Major Requirements of an Operating System Process Description and Control

Operating Systems Overview. Chapter 2

Introduction to Computer Systems and Operating Systems

Chapter 3: Process Concept

Chapter 3: Process Concept

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

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006

ELEC 377 Operating Systems. Week 1 Class 2

Processes. CS3026 Operating Systems Lecture 05

PROCESS CONCEPTS. Process Concept Relationship to a Program What is a Process? Process Lifecycle Process Management Inter-Process Communication 2.

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

What Is A Process? Process States. Process Concept. Process Control Block (PCB) Process State Transition Diagram 9/6/2013. Process Fundamentals

Chapter 3: Process Concept

(MCQZ-CS604 Operating Systems)

Processes and Threads

Course: Operating Systems Instructor: M Umair. M Umair

Transcription:

Comp 104: Operating Systems Concepts Management Scheduling & Resource Allocation Today OS evolution Introduction to processes OS structure 1 2 Evolution of OS Largely driven by desire to do something useful when a program cannot continue (maximise throughput) Early systems: Job loaded from punched cards or tape, output to printer Job may include loading compiler, assembler, linker, data etc. CPU idle for much of the time Batch systems: Job passed to human operator Operator groups jobs into batches with similar characteristics, e.g. all programs using same compiler More efficient use of resources Multiprogramming Load several programs into memory simultaneously, all sharing single CPU When running program cannot continue (e.g. waiting for I/O), switch to another Hence, I/O and computation overlap 3 4 1

Multi-Access (Time-Sharing) An extension of multiprogramming CPU is switched rapidly between processes to give illusion of uninterrupted execution in parallel (multitasking) users can interact with programs users see their own virtual machine resources (printers, disks etc.) are shared, but this is largely transparent 5 Question The following two statements describe the performance of two programs (where the computation and input/output could be interleaved): A performs a total of 20 seconds of computation and 15 seconds of input/output. B performs a total of 30 seconds of computation and 10 seconds of I/O Which of the following are true? I. It will take up to 50 seconds to run A and B sequentially II. It will take up to 75 seconds to run A and B sequentially III. Using multiprogramming, the shortest time to execute both is 50 seconds IV. Using multiprogramming, the shortest time to execute both is 40 seconds a) I and III b) l and lv c) ll and lll d) ll and lv e) None of the above Answer: c If run sequentially, A needs to finish before B can begin, therefore II is true. With multiprogramming, I/O for one process can take pave whilst the computation takes place for another. Therefore III is true 6 Implications Operating System An Abstract View Need to decide which programs to load from disk into memory (job scheduling) Need to decide which program to execute next (CPU scheduling) Consider disk space as extension of main memory (virtual memory) Memory allocation Disk/file allocation Protection/security Device Manager User Command Interface Processor Manager Memory Manager File Manager 7 8 2

A program is a representation of an algorithm in some programming language; i.e. it is static A process refers to the activity performed by a computer when executing a program; i.e. it is dynamic A process is created when a program or Process Characteristics Process characteristics: Requires space in memory where it resides during execution During its execution it may require other resources such as data files or I/O It passes through several states from its initial creation to its completion within the computer system (more details on these states to come in later lectures) command is executed 9 10 A process needs resources, such as CPU time, memory, files and I/O devices, to accomplish its task. These resources are allocated either when the program is created, or when it is executing. Operating-system processes execute system code and user-processes execute user code All these processes could potentially execute concurrently 11 The Processor Manager is responsible for overseeing the following activities in relation to process management: Creation and deletion of both system and user processes Scheduling processes Provision of mechanisms for synchronisation and communication of processes Deadlock handling for processes 12 3

O.S. Structure Often consists of: A central nucleus or kernel resides permanently in memory performs low-level, frequently needed activity A set of processes may be system level or user level processes interact with kernel via system calls e.g. create process, run program, open file kernel and system level processes may operate in privileged mode 13 Command Interpreter Accepts and runs commands specified by user Hence provides user s view of OS May be graphical, e.g. Windows May be textual, e.g. UNIX shell bash, ksh, csh Some commands built into shell, others loaded from separate executable files Shell also has sophisticated control structures such as loops, if-statements and procedures 14 Process States State Changes Running on a uniprocessor machine, only one process can be executing at any time may be interrupted at end of time-slice if no I/O requests or system calls performed Ready refers to a process that is able to run, but does not currently have the CPU Waiting(Blocked) refers to a process that is unable to continue, even if granted the CPU new admitted ready I/O or event completion interrupt dispatch blocked terminated exit running I/O or event wait 15 16 4

Question A running process makes a system call to read data from a file. Which process state should it enter next? a) New b) Ready c) Running d) Blocked e) Terminated Answer: d Blocked; it may take some time before the file system can read the file (e.g. on a networked file store), so the process is blocked until the data is available. Process Descriptors For each process, the OS kernel maintainers a descriptor or Process Control Block (PCB) PCB contains info like unique process ID user ID of process owner process state position in memory accounting stats. (time used etc.) resources allocated (open files, devices, etc.) register values (process counter, etc) 17 18 Context Switch PCBs and Queuing When a process is interrupted all current state information (including program counter and other registers) is saved into PCB PCB is put into a queue may have several, e.g. for different devices the kernel may do some of its own work e.g. handling a system call the PCB of a process from the ready queue is selected, and its context restored Whole context switch is an expensive overhead hardware support may help The PCB of each process is updated as the process progresses from the start to the end of its execution Queues use PCBs to track the processes progress through the system. The PCBs are linked to form queues: Ready queue linking the PCBs for every ready process New queue linking the PCBs for processes just entering the system e.g. multiple register sets 19 20 5

PCBs and Queuing Queuing that are blocked are linked together by reason for waiting PCBs for these processes are linked into several queues e.g. those waiting for I/O on a specific disk drive are linked together, those waiting for a printer are linked in a different queue All queues need to be effectively managed in an order that is determined by the process scheduling policies and algorithms new admitted I/O or event completion ready blocked interrupt running dispatch Disk I/O queue Printer I/O queue Other I/O queue exit I/O request terminated 21 22 Inter-Process Communication Inter-Process Communication (IPC) mechanisms allow processes to talk to each other IPC useful when processes working together (cooperating processes) synchronisation and/or passing data For example in UNIX: signals pipes sockets 23 Signals A process can usually be terminated by typing CTRL-C Actually sends a signal to process Process responds by aborting Signals can be sent from one process to another signal() system call Signals can be sent from the command line using kill command Format: kill -<signal> <pid> e.g. kill -9 12345 sends signal 9 (kill signal) to process 12345 24 6

Responding to Signals A receiving process can respond to a signal in three ways: Perform default action (e.g. abort) Ignore the signal Catch the signal; i.e. execute a designated procedure The kill signal (signal 9) cannot be caught or ignored Guaranteed way to stop process Example kill signals 1 HUP (hang up) 2 INT (interrupt) 3 QUIT (quit) 6 ABRT (abort) 9 KILL (non-catchable, nonignorable kill) 14 ALRM (alarm clock) 15 TERM (software termination signal) 25 Pipes The UNIX command wc l file counts the number of lines in file If we just type wc l we don t get an error Instead, data is read from standard input (keyboard by default) Similarly for output files and standard output (screen) The pipe symbol attaches the standard output of one program to the standard input of another, e.g. who wc -l Common wc flags -l number of lines -w number of words -c number of characters By default, all three stats are displayed. Flags state what stats appear 26 Client-Server Examples The following are examples of common servers: Web server: accessed by client s web browser Mail server: retrieving and sending emails to clients File server: holding documents to be accessed by clients Database server: providing database services to clients, e.g. customer database, stock database etc 27 7