More examples How many processes does this piece of code create?

Slides:



Advertisements
Similar presentations
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Advertisements

Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
Thursday, June 08, 2006 The number of UNIX installations has grown to 10, with more expected. The UNIX Programmer's Manual, 2nd Edition, June, 1972.
Processes CSCI 444/544 Operating Systems Fall 2008.
Page 1 Processes and Threads Chapter 2. Page 2 Processes The Process Model Multiprogramming of four programs Conceptual model of 4 independent, sequential.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
1 CS 333 Introduction to Operating Systems Class 2 – OS-Related Hardware & Software The Process Concept Jonathan Walpole Computer Science Portland State.
Introduction to Kernel
CSCE 351: Operating System Kernels
Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
CSSE Operating Systems
CSE451 Processes Spring 2001 Gary Kimura Lecture #4 April 2, 2001.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Processes April 5, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
System Calls 1.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Introduction to Processes CS Intoduction to Operating Systems.
CSC 501 Lecture 2: Processes. Process Process is a running program a program in execution an “instantiation” of a program Program is a bunch of instructions.
Implementing Processes and Process Management Brian Bershad.
Exec Function calls Used to begin a processes execution. Accomplished by overwriting process imaged of caller with that of called. Several flavors, use.
Multiprogramming CSE451 Andrew Whitaker. Overview Multiprogramming: Running multiple programs “at the same time”  Requires multiplexing (sharing) the.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Operating System Structure A key concept of operating systems is multiprogramming. –Goal of multiprogramming is to efficiently utilize all of the computing.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Cs431-cotter1 Processes and Threads Tanenbaum 2.1, 2.2 Crowley Chapters 3, 5 Stallings Chapter 3, 4 Silberschaz & Galvin 3, 4.
What is a Process ? A program in execution.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Multiprogramming. Readings r Chapter 2.1 of the textbook.
Introduction to Kernel
Processes and threads.
Process concept.
Interrupts and signals
Protection of System Resources
CS 3305 System Calls Lecture 7.
Processes A process is a running program.
Processes in Unix, Linux, and Windows
Processes in Unix, Linux, and Windows
Lecture 5: Process Creation
Lecture 7: Introduction to Threads
Processes in Unix, Linux, and Windows
System Structure and Process Model
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Process & its States Lecture 5.
Lecture Topics: 11/1 General Operating System Concepts Processes
Operating Systems Processes (Ch 4.1).
Processes Hank Levy 1.
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Processes and Process Management
Jonathan Walpole Computer Science Portland State University
Lecture 6: Multiprogramming and Context Switching
Lecture 7: Introduction to Threads
October 7, 2002 Gary Kimura Lecture #4 October 7, 2002
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Processes in Unix, Linux, and Windows
Processes in Unix and Windows
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
CS510 Operating System Foundations
Processes Hank Levy 1.
Operating Systems Processes (Ch 2.1).
Presentation transcript:

More examples How many processes does this piece of code create? int main() { fork(); /*(Line 1)*/ fork(); /*(Line 2)*/ }

What is the output of this? int main() { int i; for (i=0; i<2; i++) { fork(); printf(“%d\n”,i); } return (0);

Lecture 6: Multiprogramming and Context Switching

Review: UNIX process memory layout Stack Heap Static data Text (program) Address space or core image

Review: Stack Frame arguments return address stack frame pointer Heap Static data Text (program) arguments return address stack frame pointer local variables To previous stack frame pointer To the point at which this function was called

Review: Creating a process via fork() Stack Heap Static data Text (program) fork() //return p Stack Heap Static data Text (program) fork() //return 0 The only way to create a new process is to use the fork system call. PC PC parent process child process process id = p

Review: Loading a new image via exec() Stack Heap Static data Text (program) exec(prog, args) prog’s stack prog’s heap prog’s static data prog’s Text before after

In this lecture Multiprogramming Process context switch

Why Multiprogramming? Imagine not having it Multiprogramming: Type in command in a shell Wait for result Can’t browse in the meanwhile! Multiprogramming: Many processes executing in parallel

Multiple Processes = Multiple Address Spaces User Kernel In this slide we view things from the point of view of the operating system, which has to deal with multiple address spaces, each belonging to a separate process. We normally think of a user process as executing user code. But when a process invokes kernel functions (by executing system calls), it switches into privileged mode and executes kernel code. Besides having its own stack in user mode, each process has a stack in the kernel for use when executing kernel code. There is also a common heap shared by all processes in the kernel, as well as the equivalents of data, BSS, and text. Copyright © 2002 Thomas W. Doeppner. All rights reserved.

Pseudoparallelism Multi-processor CPU Single processor CPU Real parallelism Single processor CPU Pseudoparallelism

The Process Model Multiprogramming 4 processes Conceptual model of 4 independent, sequential processes Only one program active at any instant

Implementation of Multiprogramming Context Switch Resources (CPU) taken away from one process and given to another Save the context of previous process and restore context of new process

Process Table Where is process table Process context Registers File management Others OS stores the context of a process in process table Each process has an entry in the process table Where is process table

When to Switch Context? When a process has reached its quota of time When a process waits for I/O When a previously started I/O has completed

Interrupt Driven Context Switch Interrupt occurs (timer or I/O) Each interrupt has its own service procedure (address given by interrupt vector) Save some context and then jump to interrupt service procedure Scheduler might context switch after the interrupt is serviced

Interrupt Implementation Skeleton of what lowest level of OS does when an interrupt occurs

Process States Possible process states running blocked ready

Summary Multiprogramming Context switching Process table Each entry stores context of a process

Will the following get speeded up with multiprogramming? Four compilations running in parallel A compilation and a text editor