Linux with Operating System Concepts



Download 5,65 Mb.
Pdf ko'rish
bet221/254
Sana22.07.2022
Hajmi5,65 Mb.
#840170
1   ...   217   218   219   220   221   222   223   224   ...   254
Bog'liq
Linux-with-Operating-System-Concepts-Fox-Richard-CRC-Press-2014

fairness
. All processes need 
to be treated fairly so that no process is allowed to monopolize a resource. Without fair-
ness, a process could potentially starve because the needed resources are always being 
granted to other processes.
While the operating system is set up to ensure these criteria (fairness, availability of 
resources), it is up to the system administrator to monitor the processes and resources 
to make sure that the operating system is doing what we expect. Toward that end, Linux 
provides us with a number of programs to monitor the processes and system resources. 
Although we have examined several such tools to this point of the chapter, we will reexam-
ine them and look at several other programs.
Let us consider an example of a poorly performing system. When an operating system 
is spending much of its time performing page swapping, this is known as 
thrashing
. Recall 
that paging accesses the hard disk that incurs a large penalty in processor performance 
because the hard disk is so much slower than the processor. Figure 14.2 illustrates a simple 
although unrealistic example of thrashing. In this case, there are so many processes run-
ning that this particular process is given only two frames of memory, 315 and 612.
The process contains a for loop that consists of two sets of code: the loop mechanism (ini-
tializing i to 0, comparing i to n, and incrementing i at the end of the loop) and the assign-
ment statement to modify array element a[i]. In assembly code, the assignment statement 
would also require computing the memory location of a[i]. Coincidentally, both sets of the for 
loop code are stored on two different but consecutive pages and thus when moving from one 
page to the next, if a frame is not available in memory, the current page must be discarded in 
favor of the new page (because the process has been given only two frames in memory). The 
data used by this code are stored in two separate but consecutive pages as well.
Every iteration through the loop causes four page faults. First, the for loop mechanism 
is needed to initialize i and compare it to n requiring the page with the for loop. To execute 
this instruction also requires that the first page of data (with i and n) must be loaded into 
memory. If i is less than n, then the assignment statement is executed. Thus, the page with 
this statement, which is not currently in memory, is required. This causes a page fault.
Now, to compute a[i] 
=
a[i] 
+
b, we need to access array a. This causes another page fault. 
After completing a[i] 
=
a[i] 
+
b, we resume with the loop increment and loop comparison, 
again, not in memory because it was discarded. This requires access to both i and n, also 
for(i=0;Memory frame
612
612
315
315
a[i]=a[i] +b; }
data: i, n, b
data: array a
FIGURE 14.2 
Thrashing example.


588

Linux with Operating System Concepts
not currently in memory. Two more page faults occur within a single iteration of the loop. 
If there are four page faults per iteration, then this set of code could result in a total of 4*n 
total page faults!
It should be obvious that this example is artificial and should never arise. For one rea-
son, a process will be given far more than two frames. Another is that it is unlikely that 
the division within a program would fall exactly as shown in this example (although 
this is possible). However, as unlikely as the example is, it illustrates the potential prob-
lem of thrashing.
14.4.3 Process System-Monitoring Tools
The system monitor program provides us with both an overview and detail of what is 
going on with many system resources. Specifically, we can see the amount of CPU usage, 
memory usage, network usage, virtual memory usage, and file system usage. For CPU, 
memory, swap space, and network utilization, the tool shows us the changes taking place 
over the past minute.
As a system administrator, a quick look at this tool can indicate that your system is 
running smoothly. You would hope to see CPU load is not approaching or at 100% for any 
length of time and that swap space is not approaching 100% utilization. Further, if memory 
use has not come close to 100%, you should expect swap space usage to remain low. If you 
find swap space usage to be high and remain high, it means that your system is doing a lot 
of very inefficient paging.
Through the system monitor, you can inspect the running processes (the Processes tab) 
and see the status, CPU, and memory usage of the processes. If you see many processes 
with high CPU utilization, you might inspect these processes. Which processes are owned 
by root that can be postponed? Which processes are owned by users that you might deem 
of low priority that could be moved either to the background or have their priority low-
ered? You could even select some user process(es) to run later via scheduling.
If memory utilization is approaching capacity causing a lot of virtual memory usage, 
you might again select some of the processes to move into the background or schedule 
them later. Moving processes to the background permits the operating system to tem-
porarily swap their content out of memory and thus free up space for other processes. 
Lowering the priority of running processes will not impact their memory usage as they 
would remain in memory. If you find that memory usage remains very high, it might 
indicate that either you have too many users for your Linux system or that you need more 
memory in your computer.
Top also provides information about processes and system resource usage. While top 
and the system monitor will tell you much of the same information, top displays pro-
cess and resource utilization on one screen, rather than having to switch between tabs. 
Additionally, top can be tailored to display different types of information. See Chapter 4 
for more details on top.
Other tools for querying the system are command line programs. These include ps (see 
Chapter 4) as well as 
mpstat

sar

pidstat

uptime

vmstat

free

stat

df

du

netstat

nmap

ip

ss

lnstat

iostat
, and 
lpstat
.


Maintaining and Troubleshooting Linux

589
Another command that might provide useful information is called 
strace
, which 
traces the system calls made by a particular Linux command. We have already looked at 
some of these programs earlier in the chapter (stat, df, du, ip, and ss). We will examine the 
remainder here.
The first set of commands explores the processor’s performance and the active pro-
cesses. The mpstat command reports processor-related statistics for each of the system’s 
processors. It is implied that mpstat is used on a multiprocessor system, but it can also be 
used for a single-processor computer.
The mpstat command provides for each CPU the percentage of time it spends on user 
activities, system activities, hardware interrupts, software interrupts, guest activities, 
ideal time, cycle stealing, and periods of input or output when it is forced to wait. The 
user activity is broken into two different values: ordinary user activity and user activity 
with niced processes (those given lower priority). Guest activities are actions that the 
CPU takes to run a virtual processor. Cycle stealing occurs when the CPU is given a 
lower priority to accessing resources than the disk drive (this is described in more detail 
later).
Similar to mpstat, sar reports on CPU utilization. The primary difference is that mpstat 
reports an average over some duration of time. Sar on the other hand, outputs a series of 
snapshots of processor utilization over a period of time. The output shows, row by row, the 
processor’s utilization at each timed interval.
By default, the interval is every 10 minutes. This information is stored in log files under 
the directory /
var/log/sa
. You might find numerous entries in this directory with 
names such as 
sa

Download 5,65 Mb.

Do'stlaringiz bilan baham:
1   ...   217   218   219   220   221   222   223   224   ...   254




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish