Most of the work is done in the context of the process rather than handled separately by the kernel

Similar documents
Process States. Controlling processes. Process states. PID and PPID UID and EUID GID and EGID Niceness Control terminal. Runnable. Sleeping.

Linux System Administration

Unix Processes. What is a Process?

Chapter 9: Process management. Chapter 9 Process management

CPSC 341 OS & Networks. Processes. Dr. Yingwu Zhu

5/8/2012. Controlling User Processes Chapter 10

Chapter 4 Controlling Processes

Programs. Program: Set of commands stored in a file Stored on disk Starting a program creates a process static Process: Program loaded in RAM dynamic

High Performance Computing Lecture 11. Matthew Jacob Indian Institute of Science

elinks, mail processes nice ps, pstree, top job control, jobs, fg, bg signals, kill, killall crontab, anacron, at

Bamuengine.com. Chapter 7. The Process

Process Management forks, bombs, zombies, and daemons! Lecture 5, Hands-On Unix System Administration DeCal

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D)

elinks, mail processes nice ps, pstree, top job control, jobs, fg, bg signals, kill, killall crontab, anacron, at

Getting to know you. Anatomy of a Process. Processes. Of Programs and Processes

PROCESSES. At least they re not ISO-9001 processes

Processes & Signals. System Runs Many Processes Concurrently. State consists of memory image + register values + program counter

Processes. System tasks Campus-Booster ID : **XXXXX. Copyright SUPINFO. All rights reserved

Lecture Topics. Announcements. Today: Threads (Stallings, chapter , 4.6) Next: Concurrency (Stallings, chapter , 5.

Advanced Unix Concepts. Satyajit Rai

Managing Processes Process: A running program

Sperimentazioni I LINUX commands tutorial - Part II

Processes. Dr. Yingwu Zhu

Shell and Signals. Computer Organization 3/17/2015. CSC252 - Spring The World of Multiprogramming or Multitasking. Unix Process Hierarchy

ENGR 3950U / CSCI 3020U Midterm Exam SOLUTIONS, Fall 2012 SOLUTIONS

Simplest version of DayOfYear

Multitasking. Programmer s model of multitasking. fork() spawns new process. exit() terminates own process

Signals: Management and Implementation. Sanjiv K. Bhatia Univ. of Missouri St. Louis

Design Overview of the FreeBSD Kernel CIS 657

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent?

Processes. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Processes in linux. What s s a process? process? A dynamically executing instance of a program. David Morgan. David Morgan

Computer Systems II. First Two Major Computer System Evolution Steps

CPSC 457 OPERATING SYSTEMS MIDTERM EXAM

User Commands ps ( 1 )

Process management. What s in a process? What is a process? The OS s process namespace. A process s address space (idealized)

An introduction to checkpointing. for scientifc applications

Programming Assignments will be.. All the PAs are continuous 3 major factors that you should consider

CSE 451: Operating Systems Winter Module 4 Processes. Mark Zbikowski Allen Center 476

Processes. CS 416: Operating Systems Design, Spring 2011 Department of Computer Science Rutgers University

Processes. CS3026 Operating Systems Lecture 05

Shell Execution of Programs. Process Groups, Session and Signals 1

Process Concepts. CSC400 - Operating Systems. 3. Process Concepts. J. Sumey

Process Control. Philipp Koehn. 23 April 2018

Operating Systems. Lecture 05

Layers in a UNIX System. Create a new process. Processes in UNIX. fildescriptors streams pipe(2) labinstructions

CSCE Operating Systems Interrupts, Exceptions, and Signals. Qiang Zeng, Ph.D. Fall 2018

Shells and Processes. Bryce Boe 2012/08/08 CS32, Summer 2012 B

CSE 410: Computer Systems Spring Processes. John Zahorjan Allen Center 534

Lecture 24: Multitasking and Signals

Operating Systems Lab 1 (Users, Groups, and Security)

System Programming. Introduction to Unix

Operating System Structure

S E C T I O N O V E R V I E W

Killing Zombies, Working, Sleeping, and Spawning Children

CS213. Exceptional Control Flow Part II. Topics Process Hierarchy Signals

Unix-Linux 2. Unix is supposed to leave room in the process table for a superuser process that could be used to kill errant processes.

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 20

Lesson 3. The func procedure allows a user to choose the action upon receipt of a signal.

Advanced Unix/Linux System Program. Instructor: William W.Y. Hsu

Operating Systems Process description and control

Signals. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Exceptions, Processes and Signals

Processes. Operating System CS 217. Supports virtual machines. Provides services: User Process. User Process. OS Kernel. Hardware

KING FAHD UNIVERSITY OF PETROLEUM AND MINERALS Information and Computer Science Department ICS 431 Operating Systems Lab # 6

System Calls and Signals: Communication with the OS. System Call. strace./hello. Kernel. Context Switch

PROCESSES. Jo, Heeseung

Processes. Jo, Heeseung

Processes. What s s a process? process? A dynamically executing instance of a program. David Morgan

(MCQZ-CS604 Operating Systems)

Processes. Sanzheng Qiao. December, Department of Computing and Software

Processes. Process Management Chapter 3. When does a process gets created? When does a process gets terminated?

OPERATING SYSTEMS: Lesson 4: Process Scheduling

NAME top display top CPU processes. SYNOPSIS top [ ] [d delay] [p pid] [q] [c] [C] [S] [s] [i] [n iter] [b]

COSC243 Part 2: Operating Systems

CS631 - Advanced Programming in the UNIX Environment. Process Groups, Sessions, Signals

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

Mid Term from Feb-2005 to Nov 2012 CS604- Operating System

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7

Signals and Session Management. Signals. Mechanism to notify processes of system events

CSci 4061 Introduction to Operating Systems. Processes in C/Unix

Exceptional Control Flow Exists at All Levels of a System. Systemprogrammering 2007 Föreläsning 3 Exceptional Control Flow Part II

CS 4410, Fall 2017 Project 1: My First Shell Assigned: August 27, 2017 Due: Monday, September 11:59PM

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission 1

ECF Exists at All Levels of a System Exceptional Control Flow Part II Oct. 22, 2002 Topics! Process Hierarchy! Shells! Signals!

ECE 650 Systems Programming & Engineering. Spring 2018

Lecture 4: Process Management

Chap 4, 5: Process. Dongkun Shin, SKKU

Processes. CS439: Principles of Computer Systems January 24, 2018

Exceptional Control Flow Part II

Processes. CS439: Principles of Computer Systems January 30, 2019

Processes & Threads. (Chapter 3) CS 4410 Operating Systems. [R. Agarwal, L. Alvisi, A. Bracy, M. George, E. Sirer, R. Van Renesse]

Each terminal window has a process group associated with it this defines the current foreground process group. Keyboard-generated signals are sent to

PROCESS CONTROL: PROCESS CREATION: UNIT-VI PROCESS CONTROL III-II R

CSC374, Spring 2010 Lab Assignment 1: Writing Your Own Unix Shell

CSC 539: Operating Systems Structure and Design. Spring 2006

The Classical OS Model in Unix

Signals, Synchronization. CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han

* What are the different states for a task in an OS?

Transcription:

Process Control Process Abstraction for a running program Manages program s use of memory, cpu time, and i/o resources Most of the work is done in the context of the process rather than handled separately by the kernel Components of a process Address space Set of pages allocated to the process by the kernel Code and libraries being executed by the process (code segment) Variable space (data segment) Stack A set of data structures within the kernel Process address space map Current state of the process (R, S, T, Z) Execution priority Resources used by the process Signal mask to know the signals to be blocked Owner of the process Process may have information about each execution context, or thread Scheduling is on process level and not thread level Threads have little impact on system administration at present Common parameters of a process from system administration viewpoint pid Assigned by the kernel Unique for every process Most important information to identify any process PPID UID and EUID UID is initialized from the EUID of the parent GID and EGID Nice value Control terminal Determines default linkages for stdin, stdout, and stderr Life cycle of a process

Process Control 2 Created by fork(2) Program text changed by one of the calls from the exec family The grand-ancestor of every process is init with pid as 1 Process termination Process terminates by calling _exit(2) It supplies an integer to _exit(2) to identify the reason for termination; 0 (or EXIT_SUCCESS) for successful termination Process death must be acknowledged by its parent, by using a call to wait(2) Parent picks up the reason for termination and a summary of the child s use of resources If child outlives its parent, it is adopted by init who performs the last rites upon child s death Signals Process-level interrupt requests Used for communication among processes Used to kill, interrupt, or suspend a process from terminal driver Sent by administrator to achieve different tasks Sent by kernel to issue a trap, or to report synchronous errors Signal is handled by a designated handler function, or the default handler provided by kernel Handler catches the signal After catching the signal, execution resumes from the point where signal is caught Signals can be ignored or blocked by a process Ignored signal is simply discarded Blocked signal is queued for delivery till the time the process unblocks the signal The handler for a newly unblocked signal is called only once even if there are several signals waiting when it is unblocked Signals of interest to system administrators on Solaris (complete list available in /usr/include/sys/signal.h) # Name Description Default Catch Block Dump core 1 HUP Hangup Terminate Y Y N 2 INT Interrupt (rubout) Terminate Y Y N 3 QUIT Quit Terminate Y Y Y 9 KILL Kill Terminate N N N 10 BUS Bus error Terminate Y Y Y 11 SEGV Segmentation violation Terminate Y Y Y 15 TERM Software termination signal from kill Terminate Y Y N 16 USR1 User defined signal 1 Terminate Y Y N 17 USR2 User defined signal 2 Terminate Y Y N 20 WINCH Window size change Ignore Y Y N 23 STOP Stop Stop N N N 24 TSTP User stop requested from tty Stop Y Y N 25 CONT Stopped process continued Ignore Y Y N Signal names are prefixed with SIG in the file

Process Control 3 HUP provides a reset request for daemons, or if possible, makes the daemon to read the configuration file again without restarting It is used to clean up or kill the process associated with the tty when the user logs out C shell family shells make the background processes immune to HUP Bourne shell family shells need to emulate the behavior with nohup command INT is sent by terminal driver in response to ^C Simple programs should quit (if signal is caught), or allow themselves to be killed (if signal is not caught) Programs waiting for user input should stop what they are doing, clean up, and wait for user input again QUIT is similar to TERM but produces a core dump if not caught KILL terminates a process at os level and is not receivable by the process TERM is a request to terminate execution completely kill to send signals Process states Five execution states for a process in Unix O Running Process is running on a processor S Sleeping Process is waiting for an event to complete R Runnable Process is on run queue; ready to run Z Zombie Process terminated and parent not waiting T Trace Process is stopped, either by a job control signal or because it is being traced Stopped processes are administratively forbidden to run Processes are stopped by STOP or TSTP signals Restarted with CONT Stopped is similar to sleeping except that the process has to be explicitly woken up (or killed) by some other process nice and renice to influence scheduling priority Numeric hint to kernel about process priority Higher nice value implies lower priority Negative nice value implies higher priority Higher the number, lower the priority Priority assigned to a process can be changed by changing its nice value, using the command nice The processes can only be made more nice (decrease priority) by users, superuser can make the processes less nice (increase priority) Each process is assigned a default nice value of 20 Example

Process Control 4 nice -10 sort foo will execute the command at a lower priority Most common nice value range is from 20 to +19 Newly created process inherits the nice value from parent The kernel may increase the nice value for process that use excessive cpu time Confusion due to shell-built-in nice and system nice commands ps to monitor processes sys v vs bsd versions Without options, the ps command lists the processes of the user who invoked the command $ ps PID TTY TIME CMD 29677 pts/3 0:00 xbiff 29676 pts/3 0:04 xdaliclo 29739 pts/3 0:01 vi 29681 pts/3 0:02 xdvi.bin 29742 pts/3 0:00 tcsh 29659 pts/3 0:01 tcsh $ Here, the command displays the process id, the controlling terminal, the cpu time used, and the name of the command or program We can get a more detailed listing of the processes by using the -l option (for long) with the ps command $ ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 8 R 122 318 315 1 81 20 f60b2488 459 pts/3 0:00 tcsh 8 S 122 51 49 0 51 20 f625f720 522 f625f918 pts/3 0:02 tcsh 8 S 122 93 51 0 40 20 f61da8d8 708 f5d04b26 pts/3 0:00 xbiff 8 S 122 92 51 0 40 20 f5fc51f0 624 f5f80836 pts/3 0:22 xdaliclo 8 S 122 315 51 0 61 20 f625fde0 367 f5e10738 pts/3 0:00 vi 8 S 122 160 51 0 41 20 f5fc36f0 903 f5f805b6 pts/3 0:02 xdvi.bin $ The fields can be described as follows

Process Control 5 Field F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD Description Associated flag; for historical reasons only; no special meaning Running state of the process (as defined previously) User identifier Process identifier Parent process identifier Processor utilization for scheduling (obsolete) Priority of the process Nice value (for scheduling) Address in memory Data and stack segment size combined (in Kbytes) Address of an event for which the process is waiting Controlling terminal Cumulative execution time for the process Command being executed (up to first 80 characters) Another useful option with ps is -e which lists all the processes currently active on the system Monitoring processes with top Regularly updated summary of active processes and their use of resources Runaway processes Processes that use up too much of cpu resources Could be legitimate, or buggy, or malicious (like password cracker) If problem occurs in /tmp and it is a filesystem by itself, the partition can be reinitialized by the newfs command Job control with background and foreground processes A job is a process that is either running in the background, or is stopped Processes in the background continue to run but do not make the shell to wait for their termination before putting the prompt You can have many processes running in the background at the same time When you issue a command on the shell, you cannot do any further work until it terminates You can abort it by sending it a signal by pressing ^C Job control is used to control multiple processes Allows placing the jobs into foreground or background, and move them from foreground to background or vice versa You can suspend the jobs temporarily, and restart them later A running command can be suspended by pressing ^Z key After the command is suspended, user is presented with a new shell prompt Suspended commands can be later resumed at the point where they were suspended The command is resumed in foreground by typing fg on shell prompt

Process Control 6 The command is resumed in background by typing bg on shell prompt Checking on the jobs associated with the terminal session Use the command jobs Job control commands are summarized as: Command & CTRL-Z bg fg jobs kill stop suspend Action Run the preceding command in background Suspend a foreground job Run a suspended job in the background Run the command in foreground (from suspended or background) List active and suspended jobs in the background Terminate a job Suspend a background job (not in ksh) Equivalent of CTRL-Z in ksh