Processes. Operating System Concepts 8 th Edition

Similar documents
Chapter 3: Processes. Operating System Concepts Essentials 8 th Edition

Chapter 3: Processes. Operating System Concepts Essentials 2 nd Edition

Chapter 3: Processes. Operating System Concepts 9 th Edit9on

Chapter 3: Processes

COP 4610: Introduction to Operating Systems (Spring 2016) Chapter 3: Process. Zhi Wang Florida State University

Chapter 3: Process Concept

COP 4610: Introduction to Operating Systems (Spring 2014) Chapter 3: Process. Zhi Wang Florida State University

Chapter 3: Process-Concept. Operating System Concepts 8 th Edition,

CHAPTER 3 - PROCESS CONCEPT

Chapter 3: Processes. Operating System Concepts 9 th Edition

Chapter 3: Processes

Chapter 3: Processes. Chapter 3: Processes. Process in Memory. Process Concept. Process State. Diagram of Process State

Chapter 3: Processes

Chapter 3: Process Concept

Chapter 3: Process Concept

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

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

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

Chapter 3: Processes. Operating System Concepts 9 th Edition

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

Chapter 5: Processes & Process Concept. Objectives. Process Concept Process Scheduling Operations on Processes. Communication in Client-Server Systems

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

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

Chapter 4: Processes. Process Concept

Chapter 4: Processes

Killing Zombies, Working, Sleeping, and Spawning Children

Diagram of Process State Process Control Block (PCB)

Process Concept. Chapter 4: Processes. Diagram of Process State. Process State. Process Control Block (PCB) Process Control Block (PCB)

Chapter 4: Processes

Chapter 3: Processes. Operating System Concepts 8th Edition

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

Chapter 4: Processes. Process Concept

The Big Picture So Far. Chapter 4: Processes

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

Chapter 3: Process Concept

The Big Picture So Far. Chapter 4: Processes

Part Two - Process Management. Chapter 3: Processes

Processes. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & Apps 1

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

Part V. Process Management. Sadeghi, Cubaleska RUB Course Operating System Security Memory Management and Protection

Processes. Operating System Concepts with Java. 4.1 Sana a University, Dr aimen

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - III Processes. Louisiana State University. Virtual Machines Processes

2. PROCESS. Operating System Concepts with Java 8th Edition Silberschatz, Galvin and Gagn

Processes and Threads

Notice: This set of slides is based on the notes by Professor Perrone of Bucknell and the textbook authors Silberschatz, Galvin, and Gagne

CS307 Operating Systems Processes

Processes. Process Concept. The Process. The Process (Cont.) Process Control Block (PCB) Process State

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Process. Program Vs. process. During execution, the process may be in one of the following states

Lecture 2 Process Management

Process Concept Process Scheduling Operations On Process Inter-Process Communication Communication in Client-Server Systems

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

Module 4: Processes. Process Concept Process Scheduling Operation on Processes Cooperating Processes Interprocess Communication

Module 4: Processes. Process Concept Process Scheduling Operation on Processes Cooperating Processes Interprocess Communication

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - III Processes. Louisiana State University. Processes. September 1 st, 2009

CHAPTER 2: PROCESS MANAGEMENT

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

Operating System Concepts Ch. 3: Processes

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

Prepared by Prof. Hui Jiang Process. Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University

2/14/2012. Using a layered approach, the operating system is divided into N levels or layers. Also view as a stack of services

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

Process. Prepared by Prof. Hui Jiang Dept. of EECS, York Univ. 1. Process in Memory (I) PROCESS. Process. How OS manages CPU usage? No.

! The Process Control Block (PCB) " is included in the context,

OPERATING SYSTEMS. UNIT II Sections A, B & D. An operating system executes a variety of programs:

Chapter 3: Processes. Operating System Concepts 8th Edition, modified by Stewart Weiss

Chapter 4: Processes

Announcements. Operating Systems. Autumn CS4023

CS370 Operating Systems

Processes. CSE 2431: Introduction to Operating Systems Reading: Chap. 3, [OSC]

Operating System Design

Chapter 4: Processes. Process Concept. Process State

TDIU25: Operating Systems II. Processes, Threads and Scheduling

Processes COMPSCI 386

Agenda Process Concept Process Scheduling Operations on Processes Interprocess Communication 3.2

BASIC COMPUTER ORGANIZATION. Operating System Concepts 8 th Edition

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Processes and threads

csci3411: Operating Systems

Course: Operating Systems Instructor: M Umair. M Umair

Process! Process Creation / Termination! Process Transitions in" the Two-State Process Model! A Two-State Process Model!

CSI Module 2: Processes

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7

CSC 539: Operating Systems Structure and Design. Spring 2006

PROCESSES. Jo, Heeseung

Processes. Jo, Heeseung

Chapter 4: Threads. Operating System Concepts 9 th Edit9on

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

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

ICS Principles of Operating Systems

Chapters 9 & 10: Memory Management and Virtual Memory

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

Chap 4, 5: Process. Dongkun Shin, SKKU

CS 3733 Operating Systems

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

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

CSCE 313: Intro to Computer Systems

CS Lecture 2! Processes! George Mason University! Fall 2010!

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission 1

Transcription:

Processes Silberschatz, Galvin and Gagne 2009

Processes Process Concept Process Scheduling Operations on Processes Inter-process Communication Examples of IPC Systems Communication in Client-Server Systems 3.2 Silberschatz, Galvin and Gagne 2009

Objectives To introduce the notion of a process -- a program in execution, which forms the basis of all computation To describe the various features of processes, including scheduling, creation and termination, and communication To describe communication in client-server systems 3.3 Silberschatz, Galvin and Gagne 2009

Process Concept An operating system executes a variety of programs: Batch system jobs Time-shared systems user programs or tasks Textbook uses the terms job and process almost interchangeably Process a program in execution; process execution must progress in sequential fashion A process includes: program counter stack data section [data + heap] 3.4 Silberschatz, Galvin and Gagne 2009

Process vs. Program Program is a passive entity It usually found on hard drives or magnetic disks Process is an active entity The action starts when a program file loaded into memory Execution of program started via GUI event (GUI = Graphic User Interfaces) Command line entry of its name (cmd.exe, xterm, putty, ) Exec system calls (exec*(), CreateProcess, ) One program can start many processes Consider 10 instances of FireFox process (10 tabs) Consider multiple users executing the same program 3.5 Silberschatz, Galvin and Gagne 2009

Process in Memory 3.6 Silberschatz, Galvin and Gagne 2009

The Process Text section (machine code!!) program counter, processor registers Data section Consists of global and static variables that are initialized by the programmer (like C++ const/global declarations, Java Final ) Does not change at run-time Heap Dynamic memory, allocated during run time data is freed with delete, delete[], or free() (this is where memory leaks happen ) Stack containing temporary data Function arguments Return values (usually pointers to structures on the heap) local variables (C uses the stack to store local variables) 3.7 Silberschatz, Galvin and Gagne 2009

Example double PI = 3.14159 // data or text? unsigned int u = 27 // data section char * str = "No changes allowed"; // data section int foo() { char *pbuffer; // nothing allocated yet (excluding the pointer itself, // which is allocated here on the stack). bool b = true; // Allocated on the stack if(b) { long int x, y, z ; // Create 3 longs on the stack! (local vars) char buffer[500]; // Create 500 bytes on the stack! (local var) pbuffer = new char[500]; // Create 500 bytes on the heap! (array of char objects) } // buffer is deallocated here, pbuffer is not! } // oops there's a memory leak, should have called: // delete[] pbuffer; 3.8 Silberschatz, Galvin and Gagne 2009

Process State During its lifetime, process changes states: New The process is being created The process has been launched and is loaded to memory Ready The process is waiting to be assigned to a processor It is in memory and ready to run (scheduling) Running Instructions are being executed CPU control was given to the process and it now the CPU master Waiting The process is waiting for some event to occur wait for data write, data read, network response, child process to finish work, Terminated The process has finished execution 3.9 Silberschatz, Galvin and Gagne 2009

Diagram of Process State 3.10 Silberschatz, Galvin and Gagne 2009

Process Control Block (PCB) Data structure holding process information Process state (ready, waiting, running, ) Program counter CPU registers CPU scheduling information (priority, queues) Memory-management information (base, limit) Accounting information (run times, reads, writes, ) I/O status information (open files tables) 3.11 Silberschatz, Galvin and Gagne 2009

Process Control Block (PCB) 3.12 Silberschatz, Galvin and Gagne 2009

CPU Switch From Process to Process P1 P2 Running OS Sleeping OS Save state to PCB1 Load state from PCB2 Sleeping Running Load state from PCB1 Save state to PCB2 Running Save state to PCB1 Sleeping Load state from PCB2 Running 3.13 Silberschatz, Galvin and Gagne 2009

Process Scheduling Maximize CPU usage Optimize process time sharing by quick switches Process scheduler role is to decide among available processes for next execution on CPU Maintains scheduling queues of processes Job queue set of all processes in the system Ready queue set of all processes residing in main memory ready and waiting to execute Device queues set of processes waiting for an I/O device (per device) Processes migrate among the various queues 3.14 Silberschatz, Galvin and Gagne 2009

Process Representation in Linux Represented by the C structure task_struct pid_t pid; /* process identifier */ long state; /* state of the process */ unsigned int time_slice /* scheduling information */ struct task_struct *parent; /* this process s parent */ struct list_head children; /* this process s children */ struct files struct *files; /* list of open files */ struct mm struct *mm; /* memory management info */ struct task_struct *p_opptr, *p_pptr, *p_cptr, *p_ysptr, *p_osptr; /* op=original parent, p=parent, c=youngest child, ys=youngest siebling, os=older siebling */ 3.15 Silberschatz, Galvin and Gagne 2009

Ready Queue And Various I/O Device Queues 3.23 Silberschatz, Galvin and Gagne 2009

Representation of Process Scheduling Process is Born Process Terminates 3.24 Silberschatz, Galvin and Gagne 2009

Schedulers Long-term scheduler (or job scheduler) Selects which processes should be brought into the ready queue Selects which processes be swapped to disk Short-term scheduler (or CPU scheduler) selects which process will run next Sometimes the only scheduler in a system 3.25 Silberschatz, Galvin and Gagne 2009

Some tasks are ready-to-run init_task list run_queue Those tasks that are ready-to-run comprise a sub-list of all the tasks, and they are arranged on a queue known as the run-queue Those tasks that are blocked while awaiting a specific event to occur are put on alternative sub-lists, called wait queues, associated with the particular event(s) that will allow a blocked task to be unblocked 3.26 Silberschatz, Galvin and Gagne 2009

Schedulers (Cont.) Short-term scheduler is invoked very frequently Typically 15-60 milliseconds Must be fast! Long-term scheduler is invoked very infrequently Seconds, minutes, or hours Could be slow (disk swap is very slow ) Processes that run for days, or even sleep for days but hold large memory segments. The long-term scheduler may swap them to disk Processes can be described as either: I/O-bound process spends more time doing I/O than computations, many short CPU bursts and long I/O bursts CPU-bound process spends more time doing computations; few very long CPU bursts 3.27 Silberschatz, Galvin and Gagne 2009

Communications in Client-Server Systems Sockets Remote Procedure Calls Pipes Remote Method Invocation (Java) 3.44 Silberschatz, Galvin and Gagne 2009

Sockets A socket is defined as an endpoint for communication Concatenation of IP address and port The socket 161.25.19.8:1625 refers to port 1625 on host 161.25.19.8 Communication consists between a pair of sockets 3.45 Silberschatz, Galvin and Gagne 2009

Socket Communication 3.46 Silberschatz, Galvin and Gagne 2009

Pipes Acts as a conduit allowing two processes to communicate Issues Is communication unidirectional or bidirectional? In the case of two-way communication, is it half or fullduplex? Must there exist a relationship (i.e. parent-child) between the communicating processes? Can the pipes be used over a network? 3.49 Silberschatz, Galvin and Gagne 2009

Ordinary Pipes Ordinary Pipes allow communication in standard producer-consumer style Producer writes to one end (the write-end of the pipe) Consumer reads from the other end (the read-end of the pipe) Ordinary pipes are therefore unidirectional Require parent-child relationship between communicating processes 3.50 Silberschatz, Galvin and Gagne 2009

Ordinary Pipes 3.51 Silberschatz, Galvin and Gagne 2009

Named Pipes (FIFO) Named Pipes are more powerful than ordinary pipes Communication is bidirectional No parent-child relationship is necessary between the communicating processes Several processes can use the named pipe for communication Provided on both UNIX and Windows systems 3.52 Silberschatz, Galvin and Gagne 2009