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.

Slides:



Advertisements
Similar presentations
RH030 Linux Computing Essentials
Advertisements

June 1, 1999Foreground/Background Processing1 Introduction to UNIX H. Foreground/Background Processing.
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.
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.
Essential System Administration 3rd Edition Chapter 2 The Unix Way(Cont.) University Of Palestine.
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.
1 Introduction to UNIX Ke Liu
Chapter Seven Unix Shell Environments1 System Programming UNIX Shell Environments.
CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Linux+ Guide to Linux Certification, Second Edition
Now, return to the Unix Unix shells: Subshells--- Variable---1. Local 2. Environmental.
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.
Introduction to Linux/UNIX. History UNIX beginnings in 1969 (Linus Torvalds is born!) AT & T Bell Laboratories (Ken Thompson & Dennis Richie) Working.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – Shell Programming The activities of.
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.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process System Process and init.
UNIX and Shell Programming (06CS36)
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Shell The Shell The agency that.
An Introduction to Unix Shell Scripting
The UNIX Shell. The Shell Program that constantly runs at terminal after a user has logged in. Prompts the user and waits for user input. Interprets command.
CSC 322 Operating Systems Concepts Lecture - 4: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Chapter 4 UNIX Common Shells Commands By C. Shing ITEC Dept Radford University.
Linux+ Guide to Linux Certification, Third Edition
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. The Operating System Allocates memory for.
CS465 - UNIX The Bourne Shell.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
Process Control. Module 11 Process Control ♦ Introduction ► A process is a running occurrence of a program, including all variables and other conditions.
second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. Contents Why an Operating System (OS) How.
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
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.
Unix/Linux cs3353. The Shell The shell is a program that acts as the interface between the user and the kernel. –The shell is fully programmable and will.
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.
Scis.regis.edu ● CS 468: Advanced UNIX Class 4 Dr. Jesús Borrego Regis University 1.
Lecture 24CS311 – Operating Systems 1 1 CS311 – Lecture 24 Outline Final Exam Study Guide Note: These lecture notes are not intended replace your notes.
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,
Operating Systems Process Creation
Introduction to Programming Using C An Introduction to Operating Systems.
1 Lecture 6 Introduction to Process Management COP 3353 Introduction to UNIX.
Getting Started UNIX InKwan Yu Topics Unix Commands Unix System calls C function calls.
1 © 2000 John Urrutia. All rights reserved. Session 5 The Bourne Shell.
CIT 140: Introduction to ITSlide #1 CSC 140: Introduction to IT Processes.
Advanced Programming in the UNIX Environment Hop Lee.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Linux Commands C151 Multi-User Operating Systems.
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.
Module 1 - Introduction to Linux. Users must log-in Linux is case sensitive File and Directories naming conventions (No spaces!) Files and Directories.
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.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
Chapter 13 Processes.
Shell Script Assignment 1.
Unix : Introduction and Commands
CHAPTER 13 Processes.
CSC 140: Introduction to IT
Linux Shell Script Programming
Lecture 6 Introduction to Process Management
Presentation transcript:

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 a UNIX abstraction that enables to look at the files and programs in another way. A file is treated as a simple file when it lies in a document state on disk. A file can be understood as a process when it is executed.

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process The Process Like living organisms processes are born; they give birth to other processes and also die. Processes make things happen in UNIX UNIX is multitasking, hundreds or even thousands of processes can run on a large system.

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process The Process Processes belong to the domain of the kernel, which is responsible for their management. We will examine: The Process Attributes Understand the process creation To control these processes by moving them between foreground and background and killing them when they get out of control The process scheduling facilities offered by UNIX

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process Process Basics A process is simply an instance of a running program It is said to be born when the program starts execution and remains alive as long as the program is active After execution is complete, the process is said to die A process also has a name, usually the name of the program being executed; for example grep

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process Process Basics Even though a process originates from a program, a process can’t be considered synonymous with a program

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process Process Basics There are a number of ways that the two can differ First when two users run the same program, there is one program in disk, but two processes in memory Second, when you execute a shell script (also a program) containing a pipeline of three commands, you have three processes Finally, a program can split into two or more processes while it is running

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process Process Basics The shell serves the user; but the kernel handles processes Kernel manages memory and schedules processes so that each process has a fair share of the CPU and other resources Kernel provides a mechanism where a process is able to execute for a finite period of time and then relinquish control to another process Kernel saves the state of the process so that when its turn comes up again for execution, the kernel knows where to resume

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process Process Basics Process management happens so quickly making the user oblivious to the switching process Files and processes have a lot in common A process is always created by another process, so except for the first process, every process has a parent Processes also are arranged in hierarchical structure with the first process occupying the top; like the root directory of a file system

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process Process Basics Just as a directory can have multiple filenames in it, the multitasking nature of UNIX permits a process to have multiple children

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process Process Basics Files have attributes and so do processes Attributes are stored in a process table, a separate structure maintained in memory by the Kernel Process table can be referred to as the inode for the processes Process retain an entry in the table until it dies properly (will understand what proper death actually means)

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process Process Basics The process table is of finite size, there is a limit to the maximum number of processes that can run on a system Most attributes are inherited by the child from its parent; and there are some attributes that are not inherited and are allocated by the kernel when a process is born: Process Id Parent Process Id

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process Process Basics The Process-id (PID) Each process is identified by a unique integer called the Process- id (PID). It is required to control a process, for instance to kill it. The first process has the PID 0. The parent PID (PPID) The PID of the parent is also available in the process table. When several processes have the same PPID, it often makes sense to kill the parent rather than all its children separately

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process Process Basics Things can go wrong at times. A process may berserk and multiply rapidly, bringing the system to a complete standstill. However, UNIX provides us with the tools to understand the process hierarchy and control processes

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process The Shell and init At the time of login, the process representing the shell starts running at your terminal. This process may be sh, ksh, csh, or bash The shell maintains a set of environment variables, like PATH, and HOME. The shells own pathname is stored in SHELL, but its PID is stored in a special variable, $$. To know the PID of the current shell type $ echo $$ The PID of the login shell does not change as long as you are logged in. When you logout and login again, your login shell will be assigned a different PID.

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process The Shell and init The PPID of every login shell is always 1. This is the init process; init is a very important process and, apart from being the parent of users’ shells, it is also responsible for giving birth to every service that’s running in the system—like printing, mail, and so on. Commands like cat and ls run as separate processes. The shell executes a shell script by creating an extra shell process that runs each of the commands in the script. Built in commands of the shell like echo, pwd, and cd don’t create a process at all.

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process ps: Displaying Process Attributes The ps (process status) command is used to display some process attributes. ps fetches these attributes from the process table. Compare this to ls which looks up the inode to retrieve a file’s attributes. By default, ps displays the process owned by user invoking the command: {apache:~} ps PID TTY TIME CMD pts/131 0:00 bash pts/131 0:00 ksh pts/131 0:00 ps

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process ps: Displaying Process Attributes apache[kkhan:163] bash Querying terminal... Terminal recognized as vt100 (Generic VT100) {apache:~} ps PID TTY TIME CMD pts/131 0:00 bash pts/131 0:00 ksh pts/131 0:00 ps {apache:~} echo $$ {apache:~} exit exit apache[kkhan:164] echo $$ apache[kkhan:165]

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process ps: Displaying Process Attributes The login shell is ksh and has the PID of It is running at the terminal /dev/pts/131. The cumulative processer time (TIME) that has been consumed since the process started is negligible. That is to be expected because the shell is mostly sleeping—waiting for a command to be entered and waiting for it to finish. {apache:~} ps PID TTY TIME CMD pts/131 0:00 ksh pts/131 0:00 ps apache[kkhan:164] echo $$ 27489

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process ps: Displaying Process Attributes ps presents a snapshot of the process table. This picture gets outdated by the time it is displayed. On some systems you might see ps itself in the output. ps is a highly variant command; its actual output varies across different UNIX flavors.

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process ps: Displaying Process Attributes Displaying the PPID (-f) since knowing the parenting is often important, the –f option displays a fuller listing that included the PPID: $ ps –f UID PID PPID C STIME TTY TIME CMD kkhan :04:26 pts/131 0:00 bash kkhan :46:59 pts/131 0:00 - ksh kkhan :10:55 pts/131 0:00 ps -f

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process ps: Displaying Process Attributes $ps -f UID PID PPID C STIME TTY TIME CMD kkhan :14:09 pts/131 0:00 ps -f kkhan :04:26 pts/131 0:00 bash kkhan :46:59 pts/131 0:00 -ksh kkhan :14:03 pts/131 0:00 vi guess.sh kkhan :14:06 pts/131 0:00 /bin/ksh -i

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process ps: Displaying Process Attributes ps –u followed by the user-id displays the processes owned by the user-id. The –a option displays process run by all users, irrespective of their ownership. We will discuss (-e and –l) once we have see studied the process creation mechanism.

second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process ps: Displaying Process Attributes {apache:~/public_html/CS3375} ps -fu kkhan UID PID PPID C STIME TTY TIME CMD kkhan :46:59 ? 0:00 /usr/lib/ssh/sshd kkhan :04:26 pts/131 0:00 bash kkhan :46:59 pts/131 0:00 -ksh kkhan :19:33 pts/131 0:00 ps -fu kkhan ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine. It provides secure encrypted communications between two un-trusted hosts over an insecure network. sshd (SSH Daemon) is the daemon program for ssh