CSC 140: Introduction to IT

Slides:



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

UNIX Process Processes Commands that deal with processes
Operating Systems COMP 4850/CISG 5550 Processes Introduction to Threads Dr. James Money.
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.
Job Control Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
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.
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.
CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang
Linux+ Guide to Linux Certification, Second Edition
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.
CSSE Operating Systems
Processes & Daemons Chapter IV / Part III. Commands Internal commands: alias, cd, echo, pwd, time External commands, code is in a file: grep, ls, more.
Process Description and Control A process is sometimes called a task, it is a program in execution.
Phones OFF Please Processes Parminder Singh Kang Home:
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.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process System Process and init.
Chapter 4 UNIX Common Shells Commands By C. Shing ITEC Dept Radford University.
Linux+ Guide to Linux Certification, Third Edition
Process Control. Module 11 Process Control ♦ Introduction ► A process is a running occurrence of a program, including all variables and other conditions.
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.
Scis.regis.edu ● CS 468: Advanced UNIX Class 4 Dr. Jesús Borrego Regis University 1.
Welcome to CS323 Operating System lab 1 TA: Nouf Al-Harbi NoufNaief.net.
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,
1 Lecture 6 Introduction to Process Management COP 3353 Introduction to UNIX.
CIT 140: Introduction to ITSlide #1 CSC 140: Introduction to IT Processes.
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
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.
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 ( >, >>,
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.
Chapter 13 Processes.
...looking a bit closer under the hood
Process Management Process Concept Why only the global variables?
The UNIX Shell Learning Objectives:
Hands On UNIX AfNOG 2010 Kigali, Rwanda
CSC 382: Computer Security
Processes A process is a running program.
Review An OS in action Processes and Programs
Hands On UNIX AfNOG X Cairo, Egypt
Chapter 3: Processes.
Process Models, Creation and Termination
Operating Systems Lecture 6.
Operating Systems Lecture 5.
CHAPTER 8 ( , ) John Carelli, Instructor Kutztown University
Operating Systems Lecture 12.
Process & its States Lecture 5.
Chapter 3: Processes.
CHAPTER 13 Processes.
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Chapter 3: Processes.
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Processes – Part I.
CSE 451: Operating Systems Autumn 2004 Module 4 Processes
Lab 6: Process Management
Lecture 6 Introduction to Process Management
Presentation transcript:

CSC 140: Introduction to IT Processes CIT 140: Introduction to IT

CIT 140: Introduction to IT Topics What is a process? Process states and multitasking How does the shell execute processes? Foreground and background processes Job control Process tree Process commands CIT 140: Introduction to IT

CIT 140: Introduction to IT A process is a program in execution. A process is created every time you run an external command and is removed after the command finishes its execution. CIT 140: Introduction to IT

CIT 140: Introduction to IT Multitasking Only one process is using a CPU at a time. A process uses the CPU until: It makes an I/O request, or It reaches the end of its time slice, or It is terminated. The technique used to choose the process that gets to use the CPU next is called Process scheduling. CIT 140: Introduction to IT

CIT 140: Introduction to IT Process State As a process executes, it changes state new: The process is being created. running: Instructions are being executed. waiting: The process is waiting for some event to occur. ready: The process is waiting to be assigned to a CPU. terminated: The process has finished execution. zombie: Process has been terminated and is waiting for its resources to be recovered. CIT 140: Introduction to IT

CIT 140: Introduction to IT Process States A UNIX process can be in one of many states, typically ready, running, or waiting. CIT 140: Introduction to IT

CIT 140: Introduction to IT Process Scheduling First come, First serve(FCFS) Process that enters system first is assigned highest priority. Priority Scheduling Assign priorities based on accumulated CPU time. New and I/O bound processes have highest priorities. Round Robin (RR) A process gets to use the CPU for one time slice, then the CPU is given to another process, the next process in the queue of processes waiting to use the CPU. CIT 140: Introduction to IT

Execution of shell Commands A shell command can be external or internal. Internal (built-in) command: is part of the shell: ex: bg, cd, continue, echo, exec External command: separate program or script ex: grep, more, cat, mkdir, rmdir, ls CIT 140: Introduction to IT

Execution of shell Commands A UNIX process is created by the fork() system call, which creates an exact copy of the original process. The forking process is known as the parent process. The created (forked) process is called the child process. CIT 140: Introduction to IT

Execution of shell Commands To execute an external command, the exec() system call is used after fork. exec() replaces the current process in memory with the specified file and begins running it. CIT 140: Introduction to IT

Execution of shell Commands CIT 140: Introduction to IT

Execution of Shell Scripts Shell script: a series of shell commands in a file Execution different from binary programs. Current shell creates a child shell and lets the child shell execute commands in the shell script, one by one. Child shell creates a child process for every command it executes. While the child shell is executing commands in the script file, the parent shell waits for the child to terminate, after which it comes out of waiting state and resumes execution. Only purpose of child shell is to execute commands and eof means no more commands. CIT 140: Introduction to IT

Execution of shell Commands CIT 140: Introduction to IT

CIT 140: Introduction to IT Process Attributes Processes have a variety of attributes: User owner Group owner Process name Process ID (PID) Parent process ID (PPID) Process state Length of time running Amount of memory used CIT 140: Introduction to IT

CIT 140: Introduction to IT Process Status ps [options] (System V version) Purpose Report process status Output Attributes of process running on the system Commonly used options/features: -a Display Information about the processes executing on your terminal except the session header (your login shell) -e Display information about all the processes running on the system -f Display full list (8 columns) of status report. -l Display long list (14 columns) of status report. -u uidlist Display information about processes belonging to the users with UIDs in the ‘uidlist’ (UIDs separated by commas) CIT 140: Introduction to IT

CIT 140: Introduction to IT Examples of ps > ps PID TTY TIME CMD 24621 pts/13 0:00 bash 24740 pts/13 0:00 ps > ps -f UID PID PPID C STIME TTY TIME CMD waldenj 24621 24615 0 14:51:55 pts/13 0:00 -bash waldenj 24745 24621 0 14:55:06 pts/13 0:00 /usr/bin/ps -f > ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 8 S 1249 24621 24615 0 50 20 ? 331 ? pts/13 0:00 bash 8 O 1249 24746 24621 0 50 20 ? 123 pts/13 0:00 ps > ps -ef|head root 0 0 0 Jun 16 ? 0:01 sched root 1 0 0 Jun 16 ? 1:39 /etc/init - root 2 0 0 Jun 16 ? 0:01 pageout root 3 0 1 Jun 16 ? 970:56 fsflush root 332 1 0 Jun 16 ? 0:00 /usr/lib/saf/sac -t 300 root 312 1 0 Jun 16 ? 0:00 /usr/lib/snmp/snmpdx -y -c /etc/snmp/conf root 325 1 0 Jun 16 ? 0:05 /usr/sbin/vold root 50 1 0 Jun 16 ? 0:00 /usr/lib/sysevent/syseventd root 60 1 0 Jun 16 ? 0:01 /usr/lib/picl/picld CIT 140: Introduction to IT

Process and Job control Shell manages your processes for you: Process creation Process termination Suspending processes Running foreground processes. Running background processes. Switching processes to foreground/background. CIT 140: Introduction to IT

Example of Background Processes > find / -name foo 2>/dev/null & [1] 25299 > bzip2 bash.man & [2] 25304 > ps PID TTY TIME CMD 24621 pts/13 0:00 bash 25299 pts/13 0:03 find 25305 pts/13 0:00 ps > [2]+ Done bzip2 bash.man CIT 140: Introduction to IT

CIT 140: Introduction to IT Suspending a Process What if you forgot to background a process? Suspend the process with <Ctrl-z> Use fg or bg to unsuspend process. Use stop to suspend background processes. If you don’t have a stop command, use alias stop=“kill –STOP” Example CIT 140: Introduction to IT

Managing Background Processes: fg fg[%jobid] Purpose: Resume execution of the process with job number ‘jobid’ in the foreground or move background processes to the foreground. Commonly used values for ‘%jobid’ % or %+ Curent job %- Previous job %N Job Number N %Name Job beginning with ‘Name’ CIT 140: Introduction to IT

Managing Background Processes: bg bg[%jobid-list] Purpose: Resume execution of suspended processes/jobs with job numbers in ‘jobid-list’ in the background. Commonly used values for ‘%jobid’: % or %+ Curent job %- Previous job %N Job Number N %Name Job beginning with ‘Name’ %?Name Command containing ‘Name’ CIT 140: Introduction to IT

CIT 140: Introduction to IT UNIX Daemons A daemon is a system process running in the background. Most system services are daemons: E-mail Printing Ssh Web CIT 140: Introduction to IT

Sequential and Parallel Execution cmd1; cmd2; … ; cmdN Purpose: Execute the ‘cmd1’, ‘cmd2’, ‘cmd3’,…,’cmdN’ commands in sequence. cmd1 & cmd2 & … & cmdN & Purpose: Execute commands ‘cmd1’,cmd2’,…’cmdN’ in parallel as separate processes. CIT 140: Introduction to IT

CIT 140: Introduction to IT Terminating a Process Can terminate a foreground process by <Ctrl-C> Can terminate a background process: Find the PID with ps, then use kill PID. Bring process into foreground with fg, then use <Ctrl-C> CIT 140: Introduction to IT

CIT 140: Introduction to IT Terminating a Process > find / -name foo 2>/dev/null >foo.txt & [4] 28344 > sort bigFile | bzip2 -c >sortFile.bz2 & [5] 28350 > jobs [2]+ Stopped vim smallFile [3] Running sleep 10000 & [4] Running find / -name foo 2>/dev/null >foo.txt & [5]- Running sort bigFile | bzip2 -c >sortFile.bz2 & > kill %5 [5]- Terminated sort bigFile | bzip2 -c >sortFile.bz2 > ps PID TT S TIME COMMAND 28022 pts/4 S 0:00 -bash 28132 pts/4 T 0:00 vim smallFile 28137 pts/4 S 0:00 sleep 10000 28344 pts/4 R 0:05 find / -name foo > kill 28344 [4]- Terminated find / -name foo 2>/dev/null >foo.txt CIT 140: Introduction to IT

CIT 140: Introduction to IT Job Numbers vs PIDs PIDs Every process has a PID. PIDs are global (shared by every user.) Job Numbers Every job has a job number. Jobs may contain multiple processes. Job numbers are local (every user has own %1...) CIT 140: Introduction to IT

UNIX Process Hierarchy System starts init process on boot. Init is PID 1. Init starts system processes System daemons. Graphical login: xdm, kdm, gdm Text login: getty -> login Network login: sshd Login runs User shell CIT 140: Introduction to IT

Process Hierarchy in UNIX CIT 140: Introduction to IT