CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang

Slides:



Advertisements
Similar presentations
June 1, 1999Foreground/Background Processing1 Introduction to UNIX H. Foreground/Background Processing.
Advertisements

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.
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 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.
Shells and Processes Bryce Boe 2012/08/08 CS32, Summer 2012 B.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Chapter Seven Unix Shell Environments1 System Programming UNIX Shell Environments.
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.
Now, return to the Unix Unix shells: Subshells--- Variable---1. Local 2. Environmental.
CS 497C – Introduction to UNIX Lecture 36: - Customizing the Environment Chin-Chih Chang
CS 497C – Introduction to UNIX Lecture 34: - Shell Programming Chin-Chih Chang
The UNIX Shells 1. What is a Unix shell? 2. A few common shells in the Unix & Linux. A. Bourne shell B. Korn shell C. C shell D. Bash-the default shell.
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 4: Understanding the UNIX Command Chin-Chih Chang
Introduction to Linux/UNIX. History UNIX beginnings in 1969 (Linus Torvalds is born!) AT & T Bell Laboratories (Ken Thompson & Dennis Richie) Working.
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.
Welcome to CSE  Name: Di Cao   Classroom: DL357  Class Time: T 8:30am - 9:18am  Office.
UNIX and Shell Programming (06CS36)
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Unix Shells Based on Glass & Abels’ Book CS240 Computer Science II.
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
Chapter 4 UNIX Common Shells Commands By C. Shing ITEC Dept Radford University.
Linux+ Guide to Linux Certification, Third Edition
Additional UNIX Commands. 222 Lecture Overview  Multiple commands and job control  More useful UNIX utilities.
UNIX/LINUX Shells Shell is an UNIX/LINUX command interpreter. Shell command can be internal or external. The code to execute an internal command is part.
1 Logging in to a UNIX System init ( Process ID 1 created by the kernel at bootstrap ) spawns getty for every terminal device invokes our login shell terminal.
CS465 - UNIX The Bourne Shell.
1 Week 2 The Crunchy Shell to the Soft and Chewy Kernel… Sarah Diesburg 8/3/2010 COP4610 / CGS5765.
Linux+ Guide to Linux Certification, Second Edition Chapter 10 Managing Linux Processes.
RH030 Linux Computing Essentials
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.
Introduction to UNIX Road Map: 1. UNIX Structure 2. Components of UNIX 3. Process Structure 4. Shell & Utility Programs 5. Using Files & Directories 6.
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.
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
CS4315A. Berrached:CMS:UHD1 Process Management Chapter 6.
Unix – Linux CS3353 Ssystem Administration. OS The Operating System – Acts as the interface to all software, hardware, and users of a computer. – Requires.
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.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Module 1 - Introduction to Linux. Users must log-in Linux is case sensitive File and Directories naming conventions (No spaces!) Files and Directories.
Lecture 02 File and File system. Topics Describe the layout of a Linux file system Display and set paths Describe the most important files, including.
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.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
CS241 Systems Programming Discussion Section Week 2 Original slides by: Stephen Kloder.
Comp 145 – Introduction to UNIX $200 $400 $600 $800 $1000 $200 $400 $600 $800 $1000 $200 $400 $600 $800 $1000 $200 $400 $600 $800 $1000 UNIX Processes.
Chapter 13 Processes.
Shell Script Assignment 1.
Basic UNIX OLC Training.
John Carelli, Instructor Kutztown University
CHAPTER 8 ( , ) John Carelli, Instructor Kutztown University
Introduction to Linux/UNIX
CHAPTER 13 Processes.
CSC 140: Introduction to IT
Linux Shell Script Programming
Chapter 3 The UNIX Shells
Presentation transcript:

CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang

Understanding the Process A process is defined as an instance of a running program. A process lives as long as the program is running. The kernel makes sure that processes get their due time slice and are swapped out to disk as and when needed. A process is identified by the process identifier (PID).

Understanding the Process A process has the following attributes: –The real user-id of the user who created the process. The user is said to be the owner of the process. –The real group-id of the owner process. Both user-id and group-id of the owner are stored in /etc/passwd. –The priority with which it runs. –The current directory from where the process was run. A process is said to be born when the program starts execution.

Understanding the Process After execution is complete, the process is said to die. Every process has a parent identified by the parent process identifier (PPID) except the ancestry of every process - the first process (PID 0) which is set up when the system is booted. A process can spawn (generate) multiple children.

How a Process Is Created Every process comprises code and data. The process image as viewed by the kernel runs in its own user address space. This address space has a number of segments: –Text Segment – This contains the executable code of a program. – Data Segment – All variables and arrays the program uses are held here. –User Segment – This contains all the process attributes.

How a Process Is Created There are three distinct phases in the creation of a process, using three important system calls – fork(), exec() and wait(): : –Fork – A process is created by the parent with the fork system call, which creates a copy of itself. –Exec – The parent then overwrites the copy with the exec system call to create the child. –Wait – The parent then executes the wait system call to keep waiting for the child process to complete.

How a Process Is Created When a process is forked, it inherits the environment of its parent but changes in the child are not made available in the parent. Built-in shell command like pwd and cd don’t fork a separate process. The shell also spawns a separate sub-shell to execute a shell script.

The Login Shell: The First User Process When you log on to a UNIX system, the shell process is immediately set up by the kernel. This program may be sh (Bourne shell), csh (C Shell), ksh (Korn shell), or bash (Bourne again shell). The shell maintains a set of variables that are available to the user. The PID of the login shell is stored in the variable $$. It is the parent of all commands and scripts run from the shell.

The init Process The parent of all login shells is the init process with PID 1. init forks and execs a getty process which prints the login prompt and goes to sleep. When a user tries to log in, getty wakes up and execs the login program to verify the login name and password. On most systems, login forks and execs a shell.

Internal and External Commands The shell recognizes three types of commands: –External commands – These are the most commonly used utilities and programs such as cat, ls, and so forth. –Shell scripts – The shell executes these scripts by spawning another shell, which then executes the commands listed in the script. –Internal commands – The shell has a number of built-in commands such as cd and echo which don’t generate a process.

ps: Process Status The ps command is used to list the attributes of processes. By default, ps displays the processes associated with a user at the terminal: ps is a highly variant command. Its actual output depends on the version of UNIX as well as the hardware used. BSD and System V are two main brands of the ps command.

ps: Process Status Linux uses the BSD version of the ps command. ps in Linux uses two types of options – the BSD options that don’t use a dash and the GNU-style options which use - -- (2 hyphens). The -e option shows all process including user and system process. The -f (full) option gets a detailed listing showing the the parent of a process.

ps: Process Status The -u (user) option displays processes of a user. ps -f -u root The -a (all) option displays all processes run by the user. Linux uses the ax option to display system processes. The ps u command approximates the ps -f.

Running Jobs in Background A multitasking system lets a user do more than one job at a time. A job can be run in the foreground and the background. A job can be run in the background by affixing an & at the end of the command line or the nohup command. nohup ensures that a background job remains alive even after the user has logged out.

Running Jobs in Background The & is the shell’s operator used to run a process in the background. sort -o list list &; ps -f C shell and bash shell allows you to log out without aborting the job. The nohup (no hangup) command prefixing a command permits execution of the process even after the user logged out. nohup sort list &