Process Process: the UNIX abstraction of a stand-along computer that manages resources (memory, CPU, I/O resources) comprising a running program. Processes.

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
Chapter 5 Controlling Processes Xiaoli Jiao 6/8/99.
Using tcpdump. tcpdump is a powerful tool that allows us to sniff network packets and make some statistical analysis out of those dumps. tcpdump operates.
Lesson 10-Controlling User Processes. Overview Managing and processing processes. Managing jobs. Exiting/quitting when jobs have been stopped.
CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang
Process Description and Control
UNIX Process Control Bach 7 Operating Systems Course Hebrew University Spring 2007.
Controlling Processes & Periodic Processes WeeSan Lee
CS 311 – Lecture 14 Outline Process management system calls Introduction System calls  fork()  getpid()  getppid()  wait()  exit() Orphan process.
Linux+ Guide to Linux Certification, Second Edition
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.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
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.
Ceng Operating Systems Chapter 2.1 : Processes Process concept Process scheduling Interprocess communication Deadlocks Threads.
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.
UNIX Processes. The UNIX Process A process is an instance of a program in execution. Created by another parent process as its child. One process can be.
UNIX System Administration Handbook Chapter 4. Controlling Processes 3 rd Edition Evi Nemeth et al. Li Song CMSC691X Summer 2002.
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.
Introduction to Processes CS Intoduction to Operating Systems.
Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University.
Linux+ Guide to Linux Certification, Third Edition
Processes and Threads CS550 Operating Systems. Processes and Threads These exist only at execution time They have fast state changes -> in memory and.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
1 Chapter 2.1 : Processes Process concept Process concept Process scheduling Process scheduling Interprocess communication Interprocess communication Threads.
Linux+ Guide to Linux Certification, Second Edition Chapter 10 Managing Linux Processes.
CE Operating Systems Lecture 10 Processes and process management in Linux.
Agenda  Working with Processes: Purpose Running Programs within same process (execl, execlp, execle, execv, execvp, execve) “Spawning” other process (fork,
Scis.regis.edu ● CS 468: Advanced UNIX Class 4 Dr. Jesús Borrego Regis University 1.
Scis.regis.edu ● CS 468: Advanced UNIX Class 5 Dr. Jesús Borrego Regis University 1.
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,
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.
Operating Systems Process Creation
UNIX Signals * POSIX-Defined Signals * Signaling Processes * Signal Mask * sigaction * kill and sigaction * alarm * Interval Timers * POSIX.1b Timers *
Operating Systems Recitation 4, April th, 2002 Signals.
4300 Lines Added 1800 Lines Removed 1500 Lines Modified PER DAY DURING SUSE Lab.
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
1 Process Description and Control Chapter 3. 2 Process A program in execution An instance of a program running on a computer The entity that can be assigned.
ACCESS CONTROL. Components of a Process  Address space  Set of data structures within the kernel - process’s address space map - current status - execution.
CSC414 “Introduction to UNIX/ Linux” Lecture 3
1 Lecture 19: Unix signals and Terminal management n what is a signal n signal handling u kernel u user n signal generation n signal example usage n terminal.
Unix System Administration Controlling Processes Chapter 5.
Process Manipulation. Process Manipulation in UNIX Basic process manipulation: creation, program loading, exiting, … fork(), exec(), wait(), exit() Process.
Linux Basics Part 1 OSU Picture © Greg Keene. Introductions Lance Albertson Greg Lund-Chaix source:
Process Management Process Concept Why only the global variables?
Unix Process Management
Structure of Processes
Processes in Unix, Linux, and Windows
Process Models, Creation and Termination
Processes in Unix, Linux, and Windows
Process Description and Control
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Process Description and Control
Process Description and Control
Controlling Processes
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Processes in Unix, Linux, and Windows
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
CS510 Operating System Foundations
Process Description and Control
Process Description and Control in Unix
Process Description and Control in Unix
Presentation transcript:

Process Process: the UNIX abstraction of a stand-along computer that manages resources (memory, CPU, I/O resources) comprising a running program. Processes do not share memory (default), but communicate messages using IPC. Many processes may be executing at the same time (concurrently) by time slice or quantum (20 millisecond)

Process Components of a Process administrator can monitor the status of processes control how much of the CPU’s time a process gets send signals to a process suspend or halt a process’s execution Threads in a processes. Components of a Process address space: a set of data structures inside the kernel

Process Components of a Process (cont.) address space: a set of memory pages that the kernel has marked for the use of the process segments for the program code that process is executing variables stack various extra info needed by the kernel while executing process owner

Process Components of a Process (cont.) a set of data structures inside the kernel the process’s address space map current status of the process execution priority info about the resources used signal mask process owner

Process PID (Process ID) PPID (Parent’s PID) kernel assign a unique process identification number to each newly created process PPID (Parent’s PID) UNIX does not supply a system call that create a new process running a particular program. Instead, an existing process clone (fork) itself to create a new process

Process the original process is called parent, the clone is called child. int kidpid; if((kidpid = fork()) == 0){ /* this is the child process */ } else { /* this is the parent */ } UID and EUID user ID who creates the process only creator and administrator can make change

Process GID and EGID Priority and Nice value group # in /etc/group and GID field of /etc/passwd some systems allow a user belong to more than one group Priority and Nice value a process’s priority determines how much CPU time it will receive (internal priority) impossible to set the internal priority directly possible to change the process’s nice value

Process Control Terminal other factors affecting process’s priority: amount of CPU time consumed, waiting time Control Terminal Most processes have a control terminal associated with them Control terminal determines default linkage for the standard input, output, and error. Shell’s terminal becomes the process’s terminal

The Life cycle of a Process fork() system call to create a new process new process is identical to the creator except: new process has a distinct unique PID PPID is the creator’s PID new process’s accounting info is reset new process has its own copy of file descriptors a new process usually use one of exec family system calls to begin execution of a new program execl(“/bin/ls”,, “ls”, “/usr/bin”, (char *)0);

The Life cycle of a Process init process has PID 1. init is responsible for forking a shell to execute the rc startup scripts all processes except the ones kernel creates are descendants of init init is also responsible for login process

The Life cycle of a Process init is also responsible for process management when a process completes, it calls _exit to notify kernel that it is ready to die. it supplies a exit code (0 means sucsessful) to _exit to tell why the process is exiting. Then release address space and go to zombie state The exit code is kept for the process’s parent, so the parent knows the process (its child) exits the kernel store the exit code until parent call wait system call if the parent exits after its child

The Life cycle of a Process However, if parent exits before its child, the responsibility of calling wait is given to init. Init may not does this job correctly, resulting in a zombie state to be left on the system usually cannot be killed does not cause any real problem

Process State Transition Diagram 1 User Running Interrupt, interrupt return Sys call interrupt Return to user return 9 2 7 exit preempt Preempted Zombie Kernel Running reschedule sleep Ready to Run in Memory Asleep in Memory 4 3 wakeup Created Enough mem 8 Swapout Swapout fork Swapin 6 5 wakeup Sleep, Swapped Not enough mem Ready to Run, Swapped

Command kill kill - Sends a signal to a running process SYNOPSIS kill [-signal_name | -signal_number] process_ID default is SIGTERM (15), which terminates processes that do not ignore or catch the signal. special PIDs: 0: signal is sent to all processes having a process group ID equal to sender’s process group ID, except PIDs 0 and 1.

Command kill -1: If sender’s EUID  0 (root), signal is sent to all processes with a GID = sender’s GUID, except PIDs 0 and 1. -1: If sender’s EUID = 0 (root), signal is sent to all processes, excluding 0 and 1. Kill -l: : Lists signal names HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM URG STOP TSTP CONT CHLD TTIN TTOU IO XCPU

Command kill kill 0: This command sends the SIGTERM signal to all members of the shell process group. This includes all background processes started with &. Although the signal is sent to the shell, it has no effect because the shell ignores the default signal 15. kill -KILL 0: terminates all of your processes and logs yourself out sends SIGKILL to all members of shell process group. Because shell cannot ignore SIGKILL, this also terminates the login shell and logs you out. If you are using multiple windows, this closes the active window.

Signal event kill -KILL -1: terminate all the processes that you own: sends SIGKILL to all the processes that you own, even those that belong to other process groups. If you are using multiple windows, closes all the windows. kill -KILL 17285 15692 sends SIGKILL to processes 17285 and 15692. The SIGKILL signal usually cannot be ignored or caught. kill -USR1 1103 sends SIGUSR1 signal to process 1103. The action taken on SIGUSR1 signal is defined by the particular application you are running.

Signal event When a process receives a signal, 2 things happen if process has designated a handler routine for the signal, the routine is called with info about the context in which the signal was delivered. Otherwise, kernel takes some default actions: actions vary from signal to signal terminate the process or core dump

Signal catch a signal: specify a handler routine when the handler completes, execution restarts at the point where the signal was received ignore or block a signal: set mask command (ssetmask) ignored signal has no effect on process blocked signals are queued until an explicit unblocking event is activated. Table 5.1

Unix signals Name description default catch block dump 1 HUP hangup terminate Y Y N core 2 INT interrupt terminate Y Y N 3 QUIT quit terminate Y Y Y 9 KILL kill terminate N N N a BUS bus error terminate Y Y Y a SEGV segment fault terminate Y Y Y 15TERM software termination terminate Y Y N a STOP stop stop N N N a TSTP keyboard stop stop Y Y N a CONT continue after stop ignore Y N N a USR1/USR2 user-defined terminate Y Y N

Signal usage of signals Examples: communication between processes interrupt|terminate process by control terminal Examples: <control-C> on the keyboard: terminal driver receives the character, sends INT or TERM to the active processterminate or abort program send a STOP or TSTP signal to stop a process (put it into sleep) and a CONT signal to restart the stopped process

Signal process can be stopped in the following ways: user request <control-Z> is typed to an interactive process background process try to access its control terminal Nice value: a hint to kernel to determine how much CPU time a process can get compared to other processes Lower nice value --> high priority BSD: -19 ~+19 ATT: 0 ~ 39