0% found this document useful (0 votes)
0 views18 pages

Process Management 1 (UNIX - LINUX History-Basic Shell Commands Ps-Process Definition)

Uploaded by

kumharvivek6791
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views18 pages

Process Management 1 (UNIX - LINUX History-Basic Shell Commands Ps-Process Definition)

Uploaded by

kumharvivek6791
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

CSC 501 Operating System

Dept. of Comp. Sc. & Engg., NIT Durgapur

Process Management in OS

Subrata Nandi, Dept. of CSE

[email protected]

Process is the “animated spirit” of a program – William Stallings


The study materials/presentations are solely meant for academic purposes and
they can be reused, reproduced, modified, and distributed by others for
academic purposes only with proper acknowledgements

Figures/Tables utilized from the standard books or other sources has been
acknowledged in the respective slides

Operating Systems (CSE 501) 2020, subrata.nandi@cs 2


e.nitdgp.ac.in
Process Management Topics in
• OS
Process Definition, Shell Command (ps)

• Different Process States & State Transition Diagram

• Context of a Process

• Process Data Structures

• Process control creation, termination, etc. (system calls : fork, exit, wait)

• Process (CPU) Scheduling, (related system calls)

• Signal Handling (system calls signal & kill)

• Threads and Multithreading (POSIX thread library)

• Deadlock Handling

• Data access synchronization primitives : Shared memory, Semaphores (POSIX semaphores), monitors

• Basic Inter-process communication mechanisms (system calls)


Today’s topics…..
• UNIX/LINUX history

• Basic Shell Command for monitoring process

• Process Definition
History of UNIX & LINUX
1969: UNIX V1 written in PDP 7 assembler language; memory swapping

1973: UNIX V3 written in C language by Ken Thompson

[1976: AT & T Bell Labs]

[1978: Licensed by [Berkley Software


[1978: Bell Labs] Distribution;
Microsoft from AT&T]
1976, UC Berkley]

[1982: Commercially • 1984: GNU project started by Richard Mathew Stallman;


marketed by Bell Labs]
American free software movement activist and programmer
[1982:
Santa Cruz • 1985: Free Software Foundation (FSF) was founded by
Operation
(SCO)] Stallman, initially to raise funds to help develop GNU

• 1990: major GNU tools developed; GNU Compiler


[1986: IBM]
collection, GNU debugger, GNU Emacs
[Sun MicroSys] [1985: CMU]

• 1991 Linus Torvalds developed LINUX using available


[1988: AT&T, SUN Microsys
Virtual memory]
[1991: Linus Torvalds GNU tools and copyleft (released under GNU Public
, Univ. of Helsinki]
License (GPL)); released in the Internet
Low level core of an Operating System is known as
• Supervisor – generic term
• Monitor - Batch OS
• Kernel - UNIX/LINUX OS
• Executive - Windows
The initial Processes….
• Every process is identified by an system-wide unique Id called pid. On 32-bit machines PID_MAX_LIMIT = 32768 (kernels
<=2.4), on 64-bit machines PID_MAX_LIMIT = 2^22 (approx. 4 million LINUX); value set in /proc/sys/kernel/pid_max file

• When a new process is started, the next unused number in sequence is chosen and the numbers restart at 2 so that pids
wrap around

• After booting the 1st kernel process pid (0) is created; it is known as the swapper process; which then creates several other
kernel processes and the 1st user level process init, pid (1)

• The init process is the grandparent of all other processes. All other processes are directly started by init or by other
processes created by init

• Each process (except init) is created by some other process called its parent process and the newly created process is called
its child process. A process hierarchy exist; if the parent terminates before child then init process becomes the parent of the
orphan child process

• The init process creates the terminal process (getty) after a user login

• The terminal process in turn executes the shell process


• Shell process (interactive command-line interpreter) acts as the interface between User and OS, enabling user to enter
commands for OS to execute and returns the output
• Ex: bash (GNU Bourne Again Shell) is default shell (/bin/sh) in most Linux distributions; sh (Bourne shell), ksh (korn
shell), csh (C shell)
Shell commands (pwd, ls, cat)
• $pwd - prints the current working directory the user is, at present; displays the complete path starting from root (/)

• $ls –l - utility for listing the contents files and subdirectories of a directory

• $cat - utility for displaying file contents


Shell commands (ps)
• $ps => (short for "process status") displays the currently-running processes
https://linuxgenie.net/ps-ef-command-in-linux explained/#:~:text=In%20Linux%2C%20ps%20%2Def%20is,processes%20in%20a%20full%20format.
Column Header Contents
How much of the CPU the
%CPU
process is using
How much memory the process
%MEM
is using
ADDR Memory address of the process
• $ps -ef => options used in UNIX system supporting POSIX standard C or CP
CPU usage and scheduling
information
"-e" selects every process and "-f" chooses the "full" output format
Name of the process, including
COMMAND* arguments, if any
NI nice value
F Flags
PID Process ID number
ID number of the process's
PPID
parent process
PRI Priority of the process
RSS Resident set size
S or STAT Process status code
START or STIME Time when the process started
VSZ Virtual memory usage
The amount of CPU time used by
TIME
the process
Terminal associated with the
TT or TTY
process
UID or USER Username of the process's owner
Memory address of the event
WCHAN
the process is waiting for
Shell commands (ps)
• $ps aux => options used in Unix systems derived from BSD
"a" lists all processes on a terminal, including those of other users,
"x" lists all processes without controlling terminal (daemon process) Column Header Contents
"u" adds a column for the controlling user for each process How much of the CPU the
%CPU
process is using
How much memory the process
%MEM
is using
ADDR Memory address of the process
CPU usage and scheduling
C or CP
information
Name of the process, including
COMMAND* arguments, if any
NI nice value
F Flags
PID Process ID number
ID number of the process's
PPID parent process
PRI Priority of the process
RSS Resident set size
S or STAT Process status code
START or STIME Time when the process started
VSZ Virtual memory usage
The amount of CPU time used by
TIME
the process
Terminal associated with the
TT or TTY process
UID or USER Username of the process's owner
Memory address of the event
WCHAN
the process is waiting for
Shell commands (ps)

Multiple shell processes created


Running User Application processes
Running User processes as
background/daemon (use &)
Terminating a background/daemon
process ($kill pid)
An User application process (infinite
heap allocation)
Keeps calling malloc infinite number of times
Process Definition(s)
Program – a set of routines/modules/library modules which constitute a code to be executed

Process Definition…..
• An instance of program in execution

• An entity to which processors are assigned

• It is a basic dispatchable unit that can be scheduled

• Is an abstract entity which helps to explain, understand, and control a program execution

• It is an entity that is manifested by the existence of Process Control Block (PCB) in OS; generally includes
the current activity (program counter), contents of the processor’s registers, process stack, data and the
code(the program), etc.

• An entity that reserves system resources for the execution of a program

• An animated spirit of a program

Term Process and Task are synonymous


Basic Concepts
• In very simple terms a process may be defined in terms of 5 tuples
• [process_id, process_code, data, register_contents, program_counter]
[P1,C1, D1, R1, Pc1]
[P2, C1, D2, R2, Pc1] two instance of the same code
[P3, C3, D3, R3, PC3]

• Concurrent Processes – simultaneous existence of multiple processes with full or partial overlap in time

• Interacting Processes – if concurrent processes interact (direct- sending signal or indirect - shared memory)

P1:
P2:

P3:
Blocked for I/O or
ready for running
Time
P1, P2, P3 are concurrent processes and P1 & P2 are concurrent as well as interacting processes

• Process interactions need to be synchronized - data access synchronization, control synchronization


Summary
• the init(1) process
• Parent-child process hierarchy in UNIX/LINUX;
• Basic shell command: ls, cat, ps –ef, ps aux, ./a.out &, kill
• How to run a process as background (&)
• How to monitor a process (ps)
• How processes can interact (kill)
• Process definition
• Concurrent and interacting process

You might also like