LINUX System : Lecture 7 Process Bong-Soo Sohn Lecture notes acknowledgement : The design of UNIX Operating System.

Slides:



Advertisements
Similar presentations
Process Management.
Advertisements

Chapter 3 Process Description and Control
 2004 Deitel & Associates, Inc. All rights reserved. 1 Chapter 3 – Process Concepts Outline 3.1 Introduction 3.1.1Definition of Process 3.2Process States:
Processes & Threads Today Next Time Process concept Process model
CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
Process Control Hua LiSystems ProgrammingCS2690Process Control Page 1 of 41.
1 Operating Systems and Protection CS Goals of Today’s Lecture How multiple programs can run at once  Processes  Context switching  Process.
1 Processes Professor Jennifer Rexford
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
Context switch in Linux
Structure of Processes
Page 1 Processes and Threads Chapter 2. Page 2 Processes The Process Model Multiprogramming of four programs Conceptual model of 4 independent, sequential.
1 Operating Systems and Protection Professor Jennifer Rexford CS 217.
Introduction to Kernel
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
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.
Processes and Resources
CSSE Operating Systems
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Process Description and Control A process is sometimes called a task, it is a program in execution.
University of Pennsylvania 9/12/00CSE 3801 Multiprogramming CSE 380 Lecture Note 3.
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
Process. Process Concept Process – a program in execution Textbook uses the terms job and process almost interchangeably A process includes: – program.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Processes Tarek Abdelzaher Vikram Adve.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
LINUX System Programming with Processes. Overview 1. What is a Process? 2. fork() 3. exec() 4. wait() 5. Process Data 6. File Descriptors across Processes.
Introduction to Processes CS Intoduction to Operating Systems.
Lecture 5 Process, Thread and Task September 22, 2015 Kyu Ho Park.
PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.
Multiprogramming CSE451 Andrew Whitaker. Overview Multiprogramming: Running multiple programs “at the same time”  Requires multiplexing (sharing) the.
The Structure of Processes. What is a Process? an instance of running program Program vs process(task) Program : just a passive collection of instructions.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
The Structure of Processes (Chap 6 in the book “The Design of the UNIX Operating System”)
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
LINUX System : Lecture 7 Bong-Soo Sohn Lecture notes acknowledgement : The design of UNIX Operating System.
4P13 Week 3 Talking Points 1. Process State 2 Process Structure Catagories – Process identification: the PID and the parent PID – Signal state: signals.
Concurrency & Context Switching Process Control Block What's in it and why? How is it used? Who sees it? 5 State Process Model State Labels. Causes of.
Chapter 4 Process Abstraction Chien-Chung Shen CIS, UD
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
1 A Seven-State Process Model. 2 CPU Switch From Process to Process Silberschatz, Galvin, and Gagne  1999.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
1 Structure of Processes Chapter 6 Process State and Transition Data Structure for Process Layout of System Memory THE DESIGN OF THE UNIX OPERATING SYSTEM.
Processes 2 Introduction to Operating Systems: Module 4.
Introduction to Kernel
Operating Systems Engineering
Processes.
Anton Burtsev February, 2017
Overview of today’s lecture
Unix Process Management
Operating Systems: A Modern Perspective, Chapter 6
Processes in Unix, Linux, and Windows
IT 344: Operating Systems Module 4 Processes
Structure of Processes
Processes in Unix, Linux, and Windows
Processes in Unix, Linux, and Windows
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Lecture 6: Multiprogramming and Context Switching
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Processes in Unix, Linux, and Windows
IT 344: Operating Systems Winter 2008 Module 4 Processes
Processes in Unix and Windows
CS510 Operating System Foundations
Process Description and Control
Process Description and Control in Unix
Process Description and Control in Unix
Structure of Processes
Presentation transcript:

LINUX System : Lecture 7 Process Bong-Soo Sohn Lecture notes acknowledgement : The design of UNIX Operating System

2 Process Management

What is Process? Definition –an instance of a running program (runnable program) –an execution environment of a program –scheduling entity –a control flow and address space –PCB (Process Control Block) : proc. table and U area Manipulation of Process –create, destroy –context –state transition dispatch (context switch) sleep, wakeup swap

Process State Transition user running kernel running zombie initial (idle) fork ready to run suspended ready asleep suspended asleep return from syscall or interrupt syscall, interrupt swtchsleep, lock wakeup, unlock exit wait swap swtch (Source : UNIX Internals)

Context proc table U area segment tablepage table memory disk fd file table Registers (TSS) eip sp eflags eax cs context : system context, address (memory) context, H/W context …. swap

Context : system context System context –proc. Table identification: pid, process group id, … family relation state sleep channel: sleep queue scheduling information : p_cpu, p_pri, p_nice,.. signal handling information address (memory) information –U area (swappable information) stores hardware context when the process is not running currently UID, GID arguments, return values, and error status for system call signal catch function file descriptor usage statistics

Context : address context fork example  guess what can we get from this program? intglob = 6; charbuf[] = “a write to stdout\n”; int main(void) { int var; pid_t pid; var = 88; write(STDOUT_FILENO, buf, sizeof(buf)-1); printf(“before fork\n”); if ((pid = fork()) == 0) {/* child */ glob++; var++; } else sleep(2);/* parent */ printf(“pid = %d, glob = %d, var = %d\n”, getpid(), glob, var); exit (0); } (Source : Adv. programming in the UNIX Env., pgm 8.1)

Context : address context fork internal : compile results test.c gcc header text data bss stack user’s perspective (virtual address) … movl %eax, [glob] addl %eax, 1 movl [glob], %eax... glob, buf var, pid text data stack kernel 0xffffffff 0xbfffffff 0x0 a.out Executable and Linking Format

Context : address context fork internal : before fork (after run a.out) cf) we assume that there is no paging mechanism in this figure. memory text stack data segment T. proc T. pid = 11 glob, buf var, pid

Context : address context fork internal : after fork – address space : basic protection barrier memory text stack data segment T. proc T. pid = 11 segment T. proc T. pid = 12 stack data glob, buf var, pid glob, buf

Context : address context fork internal : with COW (Copy on Write) mechanism after fork with COW after “glob++” operation memory text stack data segment T. proc T. pid = 11 segment T. proc T. pid = 12 text stack data segment T. proc T. pid = 11 segment T. proc T. pid = 12 data

12 Context : address context execve internal header text data bss stack a.out memory text stack data segment T. proc T. pid = 11 stack data text

13 Context : hardware context time sharing (multitasking) process 1 process 2 process 3 time quantum … Where am I ??

14 Context : hardware context brief reminds the 80x86 architecture ALU Control Unit Registers INOUT eip, eflags eax, ebx, ecx, edx, esi, edi, … cs, ds, ss, es,... cr0, cr1, cr2, cr3, GDTR, TR,...

15 Context : hardware context context swtch U area Proc T.TSS eip sp eflags eax cs CPU U area Proc T.TSS eip sp eflags eax cs restore context save context

16 Context : hardware context context swtch : pseudo-code in UNIX … /* need context swtch */ if (save_context()) { /* pick another process to run from ready queue */ …. restore_context(new process) /* The control does not arrive here, NEVER !!! */ } /* resuming process executes from here !!! */ …... (Source : The Design of the UNIX OS)