The Structure of Processes. What is a Process? an instance of running program Program vs process(task) Program : just a passive collection of instructions.

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

Chapter 3 Process Description and Control
Processes & Threads Today Next Time Process concept Process model
Day 11 Processes. Operating Systems Control Tables.
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 Processes Professor Jennifer Rexford
1 Processes and Pipes COS 217 Professor Jennifer Rexford.
Processes CSCI 444/544 Operating Systems Fall 2008.
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.
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.
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
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.
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.
Lecture 5 Process, Thread and Task September 22, 2015 Kyu Ho Park.
Today’s Topics Introducing process: the basic mechanism for concurrent programming –Process management related system calls Process creation Process termination.
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.
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,
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.
1 Chapter 2.1 : Processes Process concept Process concept Process scheduling Process scheduling Interprocess communication Interprocess communication Threads.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
CE Operating Systems Lecture 10 Processes and process management in Linux.
System calls for Process management
Operating Systems Processes 1.
1 Chapter 4 Processes R. C. Chang. 2 Linux Processes n Each process is represented by a task_struct data structure (task and process are terms that Linux.
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.
Processes CS 6560: Operating Systems Design. 2 Von Neuman Model Both text (program) and data reside in memory Execution cycle Fetch instruction Decode.
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.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
LINUX System : Lecture 7 Process Bong-Soo Sohn Lecture notes acknowledgement : The design of UNIX Operating System.
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
Concurrency, Processes, and System calls Benefits and issues of concurrency The basic concept of process System calls.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
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.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
What is a Process ? A program in execution.
System calls for Process management Process creation, termination, waiting.
S ALVATORE DI G IROLAMO (TA) Networks and Operating Systems: Exercise Session 1.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
A process is a program in execution A running system consists of multiple processes – OS processes Processes started by the OS to do “system things” –
Process Management Process Concept Why only the global variables?
Structure of Processes
Processes in Unix, Linux, and Windows
Processes in Unix, Linux, and Windows
More examples How many processes does this piece of code create?
Processes in Unix, Linux, and Windows
System Structure and Process Model
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Lecture 6: Multiprogramming and Context Switching
Chapter 3: Processes.
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Operating Systems: A Modern Perspective, Chapter 6
Processes in Unix, Linux, and Windows
Processes in Unix and Windows
CS510 Operating System Foundations
Process Description and Control in Unix
Process Description and Control in Unix
EECE.4810/EECE.5730 Operating Systems
Presentation transcript:

The Structure of Processes

What is a Process? an instance of running program Program vs process(task) Program : just a passive collection of instructions high-level program vs. binary program Process : actual execution of the instructions Several processes may be associated with one program In addition to program code, necessary resources (memory, CPU, etc) are allocated to process 2

Process in detail Program in execution having its own memory space (text, data, stack,..) One program may have many processes Independent of each other (protection) Scheduling entity Executed in CPU (having registers) Competing for system resources pid, context, priority, allocation resources 3

Memory image of a process Segment layout Text : program code Data : global variables Stack : local variables, parameters Heap : dynamically allocated space (eg. Malloc) 4 argc, argv env. variables stack heap Uninitialized data [bss] (initialized to 0 by exec) Initialized data text (code) User level context

Multi-tasking Running multiple processes in a system Requirements Which to run? (scheduling) Which memory to allocate? (virtual memory) Maintain process information (pid, state, context, …) uni-processor vs multi-processor 5

각 프로세스별 커널이 관리하여야 할 정보 task_struct Task Identification : process id, (real/effective) user-id, group-id, … Task State Task relationship : pointer to parent, siblings Scheduling information : policy, priority, counter Signal information: received signal, signal handler Memory information : virtual memory information, mm_struct File information : file descriptor tables (files_struct, fs_struct) Thread structure : CPU information(register context) Task 가 어디까지 실행했는지 기억 (PC,SP, general purpose register, 등 ) Time information : start time, CPU time Inter-Process Communication information : signal (handler), … Executable format : Resource limit 6

Task Structure 7 HW context memory context system context

Process States and Transitions Task running (ready, running) Waiting (interruptible, uninterruptible) waiting for an event or resource Stopped (task_stopped: by receiving a signal, task_traced: by debugger) Zombie Most task structures are freed. Will be dead after wait() is called. 8

Linux Scheduler select the most deserving process to run out of all of the runnable processes use simple priority based scheduling algorithm Context switch after choosing a new process to run, it saves the state of the current process (the processor specific registers and other context) being saved in the process’s task_struct data structure. It then restores the state of the new to run and gives control of the system to that process. Schduling information policy(normal/realtime,round-robin/FIFO), priority, counter 9

Process Context User-level (memory) Context Process text, data, user stack, and shared memory System level Context task structures Hardware(register) Context Program counter (PC), process status (PS) register stack pointer (SP), general-purpose registers 10

CPU execution mode place restrictions on the operations that can be performed by the process currently running in the CPU Kernel mode When the CPU is in kernel mode, it is assumed to be executing trusted software, and thus it can execute any instructions and reference any memory addresses (i.e., locations in memory). The kernel (which is the core of the operating system and has complete control over everything that occurs in the system) is trusted software, but all other programs are considered untrusted software. User mode It is a non-privileged mode in which each process (i.e., a running instance of a program) starts out. It is non-privileged in that it is forbidden for processes in this mode to access those portions of memory (i.e., RAM) that have been allocated to the kernel or to other programs.

Layout of System Memory Physical address space impossible for two processes to execute concurrently if their set of generated addresses overlapped. Virtual address space Allows many processes to share finite amount of physical memory Each process uses the same virtual addresses but reference different physical addresses Requires mechanism for translating virtual address to physical address 12

Regions Region (segment) : vm_area_struct Contiguous area of virtual address space of a process that can be treated as a distinct object to be shared or protected. Virtual address space of a process is divided into logical regions Text : a set of instructions Data : (initialized & uninitialized) data variables Stack : data structures local to a subroutine 13

Fork() concept Create a new process(child) that has the same context with the previous process(parent) 14

fork() example 15 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)

Memory image of a process (Example) 16

Before fork() 17 text stack data Segment (vm_area_struct) task_struct pid = 11 glob, buf var, pid … movl %eax, [glob] addl %eax, 1 movl [glob], %eax...

After fork() 18 memory text stack data Segment (vm_area_struct) task_struct pid = 11 Segment (vm_area_struct) task_struct pid = 12 stack data glob, buf var, pid glob, buf

Fork with COW (Copy-On-Write) 19 after fork with COW after “glob++” operation memory text stack data Segment (vm_area_struct) task_struct pid = 11 Segment (vm_area_struct) task_struct pid = 12 text stack data Segment (vm_area_struct) task_struct pid = 11 Segment (vm_area_struct) task_struct pid = 12 data

exec concept 20 header text data bss stack a.out text stack data Segment (vm_area_struct) task_struct pid = 11 stack data text Replace memory context with new binary program (loader) and execute

exec example 6 syntaxes for exec() execl(), execv(), execlp(), execvp(), execle(), execve() : will be covered in next lectures 21 int main() { printf("before exec\n"); execl("exec_example", "exec_example", 0); printf("after exec\n"); return 0; }