0% found this document useful (0 votes)
67 views

UNIX Chapter 2 Process

A process is a running program with a unique process ID (PID). It can be a foreground process that receives keyboard input or a background process. All processes are created through the fork() system call except the initial startup process. The parent process's PID is returned to the child process on a successful fork. Orphan and zombie processes occur when a parent process dies before its child. Daemon processes run in the background at system startup to provide services. The ps command displays information about running processes like their PID, PPID, CPU usage, and command. Top monitors processes in real-time and allows sorting and filtering.

Uploaded by

Munir Ali
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

UNIX Chapter 2 Process

A process is a running program with a unique process ID (PID). It can be a foreground process that receives keyboard input or a background process. All processes are created through the fork() system call except the initial startup process. The parent process's PID is returned to the child process on a successful fork. Orphan and zombie processes occur when a parent process dies before its child. Daemon processes run in the background at system startup to provide services. The ps command displays information about running processes like their PID, PPID, CPU usage, and command. Top monitors processes in real-time and allows sorting and filtering.

Uploaded by

Munir Ali
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

INTRODUCTION TO UNIX

Chapter 2

Process

- A process is compiled source code that is currently running on the system


- Whenever a command is issued it creates/starts a new process
- With a 5-digit id number Unix/Linux keeps an account of the processes this number
is called ID or PID
- All processes have a unique process id or PID
- Used up pid’s can be used again for a newer process since all the possible
combinations are used.
- At any point of time no two processes with the same pid exist in the system
- Every process has a parent process (With a PPID).
- The child process is often started by the parent process
- PID is unique for every process

Initializing a process

A process can be run in two ways:


- Foreground process: every process when started runs in foreground by default,
receives input from the keyboard, and sends output to the screen.
- Background process: it runs in the background without keyboard input and waits
till keyboard input is required
 Other processes can be done in parallel with the process
 Because since they do not have to wait previous process to be completed

Types of Processes

1) Parent and child process


- All processes in operating system are created when a process executes the fork ()
system call, except the startup process
- The process that used fork () system call is the parent process
- A parent process may have multiple child processes but a child process only has one
parent process
- On the success of a fork () system call
 The PID of the child process is returned to the parent process and 0 is
returned
- On the failure of a fork () system call
 -1 is returned to the parent process and a child process is not created
- A childe process inherits most of the parent attributes
- If a child process exits or is interrupted then a SIGCHLD signal is send to the parent
process

2) Zombie and orphan process

- When the parent process is killed before the termination of the child process,
the child processes become orphan processes.
- When a process is killed but still shows its entry in the process status or the
process table is called a zombie process
- They are dead and are not used

3) Daemon process

- Processes that start at system startup and keep running are called daemon
processes or daemons.
- System related background processes that often run with the permissions of
root and services requests from other processes
- Run in the background
- When ps -ef is executed the process with? in the tty field are daemon
processes.

Process Status(ps)
- Fields described by ps are described as:
 uid: user id that this process belongs to (the person running it)
 pid: Process ID
 ppid: Parent process ID (the ID of the process that started it)
 c: CPU utilization of process
 stime: Process start time
 tty: Terminal type associated with the process
 time: CPU time is taken by the process
 cmd: command that started the process
 -a: Shows information about all users
 -x: Shows information about processes without terminals
 -u: Shows additional information like -f option
 -e: Displays extended information
Process Commands
- Kill to terminate a process (Program)
- ?? $$ variable will hold your current process id
- ?? $PPID contains the parent PID
- Monitoring Process
 ps: display process running in the current shell
 ps -e: display running daemons
 ps -f: display processes with full option (Extra information about a process
PID)
 ps -l: list more information on process
 ps -lp <PID>: specific information for process id
 ps -ef: display all processes and daemon on ttys
 Ps -elf: to show threads alongside process
 Ps -eH = indentation
 ps -e --format pid,user,args,c
 ps -e --format pid,user,args,c --sort c
 ps -e --format pid,user,args,c --sort -c
 Ps -U root
 ps -e --format user,pid,c,tty,cmd --sort c
- Monitoring Process in real time
 Top
 In top
❖ 1: number of cpus and usage
❖ 1 & t: solid bar view
❖ m: memory statistics
❖ R: to change the nice value of process
❖ F: filed management
❖ S: to change sort field
❖ Shift + U

You might also like