Operating System Practice : Meeting 6- process and manajemen proces-b-slide
1. https://github.com/syaifulahdan/ospractice|Operating System Practice |1 to 45
OPERATING SYSTEMS PRACTICE
Process and Management Process
Practice : 4B
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
$ yes > /dev/null
Experiment 5 : Stop and resume jobs
1. Another way to put a job in the background is to
start the job normally (in the foreground), stop job
and start again in the background.
Pause the job (suspend), not stop it (terminate), but
pause the job until the restart. To pause the job use
Ctrl-Z.
2. To restart a job in foreground, use the fg command.
$ fg
17. https://github.com/syaifulahdan/ospractice|Operating System Practice |17 to 45
3. Shell will display the name of the command placed
in the foreground. Stop job again with Ctrl-Z. Then
use the bg command to put the job in the background.
Job can not be stopped with Ctrl-Z because job is in
background. To stop it, put the job on foreground
with fg and then pause with Ctrl-Z.
$ bg
$ fg
4. Job in the background can be used to display text
on the terminal, which can be ignored if trying to do
other jobs.
$ yes &
18. https://github.com/syaifulahdan/ospractice|Operating System Practice |18 to 45
To stop it can not use Ctrl-C. Job should be moved to
foreground, just stopped by pressing fg and press Enter, then
proceed with Ctrl-Z to pause.
5. If you want to run multiple jobs at one time, put a
job in the foreground or background by assigning a job
ID
$ fg %2 or $ %2
$ bg %2
6. press fg and press Enter, then proceed with Ctrl
-Z to pause.
20. https://github.com/syaifulahdan/ospractice|Operating System Practice |20 to 45
Experiment 6 : Experiment with
Priority Scheduling
1. Login as root.
2. Open 3 terminals, display on the same screen
3. On each terminal, type PS1="w:" followed by
Enter. w: displays the path in the home directory.
PS1=w:
4. Because login as root, it will be displayed ~: at
each terminal. For each terminal type pwd and press
Enter to see that you are in the /root directory.
21. https://github.com/syaifulahdan/ospractice|Operating System Practice |21 to 45
5. Open the terminal again (fourth), set the position so
that all four terminals are visible on the screen.
6. In the fourth terminal, type in top and press
Enter.Then the top program will appear. Type i. Top
will show the active process. Type lmt. Top no longer
displays information at the top of the screen. In this
experiment, the fourth terminal is the Top window.
7. In terminal 1, open the C ++ executable program
by typing the yes program and pressing Enter.
8. Repeat step 7 for terminal 2.
22. https://github.com/syaifulahdan/ospractice|Operating System Practice |22 to 45
9. The Top window will display two yes programs as
the running process.
The% CPU value is the same in both. This means both
processes consume the same processing time and run
just as fast.
The PID of the two processes will be different, for
example 3148 and 3149.
Then use terminal 3 (which does not run primes or
Top Window) and type renice 19 <PID terminal 1>
(example: renice 19 3148) and followed by Enter.
This means changing the priority scheduling of the
19th process.
23. https://github.com/syaifulahdan/ospractice|Operating System Practice |23 to 45
10. Wait a while until the top program changes and is
visible in the Top window. In the STAT column shows N
for process 3148. This means that the priority
scheduling for the 3148 process is greater (slower)
than 0. 3149 process runs faster.
11. The top program also has the same function as the
renice program. Select Top Window and press r.
Top program there is prompt PID to renice: press
3148 (remember that you must replace 3148 with your
own PID) and press Enter.
The top program gives prompt Renice PID 3148 to
value: press -19 and press Enter.
24. https://github.com/syaifulahdan/ospractice|Operating System Practice |24 to 45
12. Wait a while until top changes and see the% CPU
values in both processes.
Now process 3148 faster than process 3149. Column
status shows <on process 3148 which shows lower
priority scheduling (faster) than value 0.
13. Select terminal 3 (which is not running yes or top
program) and type nice -n -10 yes and press Enter.
Wait a few moments for the top program to change
and you will see a third prime process. For example its
PID 4107. Option -10 is in the NI column (priority
scheduling).
25. https://github.com/syaifulahdan/ospractice|Operating System Practice |25 to 45
14. Do not use the mouse and keyboard for 10
seconds. The top program displays an active process
in addition to the yes program.
Then it will look top listed process but% small CPU
(below 1.0) and consistent. Also visible process
related to graphical desktop like X, panel etc.
15. Move the mouse so that the cursor changes on the
screen and see what happens with the top view.
Additional processes will appear and the% CPU values
change as the graphics section works.
One reason is that the 4107 process is running on
high priority scheduling.
26. https://github.com/syaifulahdan/ospractice|Operating System Practice |26 to 45
Select the Top window, type r. PID to renice:
prompt appears. Type 4107 (change 4107 with your
PID) and press Enter. Renice PID 4107 to value:
prompt appears. Type 0 and press Enter. Now move
the mouse around the screen. View the changes.
Select the Top window, type r. PID to renice:
prompt appears. Type 4107 (change 4107 with your
PID) and press Enter. Renice PID 4107 to value:
prompt appears. Type 0 and press Enter. Now move
the mouse around the screen. View the changes.
16. Close all terminal windows.
17. Logout and log back in as user.
28. https://github.com/syaifulahdan/ospractice|Operating System Practice |28 to 45
Exercise : Practice 4B
1 Sign in to tty2 with Ctrl + Alt + F2. Type ps au and press Enter.
Then note the output as follows:
a. Mention names of processes that are not root.
b. Write PID and COMMAND from most CPU time process.
c. Mention the process and PID of the process.
d. Mention some daemon processes
e. At the login prompt do the following:
$ csh
$ who
$ bash
$ ls
$ sh
$ ps
f. Mention the largest PID and then order the sequence of
processes up to PPID = 1.
29. https://github.com/syaifulahdan/ospractice|Operating System Practice |29 to 45
2 Try the ps display format with the following options and note the results:
-f : full list
-j : job format
j : job control format
I : longitudinal list
s : signal format
v : virtual memory format
X : i386 register format
3 Do the following work sequences:
a. Use the find command to the entire directory on the system, turn
the output so that the directory list is redirected to the
directories.txt file and the list of error messages is redirected to
the errors.txt file
b. Use the command sleep 5. What happened to this command?
c. Run command in background using &
30. https://github.com/syaifulahdan/ospractice|Operating System Practice |30 to 45
d. Run sleep 15 on foreground,
- pause with Ctrl-Z and then put in background with bg.
- Type jobs.
- Type ps.
- Return the job to foreground with the fg command.
e. Run sleep 15 in background using & and then use kill command
to stop process followed by job number.
f. Run sleep 15 in the background using & and then use kill to
pause the process. Use bg to continue running the process
g. Run sleep 60 on the background 5 times and terminate it all on by
using the killall command.
h. Use the ps, w and top commands to show all the processes that are
being executed.
I. Use the ps aeH command to display the process hierarchy. Look for
init process. Can you identify an important daemon system? Can you
identify shell and subproses?
31. https://github.com/syaifulahdan/ospractice|Operating System Practice |31 to 45
j. Combine ps fae and grep, what do you see?
k. Run the sleep 300 process in the background. Log off the
computer and log back in. See a list of all running processes. What
happens to the sleep process?
33. https://github.com/syaifulahdan/ospractice|Operating System Practice |33 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