Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 9 Working.

Slides:



Advertisements
Similar presentations
Job and Process Management
Advertisements

June 1, 1999Foreground/Background Processing1 Introduction to UNIX H. Foreground/Background Processing.
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.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process The Process A process is.
Processes and Job Control. Foreground and Background (1)  Unix is a multi-tasking operating system –some of these tasks are being done by other users.
Chapter 13 Processes. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Objectives To describe the concept of a process, and execution of.
Introduction to Unix – CS 21 Lecture 10. Lecture Overview Midterm questions Jobs and processes description The foreground and background Controlling jobs.
Process Relationships Terminal and Network Logins Process Groups and Sessions Job Control Relationships.
Lesson 10-Controlling User Processes. Overview Managing and processing processes. Managing jobs. Exiting/quitting when jobs have been stopped.
Chapter 13 Processes. What is a process? A process is a program in execution A process is created whenever an external command is executed Whenever the.
Operating Systems Yasir Kiani. 20-Sep Agenda for Today Review of previous lecture Use of FIFOs in a program Example code Process management commands.
CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang
Controlling Processes & Periodic Processes WeeSan Lee
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.
More Shell Basics CS465 - Unix. Unix shells User’s default shell - specified in /etc/passwd file To show which shell you are currently using: $ echo $SHELL.
Processes & Daemons Chapter IV / Part III. Commands Internal commands: alias, cd, echo, pwd, time External commands, code is in a file: grep, ls, more.
CS 497C – Introduction to UNIX Lecture 27: - The Process Chin-Chih Chang
5 UNIX Processes. Introduction  Processes  How to list them  How to terminate them  Process priorities  Scheduling jobs  Signals.
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.
Server Design Discuss Design issues for Servers Review Server Creation in Linux.
Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University.
Chapter 4 UNIX Common Shells Commands By C. Shing ITEC Dept Radford University.
The process concept (section 3.1, 3.3 and demos)  Process: An entity capable of requesting and using computer resources (memory, CPU cycles, files, etc).
Linux+ Guide to Linux Certification, Third Edition
Additional UNIX Commands. 222 Lecture Overview  Multiple commands and job control  More useful UNIX utilities.
Process Control. Module 11 Process Control ♦ Introduction ► A process is a running occurrence of a program, including all variables and other conditions.
SUSE Linux Enterprise Server Administration (Course 3037) Chapter 6 Manage Linux Processes and Services.
Va-scanCopyright 2002, Marchany Unit 7 – Solaris Process Control Randy Marchany VA Tech Computing Center.
Managing processes and services. 1. How Linux handles processes 2. Managing running processes 3. Scheduling processes.
Linux+ Guide to Linux Certification, Second Edition Chapter 10 Managing Linux Processes.
RH030 Linux Computing Essentials
SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Introduction to UNIX / Linux - 8 Dr. Jerry Shiao, Silicon Valley University.
Lecture – Performance Performance management on UNIX.
The kernel considers each program running on your system to be a process A process lives as it executes, with a lifetime that may be short or long A process.
Hands On UNIX II Dorcas Muthoni. Processes A running instance of a program is called a "process" Identified by a numeric process id (pid)‏  unique while.
Agenda  Working with Processes: Purpose Running Programs within same process (execl, execlp, execle, execv, execvp, execve) “Spawning” other process (fork,
EMT 2390L Lecture 5 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
Linux+ Guide to Linux Certification Chapter Eleven Managing Linux Processes.
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,
Lab 3 + Using the Terminal 1. "Under Linux there are GUIs (graphical user interfaces). where you can point and click and drag, and hopefully get work.
1 Lecture 6 Introduction to Process Management COP 3353 Introduction to UNIX.
CIT 140: Introduction to ITSlide #1 CSC 140: Introduction to IT Processes.
PTA Linux Series Copyright Professional Training Academy, CSIS, University of Limerick, 2006 © Workshop VI Scheduling & Process Management Professional.
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
Agenda Managing Processes (Jobs) Command Grouping Running jobs in background (bg) Bringing jobs to foreground (fg), Background job status (jobs) Suspending.
PROCESSES We will learn more about: ¨ Multi-user processing and multi −tasking ¨ Multi-user processing and multi −tasking ¨ Process types ¨ Process types.
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.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
An Introduction to processes R Bigelow. A Unix Process A process in Unix is simple a program The Unix system is made up of a group of processes all interacting.
Processes Todd Kelley CST8207 – Todd Kelley1.
Process Relationships Chien-Chung Shen CIS/UD
Linux Basics Part 1 OSU Picture © Greg Keene. Introductions Lance Albertson Greg Lund-Chaix source:
Foreground and background processes
Chapter 13 Processes.
Rootly Powers and Controlling Processes
The Linux Command Line Chapter 10
CHAPTER 8 ( , ) John Carelli, Instructor Kutztown University
CHAPTER 13 Processes.
CSC 140: Introduction to IT
Linux Shell Script Programming
Controlling Processes
Processes – Part I.
Process Management and System Monitoring
Lecture 6 Introduction to Process Management
Presentation transcript:

Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 9 Working with Processes

© Copyright IBM Corporation 2008 Unit Objectives After completing this unit, you should be able to: Define a Linux process Describe the relationship between parent and child processes Explain the purpose of a shell Start foreground and background processes Explain the concept of signals and use them to terminate processes Explain the concept of priorities and manage them

© Copyright IBM Corporation 2008 To see the PID of your current shell process, type: $ echo $$ Program nameUser and Group ID Internal dataProcess ID (PID) Open FilesParent PID (PPID) Current DirectoryProgram variables additional parameters process environment What Is a Process? A program is an executable file. A process is a program that is being executed. Each process has its own environment:

© Copyright IBM Corporation 2008 bashfork() exec() ls -l exit() Starting and Stopping a Process All processes are started by other processes –Parent/Child relationship $ ls –l A process can be terminated for two reasons: –The process terminates itself when done. –The process is terminated by a signal from another process.

© Copyright IBM Corporation 2008 Environment Login: Linux System login:/sbin/mingetty password:...forks /bin/bash $-bash (login shell) Program-bash UID503 (tux3) GID100 (users) open files/dev/tty1 PID201 Login Process Environment

© Copyright IBM Corporation bash bash date PIDPPID $ echo $$ 561 $ bash $ echo $$ 675 $ date Mon Jan 1 22:28:21 UTC 2007 $ $ echo $$ 561 Parents and Children

© Copyright IBM Corporation 2008 $ ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root ? S Jan1 0:05 init root ? SW Jan1 0:00 [keventd] root ? SW Jan1 0:05 [kapmd] root ? SW Jan1 0:05 [kswapd]... root pts/2 R 13:47 0:00 ps aux Monitoring Processes The ps command displays process status information ps supports a large number of options; you typically use ps aux: –aall processes attached to a terminal –xall other processes –uprovides more columns

© Copyright IBM Corporation 2008 $ pstree init-+-apmd |-atd |-crond |-gpm |-httpd---10*[httpd] |-inetd |-kattraction.kss |-kdm-+-X | `-kdm---kwm-+-kbgndwm | |-kfm | |-kpanel | |-krootwm | |-kvt---bash---man---sh-+-gunzip | | `-less | `-startkde---autorun |-kflushd Viewing Process Hierarchy pstree shows process hierarchy

© Copyright IBM Corporation 2008 Controlling Processes Processes can be controlled in two ways: –From the shell that started it, using its job number –From anywhere else on the system, using its PID Actions that can be performed on a running process: –Terminate –Kill –Stop/Continue These actions are performed by sending signals

© Copyright IBM Corporation 2008 bashwait() bash $ find / -name README $ find / -name README & Starting Processes Foreground Processes Foreground processes are invoked by simply typing a command at the command line. Background Processes Background processes are invoked by putting an "&" at the end of the command line.

© Copyright IBM Corporation 2008 jobs fg bg Suspends foreground task Lists background or suspended jobs Resume suspended task in the foreground Resume suspended task in the background Specify a job number for bg, fg, and kill using %job. Job Control in the Bash Shell

© Copyright IBM Corporation 2008 $ find / -name README & [1] 2863 $ jobs [1]+runningfind / -name README & $ fg %1 /usr/share/doc/packages/grub/README.... [1]+ stoppedfind / -name README $ bg 2863 $ jobs [1]+runningfind / -name README & $ kill %find Job Control Example

© Copyright IBM Corporation 2008 SignalKeyboardMeaningDefault action 01hangupend process 02Ctrl-Cinterruptend process 03Ctrl-\quitend process and core dump 09killend process - cannot be redefined - handled by kernel 15terminateend process Kill Signals Several signals can be sent to a process: –Using keyboard interrupts (if foreground process) –Using the kill command –Synopsis: kill -signal PID –Using the killall command to kill all named apps –Synopsis: killall -signal application Most important signals:

© Copyright IBM Corporation 2008 $ nohup find / -name README & nohup: appending output to `nohup.out´ $ logout Running Long Processes The nohup command stops a process from being killed if you log off the system before it completes, by intercepting and ignoring the SIGHUP and SIGQUIT (hangup and quit) signals.

© Copyright IBM Corporation 2008 Base priority (0) User-defined priority (negative values are allowed only to root!) Dynamic part of priority (calculated by scheduler) Reserved for kernel threads Managing Process Priorities Processes are scheduled according to priority.

© Copyright IBM Corporation 2008 $ nice -n 10 my_program & [1] 4862 $ ps l F UID PID PRI NI VSZ... COMMAND bash my_program ps l The nice Command The nice command is used to start a process with a user-defined priority. nice [-n ]

© Copyright IBM Corporation 2008 $ renice : old priority 10, new priority 15 $ ps l F UID PID PRI NI VSZ... COMMAND bash my_program ps l The renice Command The renice command is used to change the priority of a currently running process. renice

© Copyright IBM Corporation 2008 Integrated Process Management Various integrated tools exist for process management: –top, gpm, kpm Availability depends on distribution.

© Copyright IBM Corporation 2008 lpd /dev/lp0 print job 1 print job 2 print job 3 Print Queue Daemons The word daemon refers to a never-ending process, usually a system process that controls a system resource, such as the printer queue or performs a network service.

© Copyright IBM Corporation 2008 Checkpoint 1.True or False? Any user can send a signal to a process of another user, and cause this process to halt. 2.If a process is hanging, the proper order of trying to terminate it with the lowest chance of data corruption is: a.kill -1, Ctrl-C, kill, Ctrl-\ b.Ctrl-Z, kill, kill -9, kill -15, Ctrl-C c.kill -9, kill -15, Ctrl-C, Ctrl-Z d.Ctrl-C, Ctrl-\, kill, kill -9 3.What is a daemon?

© Copyright IBM Corporation 2008 Unit Summary All processes are started by a parent process (except for init, which is started by the kernel). Every process is identified with a Process Identifier (PID). A special process is the shell, which can interpret user commands. Processes can terminate by themselves, or upon reception of a signal. Signals can be sent by the shell, using a keyboard sequence, or by the kill and killall commands. Processes are started with equal priority, but this can be changed using the nice and renice commands. A daemon is a background process that typically controls a system resource or offers a network service.