ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.

Slides:



Advertisements
Similar presentations
3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process An operating system executes a variety of programs: Batch system.
Advertisements

Operating Systems COMP 4850/CISG 5550 Processes Introduction to Threads Dr. James Money.
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.
Introduction to Processes
The Process Model.
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.
Unix Processes.
1 What is a Process ? The activity of program execution. Also called a task or job Has associated with it: Code Data Resources A State An executing set.
CSCE 351: Operating System Kernels
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
CSSE Operating Systems
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Process Concept An operating system executes a variety of programs
BINA RAMAMURTHY UNIVERSITY AT BUFFALO System Structure and Process Model 5/30/2013 Amrita-UB-MSES
CE Operating Systems Lecture 5 Processes. Overview of lecture In this lecture we will be looking at What is a process? Structure of a process Process.
Processes and Threads.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication in Client-Server.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
Process by Dr. Amin Danial Asham. References Operating System Concepts ABRAHAM SILBERSCHATZ, PETER BAER GALVIN, and GREG GAGNE.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
8-Sep Operating Systems Yasir Kiani. 8-Sep Agenda for Today Review of previous lecture Process scheduling concepts Process creation and termination.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
Computer Studies (AL) Operating System Process Management - Process.
Processes – Part I Processes – Part I. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Review on OSs Upon brief introduction of OSs,
11/13/20151 Processes ICS 240: Operating Systems –William Albritton Information and Computer Sciences Department at Leeward Community College –Original.
Operating Systems Processes 1.
CS212: OPERATING SYSTEM Lecture 2: Process 1. Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Linux Processes Travis Willey Jeff Mihalik. What is a process? A process is a program in execution A process includes: –program counter –stack –data section.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
Processes Dr. Yingwu Zhu. Process Concept Process – a program in execution – What is not a process? -- program on a disk - a process is an active object,
 Process Concept  Process Scheduling  Operations on Processes  Cooperating Processes  Interprocess Communication  Communication in Client-Server.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Chapter three.  An operating system executes a variety of programs:  A batch system executes jobs.  A time-shared systems has user programs or tasks.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Operating System Components) These components reflect the services made available by the O.S. Process Management Memory Management I/O Device Management.
Lecture 3 Process.
Chapter 3: Processes.
Chapter 3: Process Concept
Topic 3 (Textbook - Chapter 3) Processes
Process Management Presented By Aditya Gupta Assistant Professor
Processes Overview: Process Concept Process Scheduling
Chapter 3: Process Concept
Chapter 3: Processes.
System Structure and Process Model
Chapter 3: Processes.
System Structure and Process Model
CGS 3763 Operating Systems Concepts Spring 2013
Lecture 2: Processes Part 1
System Structure B. Ramamurthy.
System Structure and Process Model
Operating Systems Lecture 6.
Process & its States Lecture 5.
Chapter 3: Processes.
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Chapter 3: Processes.
Processes in Unix and Windows
CS510 Operating System Foundations
Chapter 3: Process Management
Presentation transcript:

ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH

ITEC502 컴퓨터 시스템 및 실습 2 Contents 1.Processes –Process Concept –The Process Model –Process Creation –Process Termination –Process Hierarchies –Process States –Implementation of Processes

ITEC502 컴퓨터 시스템 및 실습 3 Process Concept  An operating system executes a variety of programs: –Batch system – jobs –Time-shared systems – user programs or tasks  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

ITEC502 컴퓨터 시스템 및 실습 4 Process in Memory  Current activity of a process is represented by –the value of program counter –The contents of the processor ’ s registers  Stack –contains temporary data –function parameters, return address, local variables  Data section –contains global variables  Heap –is a memory that is dynamically allocated during process run time  Program is a passive entity  Process is a active entity  Two processes may be associated with the same program

ITEC502 컴퓨터 시스템 및 실습 5 Processes: The Process Model  Multiprogramming of four programs  Conceptual model of 4 independent, sequential processes  Only one program active at any instant

ITEC502 컴퓨터 시스템 및 실습 6 Process Creation (1) Principal events that cause process creation 1.System initialization 2.Execution of a process creation system 3.User request to create a new process 4.Initiation of a batch job

ITEC502 컴퓨터 시스템 및 실습 7 Process Creation (2)  Parent process create children processes, which, in turn create other processes, forming a tree of processes – via create-process system call  Three possibilities in terms of resource sharing –Parent and children share all resources –Children share subset of parent ’ s resources –Parent and child share no resources, child receives resources from OS directly  Two possibilities in terms of execution –Parent and children execute concurrently –Parent waits until children terminate

ITEC502 컴퓨터 시스템 및 실습 8 Process Creation (3)  Two possibilities in terms of address space –Child is a duplicate of parent; child has same program and data as the parent –Child has a program loaded into it  UNIX examples –fork system call creates new process –exec system call used after a fork to replace the process ’ memory space with a new program

ITEC502 컴퓨터 시스템 및 실습 9 fork() & exec()  A new process is created by the fork() system call  The new process consists of a copy of the address space of the original process  Both processes (parent & child) continue execution at the instruction after the fork().  The return code for the fork() is zero for the child process, whereas the (nonzero) pid of the child process is returned to the parent  The exec() loads a binary file into memory, destroys the memory image of the program, and starts its execution

ITEC502 컴퓨터 시스템 및 실습 10 C Program Forking – UNIX (1) int main() { pid_t pid; /* fork another process */ pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, "Fork Failed"); exit(-1); } else if (pid == 0) { /* child process */ execve("/bin/ls", "ls", NULL); } else { /* parent process */ /* parent will wait for the child to complete */ wait (NULL); printf ("Child Complete"); exit(0); }

ITEC502 컴퓨터 시스템 및 실습 11 C Program Forking – UNIX (2)

ITEC502 컴퓨터 시스템 및 실습 12 Process Creation – Win32  Windows example –CreateProcess() function is used, which is similar to fork –creates a new child process –requires loading a specified program into the address space of the child process at process creation –expects no fewer than ten parameters

ITEC502 컴퓨터 시스템 및 실습 13 C Program Forking – Wind32 (1) void _tmain( int argc, TCHAR *argv[] ) { STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); // Start the child process if( !CreateProcess( NULL, // No module name (use command line) “c:\\Windows\\system32\mspaint.exe”, // program name NULL, // Process handle not inheritable NULL, // Thread handle not inheritable FALSE, // Set handle inheritance to FALSE 0, // No creation flags NULL, // Use parent's environment block NULL, // Use parent's starting directory &si, // Pointer to STARTUPINFO structure &pi ) // Pointer to PROCESS_INFORMATION structure )

ITEC502 컴퓨터 시스템 및 실습 14 C Program Forking – Win32 (2) { printf( "CreateProcess failed (%d)\n", GetLastError() ); return; } // Wait until child process exits WaitForSingleObject( pi.hProcess, INFINITE ); // Close process and thread handles CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); }

ITEC502 컴퓨터 시스템 및 실습 15 Process Termination (1) Conditions which terminate processes 1.Normal exit (voluntary) 2.Error exit (voluntary) 3.Fatal error (involuntary) 4.Killed by another process (involuntary)

ITEC502 컴퓨터 시스템 및 실습 16 Process Termination (2)  Process executes last statement and asks the operating system to delete it (exit) –Status value returned from child to parent (via wait) –Process ’ resources are deallocated by operating system Memory, open files, I/O buffers  Parent may terminate execution of children processes (abort) with various reason –Child has exceeded allocated resources –Task assigned to child is no longer required  If parent is exiting Some operating systems do not allow child to continue if its parent terminates –All children terminated - cascading termination

ITEC502 컴퓨터 시스템 및 실습 17 Process Hierarchies  Parent creates a child process, child processes can create its own process  Forms a hierarchy –UNIX calls this a "process group"  Windows has no concept of process hierarchy –all processes are created equal

ITEC502 컴퓨터 시스템 및 실습 18 Process States (1): 3 states  Possible process states –running –blocked –ready  Transitions between states shown

ITEC502 컴퓨터 시스템 및 실습 19 Process States (2)  Lowest layer of process-structured OS –handles interrupts, scheduling  Above that layer are sequential processes

ITEC502 컴퓨터 시스템 및 실습 20 Process States – 5 states  As a process executes, it changes state –new: The process is being created –running: Instructions are being executed –waiting: The process is waiting for some event to occur –ready: The process is waiting to be assigned to a processor (CPU) –terminated: The process has finished execution  The state of a process is defined in part by the current activity of that process

ITEC502 컴퓨터 시스템 및 실습 21 Diagram of Process States  It is important to realize that only one process can be running on any processor at any instant  Many processes may be ready and waiting states

ITEC502 컴퓨터 시스템 및 실습 22 Process Control Block (PCB) (1)  Each process is represented in the operating system by a process control block (PCB)  Information associated with each process –Process state –Program counter –CPU registers –CPU scheduling information –Memory-management information –Accounting information –I/O status information

ITEC502 컴퓨터 시스템 및 실습 23 Process Control Block (PCB) (2)  Process state –New, ready, running, waiting, terminated  Program counter –The address of the next instruction to be executed for this process  CPU registers –Accumulators, index registers, stack pointers, and general-purpose registers, etc.  CPU scheduling information –Process priority, pointers to scheduling queue, etc.  Memory-management information –Value of base and limit registers, the page tables or segment tables, etc.  Accounting information –The amount of CPU and real time used, time limits, account number, job and process number  I/O status information –List of I/O devices allocated, open files, etc.

ITEC502 컴퓨터 시스템 및 실습 24 CPU Switch From Process to Process

ITEC502 컴퓨터 시스템 및 실습 25 Implementation of Processes (1) Fields of a process table entry

ITEC502 컴퓨터 시스템 및 실습 26 Implementation of Processes (2) Skeleton of what lowest level of OS does when an interrupt occurs

ITEC502 컴퓨터 시스템 및 실습 27 Summary  A process is a program in execution  As a process executes, the process may be in one of the 3 states or 5 states: –running, blocked, ready –new, ready, running, waiting, terminated  Each process is represented in the OS by its PCB  OS provides a mechanism for parent process to create a child process

ITEC502 컴퓨터 시스템 및 실습 28 Review 1.Processes –Process Concept –The Process Model –Process Creation –Process Termination –Process Hierarchies –Process States –Implementation of Processes