首页 » Python辅导 » python辅导 | COMPSCI 340 Operating Systems

python辅导 | COMPSCI 340 Operating Systems

本次任务是操作系统相关的python辅导

COMPSCI 340 2019
Operating Systems
Assignment 3 – Memory
Worth 10%
submission date 18th of October 9:30pm
Introduction
There are many tools to discover what is happening to memory as Linux processes run. A lot of the
information is supplied by the /proc file system. In this assignment you will use some of these tools to
answer some questions.
Login to Linux either in the lab or elsewhere and execute the following commands (this is just to make you
familiar with the commands):
gnome-system-monitor & (select the Resources tab). Currently doesn’t run in the lab but it should
shortly.
vmstat -a
cat /proc/meminfo
cat /proc/self/maps
ls -l /proc/self/map_files/
free
You will get substantially different output depending on where you do this assignment. For some of the
questions the markers will be looking for agreement between the data you present and the explanations you
give.
Read the man pages for the vmstat command and the /proc/meminfo , /proc/[pid]/map_files and
/proc/[pid]/maps sections of man proc.
Also see https://access.redhat.com/solutions/1160343 and https://linux-audit.com/understanding-memoryinformation-on-linux-systems/. You will not be able to use all tools in this last document without super user
privileges. Don’t worry about that.
The mem_filler.py program has sections commented out. You comment and uncomment sections in order
to get different information during execution.
In all answers if you looked something up on the web you must rephrase the explanations in your own words
otherwise TurnItIn will flag it as a copy. Do not include the questions in your answers. Any submissions with
a TurnItIn score above 30% may get zero.
Tasks & Questions
Question 1. (5 marks)
Run the original mem_filler.py program and observe what happens in the system monitor.
Play with the number of iterations (you can also change the LIST_INCREMENT value to be a larger size if
that helps) until you see the memory usage spike towards 100% and the swap percentage increase as well.
Then take the data from the program’s output and produce a table and a plot a graph showing the changing
values of “swpd”, “free”, “inact” and “active”.
Include the table and graph in your answer file and describe what you see in the graph. Explain what you
think causes that behaviour.
Describe the environment you used to collect the data (e.g. lab Linux image, amount of real memory).
Question 2. (3 marks)
What is inactive memory and why is it different from free memory? What are the consequences of using
inactive memory rather than free memory?
page 1
COMPSCI 340 Assignment 3
Question 3. (4 marks)
Edit the mem_filler program so that it instead shows the output from the /proc/pid/maps file.
Describe and explain the changes to the output as the program uses more and more memory.
Also describe what the [heap][stack][vvar][vdso] and [vsyscall] regions are.
Question 4. (2 marks)
Describe and explain the differences between the output from the /proc/pid/maps file and listing the
/proc/pid/map_files directory. In particular the regions that appear in one but not the other.
Question 5. (3 marks)
Here is some output from the command cat /proc/self/maps.
56023115d000-560231165000 r-xp 00000000 08:01 1703961 /bin/cat
560231364000-560231365000 r–p 00007000 08:01 1703961 /bin/cat
560231365000-560231366000 rw-p 00008000 08:01 1703961 /bin/cat
Explain the permissions on the regions and why the three regions have different permissions.
Question 6. (2 marks)
In /proc/meminfo what is the difference between free memory and available memory?
Question 7. (2 marks)
What is the OOM killer, when does it run and what does it do?
Question 8. (1 mark)
Looking again at the output from the vmstat command why is the number of context switches more than
the number of interrupts?
Question 9. (8 marks)
Here is a page reference string:
1,2,3,4,5,6,7,6,5,4,3,2,1,2,3,4,5,6,7,2
Given a machine with 5 frames show the contents of each frame using the following replacement algorithms
on that reference string. Also say how many page faults would occur for each algorithm. Pages are
brought in on demand and the initial load of a page counts as a page fault.
a) FIFO – First In First Out
b) LRU – Least Recently Used
c) LFU – Least Frequently Used (if there are multiple pages with the same lowest frequency choose in a
FIFO manner)
d) Optimal (if there are multiple pages which are not used again choose in a FIFO manner)
Lay out your answer for each algorithm like this. A zero means the frame is free, an “=” means the content of the frame is the same
as in the previous step.
page 2
1 2 3 4 5 6 7 6 5 4 3 2 1 2 3 4 5 6 7 2
0 1 = = = = = = = = = = = = = = = = = = =
0 = 2 = = = = = = = = = = = = = = = = = =
0 = = 3 = = = = = = = = = = = = = = = = =
0 = = = 4 = = = = = = = = = = = = = = = =
0 = = = = 5 = = = = = = = = = = = = = = =
COMPSCI 340 Assignment 3
Submitting the assignment
Make sure your name and upi is included in the file you submit.
Submit your answers to the questions as a single pdf or doc file, called a3Answers.pdf or
a3Answers.doc.
These files must be readable to TurnItIn to enable a check for uniqueness. Otherwise you will get zero for the
assignment. You may submit multiple times and your most recent submission will be marked.
Any work you submit must be your work and your work alone – see the Departmental and University
policies on academic integrity.
page 3


程序辅导定制C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持 Alipay WeChatPay PayPal等支付方式

E-mail: vipdue@outlook.com  微信号:vipnxx


如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。

blank

发表评论

您的电子邮箱地址不会被公开。