Controlling 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.
Lesson 10-Controlling User Processes. Overview Managing and processing processes. Managing jobs. Exiting/quitting when jobs have been stopped.
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
Process Process: the UNIX abstraction of a stand-along computer that manages resources (memory, CPU, I/O resources) comprising a running program. Processes.
1 Process Description and Control Chapter 3. 2 Process Management—Fundamental task of an OS The OS is responsible for: Allocation of resources to processes.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
3.5 Interprocess Communication
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.
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.
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.
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
Guide to Linux Installation and Administration, 2e1 Chapter 10 Managing System Resources.
Process Control. Module 11 Process Control ♦ Introduction ► A process is a running occurrence of a program, including all variables and other conditions.
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+ Guide to Linux Certification, Second Edition Chapter 10 Managing Linux Processes.
CE Operating Systems Lecture 10 Processes and process management in Linux.
Scis.regis.edu ● CS 468: Advanced UNIX Class 4 Dr. Jesús Borrego Regis University 1.
System calls for Process management
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.
4300 Lines Added 1800 Lines Removed 1500 Lines Modified PER DAY DURING SUSE Lab.
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.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 2.
System calls for Process management Process creation, termination, waiting.
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.
Threads prepared and instructed by Shmuel Wimer Eng. Faculty, Bar-Ilan University 1July 2016Processes.
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:
Chapter 4 – Thread Concepts
Processes and threads.
Process Management Process Concept Why only the global variables?
PROCESS MANAGEMENT IN MACH
CS 6560: Operating Systems Design
Chapter 4 – Thread Concepts
Using Processes.
Unix Process Management
Processes A process is a running program.
Processes in Unix, Linux, and Windows
UNIX PROCESSES.
KERNEL ARCHITECTURE.
Structure of Processes
Process Models, Creation and Termination
Chapter 2: The Linux System Part 2
Processes in Unix, Linux, and Windows
CHAPTER 8 ( , ) John Carelli, Instructor Kutztown University
Process Description and Control
Process Description and Control
Threads Chapter 4.
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Process Description and Control
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 in Unix
CSE 153 Design of Operating Systems Winter 2019
Process Description and Control in Unix
Structure of Processes
Presentation transcript:

Controlling Processes Chapter 4

Chapter 4 - Controlling Processes Introduction A process is the abstraction used by UNIX to represent a running process. It is the object through which a program’s use of memory, processor time, and I/O resources can be managed and monitored Chapter 4 - Controlling Processes

Chapter 4 - Controlling Processes Introduction It is part of the UNIX philosophy that as much work as possible be done within the context of processes, rather than be handled specially by the kernel. Although portions of the kernel cannot be made to fit this model, it is used by most system software. System and user processes all follow the same rules, so you can use a single set of tools to control them both. Chapter 4 - Controlling Processes

1. Components of a Process Introduction: A process consists of an address space and a set of data structures within the kernel. The address space is a set of memory pages that the kernel has marked for the process’s use. It contains the code and libraries that the process is executing, the process’s variables, its stacks, and various extra information needed by the kernel while the process is running. Chapter 4 - Controlling Processes

1. Components of a Process The kernel’s internal data structures record various pieces of information about each process. Some of the more important of these are: The process’s address space map The current status of the process (sleeping, stopped, runnable, ..) The execution priority of the process Information about the resources the process has used (for accounting purposes) The process’s signal mask (which signals are blocked) The owner of the process. Now let’s look at the meaning and significance of the parameters that are interesting from the system administrator’s point of view. Chapter 4 - Controlling Processes

1. Components of a Process PID: process ID number The kernel assigns a unique ID number to every process. Most commands and system calls that manipulate processes require you to specify a PID to identify the target of the operation PIDs are assigned in order as processes are created. When the kernel runs out of PIDs, it starts again at 1, skipping over PIDs that are still in use. Chapter 4 - Controlling Processes

1. Components of a Process PPID: parent PID An existing program must clone itself to create a new process. The clone can then exchange the program it is running for a different one. When a process is cloned the original is called the parent, and the copy is called the child. The PPID of a process is the PID of the parent from which it was cloned. while that parent is alive. Chapter 4 - Controlling Processes

1. Components of a Process UID and EUID: real and effective user ID The process’s UID is the user identification number of the person who created it, more accurately it is a copy of the EUID of the parent process. The EUID is the “effective” user ID used to determine what resources and files a process has permission to access Why have both? It is useful to maintain a distinction between identity and permission Chapter 4 - Controlling Processes

1. Components of a Process GID and EGID: real and effective group ID The GID is the group identification number of a process. The EGID is related to the GID in the same was that the EUID is related to the UID. If a process tries to access a file for which it does not have owner permissions, the kernel will automatically check to see if permission may be granted on the basis of the EGID On some systems, a process can be in more than one group at a time. Chapter 4 - Controlling Processes

1. Components of a Process Niceness A process’s scheduling priority determines how much CPU time it receives. The kernel uses a dynamic algorithm to compute priorities taking into account the amount of CPU time that a process has recently consumed and the length of time it has been waiting to run. It also takes into consideration an administratively set value that’s usually called the “nice value” or “niceness” We will come back to niceness in Section 6. Chapter 4 - Controlling Processes

1. Components of a Process Control terminal The control terminal determines the linkages for stdin, stdout, and stderr. The concept of a control terminal also affects the distribution of signals We will discuss signals more in Section 3. Chapter 4 - Controlling Processes

2. The Life Cycle of a Process To create a new process, a process copies itself with the fork system call. fork creates a copy of the original process. The copy has a distinct PID and has its own accounting information. fork returns two different values from the child’s point of view it returns 0 the parent, on the other hand is returned the PID of the child Chapter 4 - Controlling Processes

2. The Life Cycle of a Process After fork, the child will often use one of the exec family of system calls to begin executing a new program. Before a process can be allowed to disappear completely, UNIX requires that its death be acknowledged by the process’s parent They do this with a call to wait. If the parent dies first, the orphan is adopted by init Chapter 4 - Controlling Processes

Chapter 4 - Controlling Processes 3. Signals Signals are process-level interrupt requests. About 30 different kinds are defined and they are used in a variety of ways. They can be sent among processes as a means of communication They can be sent by the terminal driver to kill, interrupt, or suspend a process <CTRL-C> and <CTRL-Z> They can be sent by the administrator to achieve various results. They can be sent by the kernel when a process commits an infraction (division by 0) Chapter 4 - Controlling Processes

Chapter 4 - Controlling Processes 3. Signals When a signal is received, one of two things can happen. If the receiving process has designated a handler routine for that particular signal, the handler is called with information about the context in which the signal was delivered. Otherwise the kernel takes some default action many terminate the process some also generate a core dump Chapter 4 - Controlling Processes

Chapter 4 - Controlling Processes 3. Signals Specifying a handler routine is often referred to as “catching the signal” When the handler completes, execution restarts from the point at which the signal was received just like an interrupt To prevent signals from arriving, programs can request that they be either ignored or blocked. Ignored are thrown away Blocked are queued until they are unblocked (and only handled once) Chapter 4 - Controlling Processes

Chapter 4 - Controlling Processes 3. Signals Chapter 4 - Controlling Processes

Chapter 4 - Controlling Processes 4. KILL: Send Signals The kill program is most often used to terminate a process. It can also send any signal. kill [-signal] pid signal is the number or symbolic name of the signal to be sent. pid is the process id number of the target process kill -9 pid will “guarantee” that the process will die because signal 9 (kill) cannot be caught. You have to reboot to eliminate those that will not die this way (they are stuck) Chapter 4 - Controlling Processes

Chapter 4 - Controlling Processes 5. Process States A process is not automatically eligible to receive CPU time just because it exists. There are essentially four execution states that you need to be aware of Runnable - the process can be executed Sleeping - the process is waiting for some resource Zombie - the process is trying to die Stopped - the process is suspended (not allowed to execute) Chapter 4 - Controlling Processes

6. Nice and Renice: Influence Scheduling Priority The “niceness” of a process is a numeric hint to the kernel about how the process should be treated in relationship to other processes contending for the CPU. This determines how nice you are going to be to other users of the system. High nice means low priority, Low or negative value means high priority. Chapter 4 - Controlling Processes

Chapter 4 - Controlling Processes 7. PS: Monitor Processes ps is the system administrator’s main tool for monitoring processes. Understanding ps output is an important administrative skill Looking at the ps listing you can determine (among other things) What processes are running. How much CPU and memory they are using Who owns them Chapter 4 - Controlling Processes

8. Top: Monitor Processes Even Better Since the commands like ps offer only a one-time snapshot of your system, it is often difficult to grasp the big picture of what’s really happening. top is a free utility that runs on many systems that provides a regularly updated summary of active processes and their use of resources Chapter 4 - Controlling Processes

Chapter 4 - Controlling Processes 9. Runaway Processes Runaway processes come in two flavors User processes that use up excessive amounts of system resources sometimes you have to investigate to see if they are legit (doing real computation) or malicious. System processes that suddenly go berserk and exhibit wild behavior. Chapter 4 - Controlling Processes

Chapter 4 - Controlling Processes