Operating System Practice : Meeting 5- process and manajemen proces-a-slide
1. https://github.com/syaifulahdan/ospractice|Operating System Practice |1 to 45
OPERATING SYSTEMS PRACTICE
Process and Management Process
Practice : 4A
Process on Linux Operating System
Process Management on Linux Operating Systems
https://github.com/syaifulahdan/ospractice|
2. https://github.com/syaifulahdan/ospractice|Operating System Practice |2 to 45
A. Objectives
1. Understand the process concepts in Linux operating system.
2. Shows some ways of showing parent and child process
relationships.
3. Displays the status of a process with several different formats.
4. Controlling the process on the shell.
5. Understanding priority scheduling.
4. https://github.com/syaifulahdan/ospractice|Operating System Practice |4 to 45
1. Concept Proces on linux OS
Process is the program being executed.
Whenever using the system utility or application
program from the shell, one or more "child" processes
will be created by the shell according to the given
command.
Each time the instruction is given in the Linux shell, the
kernel creates an id-process.
This process is also called the Unix terminology as a
Job.
The process Id (PID) starts from 0, the INIT process,
followed by the next process (listed in /etc
/inittab).
5. https://github.com/syaifulahdan/ospractice|Operating System Practice |5 to 45
Several types of processes:
Foreground
Processes created by the user directly at the terminal
(interactive, dialog)
Batch
Processes are collected and executed sequentially (one by
one). Batch Prose is not associated (interacting) with terminal.
Daemon
Processes that wait for requests from other processes and
perform tasks according to the request.
If there is no request, then this program will be in "idle" and do
not use CPU count time. Generally the name of the daemon
process in UNIX ends in d, for example inetd, named,
popd etc.
6. https://github.com/syaifulahdan/ospractice|Operating System Practice |6 to 45
2. Signal
The process can send and receive signals from and to
other processes. The process of sending a signal
through the instruction "kill" with the format.
kill [nomor sinyal] PID
Signal number: 1 to maximum signal number defined by
system The most important signal number standard is:
7. https://github.com/syaifulahdan/ospractice|Operating System Practice |7 to 45
No Signal Name Description
1 SIGHUP
Hangup, signals are sent when the process
is disconnected, for example through the
breaking of the modem connection
2 SIGINT Interrupt signal, through ^ C
3 SIGQUIT Quit signal, via ^
9 SIGKILL Signal Kill, stop the process
15 SIGTERM Software termination signals
8. https://github.com/syaifulahdan/ospractice|Operating System Practice |8 to 45
3. Sending Signal
Sending a signal is a communication tool between processes,
which tells the ongoing process that something must be
controlled. Based on the signal sent this process can react and
the administrator / programmer can determine the reaction.
Sending signals using instructions
kill [nomor sinyal] PID
Before sending the PID signal the process to be sent must be
known first.
9. https://github.com/syaifulahdan/ospractice|Operating System Practice |9 to 45
4. Control Process on Shell
Shell provides a job control facility that allows control of
multiple jobs or processes that are running at the same
time.
For example when doing text file editing and want to do
interrupt editing to do other things.
When done, can return (switch) to the editor and do the text
file editing again.
Job works on foreground or background.
In foreground only for one job at a time.
Job on the foreground will control the shell - receive input
from the keyboard and send output to the screen.
The job in the background does not accept input from the
terminal, usually running without requiring interaction.
10. https://github.com/syaifulahdan/ospractice|Operating System Practice |10 to 45
Job on the foreground may be suspended, with press [Ctrl-
Z].
A paused job can be re-run in the foreground or background
as needed by pressing "fg" or "bg".
For the record, stopping a temporary job is very different
from doing an interrupt job (usually using [Ctrl-C]), where
the interrupted job will be permanently disabled and can not
be executed again.
11. https://github.com/syaifulahdan/ospractice|Operating System Practice |11 to 45
5. Control Other Process
The ps command can be used to indicate all running
processes on the machine (not just processes in the current
shell) with the format :
ps –fae or
ps aux
Some versions of UNIX have a so-called top system utility
that provides an interactive way to monitor system activity.
Statistics in detail with running processes are displayed and
continually refreshed. The process is displayed in sequence
from the CPU utility. A useful key on the top is
12. https://github.com/syaifulahdan/ospractice|Operating System Practice |12 to 45
s – set update frequency
u – display proses dari satu user
k – kill proses (dengan PID)
q – quit
The utility for performing process controls can be found on
UNIX systems is the killall command. This command will
stop the process according to PID or job number process.
16. https://github.com/syaifulahdan/ospractice|Operating System Practice |16 to 45
$ ps
Experiment 1 : Process Status
1. Move to the command line terminal (tty2) by
pressing Ctrl + Alt + F2 and login to terminal as user.
2. The ps (process status) instruction is used to view
the process conditions. PID is the Process Identity
Number, TTY is the terminal name where the process
is active, STAT contains S (Sleeping) and R (Running),
COMMAND is the instruction used.
17. https://github.com/syaifulahdan/ospractice|Operating System Practice |17 to 45
$ ps -u
3. To see other factors / elements, use the -u (user)
option. %CPU is the CPU time presentation used by
the process, %MEM is the memory system
presentation used by the process, SIZE is the sum
memory used, RSS (Real System Storage) is the
amount of memory used, START is when the process is
enabled...
4. Looking for user-specific processes. The above
process is only limited to the user process, where the
user is logged in.
$ ps -u
$ ps –u <user>
19. https://github.com/syaifulahdan/ospractice|Operating System Practice |19 to 45
Experiment 2 : Displays the Parent
and Child Process Relationships
1. Move to command line terminal (tty2) by pressing
Ctrl + Alt + F2 and login to terminal as user.
2. Type ps -eH and press Enter. Option e selects all
processes and options H produce a hierarchical
process view. The child process appears below parent
rocess. The child process is marked by multiple spaces.
$ ps eH
20. https://github.com/syaifulahdan/ospractice|Operating System Practice |20 to 45
$ ps –e f
3. Type ps -e f and press Enter. The view is similar
to step 2. The -f option will display the status of the
process with graphic characters ( and _ )
4. Type pstree and press Enter. Will show all
processes on the system in the form of parent / child
hierarchy. Process the parent to the left of the child
process. For example the init process as a parent
(ancestor) of all processes on the system. Some child
from init has a child. Login process has bash process
as child. The bash process has a child startx process.
The startx process has child xinit and so on.
$ pstree
21. https://github.com/syaifulahdan/ospractice|Operating System Practice |21 to 45
$ pstree | grep mingetty
5. Type pstree | grep mingetty and press Enter. Will
show all the mingetty process that runs on the system
in the form of virtual console. In addition to displaying all
processes, the process is grouped in a row with a
number as the number of running processes.
6. To view all PIDs for the process use the p option.
$ pstree –p
7. To show the process and ancestor in bold use option
h.
$ pstree –h
22. https://github.com/syaifulahdan/ospractice|Operating System Practice |22 to 45
$ ps -e | more
Experiment 3 : Displays the Status of
Processes with Different Formats
1. Move to command line terminal (tty2) by pressing
Ctrl + Alt + F2 and login to terminal as user.
2. Type ps -e | more and press Enter. The -e option
displays all processes in the form of 4 columns: PID, TTY,
TIME and CMD.
If the full page shows a prompt --More-- at the bottom of the
screen, press q to return to the command prompt....
23. https://github.com/syaifulahdan/ospractice|Operating System Practice |23 to 45
3. Type ps ax | more and press Enter. Option a will
show all processes the resulting terminal (TTY).
The x option displays all processes the terminal does
not generate.
Logically this option is the same as the -e option.
There are 5 columns: PID, TTY, STAT, TIME and
COMMAND.
$ ps ax | more
If the full page shows a prompt --More-- at the
bottom of the screen, press q to return to the
command prompt....
24. https://github.com/syaifulahdan/ospractice|Operating System Practice |24 to 45
4. Type ps -e f | more and press Enter. The -e f
option will display all processes in full list format.
$ ps ef | more
If the full page shows a prompt --More-- at the
bottom of the screen, press q to return to the
command prompt....
5. Type ps -eo pid, cmd | more and press Enter.
The -eo option will display all processes in the format
according to the user definition that consists of PID
and CMD columns.
$ ps –eo pid,cmd | more
25. https://github.com/syaifulahdan/ospractice|Operating System Practice |25 to 45
If the full page shows a prompt --More-- at the
bottom of the screen, press q to return to the
command prompt....
6. Type ps -eo pid, ppid,% mem, cmd | more and
press Enter. Will display PID, PPID and% MEM columns.
PPID is the process ID of the parent process.
% MEM displays the percentage of memory system
used by the process. If the process uses only a small
amount of memory the system will get 0.
$ ps –eo pid,ppid,%mem,cmd | more
7. Logout and press Alt + F7 to return to graphics mode
26. https://github.com/syaifulahdan/ospractice|Operating System Practice |26 to 45
$ yes
Experiment 4 : Control the process
on the shell.
1. Move to command line terminal (tty2) by pressing
Ctrl + Alt + F2 and login to terminal as user
2. Use the yes command that sends output y that never
stops
To stop it use Ctrl-C.
27. https://github.com/syaifulahdan/ospractice|Operating System Practice |27 to 45
3. Turn standard output to /dev /null.
$ yes > /dev/null
If the full page shows a prompt --More-- at the
bottom of the screen, press q to return to the
command prompt....
To stop it use Ctrl-C.
4. One way to keep the yes command running but
the shell is still used for something else by putting
the process in the background by adding characters
& at the end of the command
$ yes > /dev/null &
The number in "[ ]" is a job number followed by PID.
28. https://github.com/syaifulahdan/ospractice|Operating System Practice |28 to 45
5. To view the status of the process use the jobs
command.
$ jobs
6. To stop a job, use the kill command followed by
the job number or PID process. To identify job
number, followed by prefix with character "%".
$ kill %<nomor job> contoh: kill %1
7. View job status after termination
$ jobs
31. https://github.com/syaifulahdan/ospractice|Operating System Practice |31 to 45
Practice Report : Practice 4A
1 Analyze your experimental results.
2 Analyze the exercises that have been done.
3 Give a conclusion from this lab.
Command Descripton
ps
ps u
ps u <user>
ps eH
pstree
jobs
kill %<jobs number>
32. https://github.com/syaifulahdan/ospractice|Operating System Practice |32 to 45
“Pleasure in a job makes perfection on the results
achieved”. Aristoteles
“Believe you can. You're halfway”. Theodore Roosevelt
“You might be able to delay, but time will not wait”.
Benjamin Franklin
“The effort will work if someone does not give up”.
Napoleon Hill
“Opportunity to find a better strength in us arises
when life seems to be very challenging”. Joseph
Campbell