$24
Problem 1
(10 points) Consider the memory management methods of contiguous allocation, paging, and segmentation. Compare these methods with respect to the following: external fragmentation and code sharing among processes.
Problem 2
(10 points) A system with 40-bit logical (virtual) address uses a two-level page table. Logical addresses are split into an 12-bit top-level page table eld, a 16-bit second-level page table eld, and an o set.
What is the size of a page in this system (assume that the size of a memory location is 1 Byte)? How many pages are there in the address space? Explain the reason.
Problem 3
(10 points) Consider the following page reference string:
1,2,3,4,2,1,5,6,2,1,2,3,7,6,3,2,1,2,3,6
How many page faults would occur for the page replacement algorithms: LRU, FIFO, Opti-mal when 6 frames are allocated for a process? Remember all frames are initially empty, so your rst unique pages will all cost one fault each.
Problem 4
(20 points) Create two simple les le1.txt and le3.txt. Add some content to both and answer the following questions. Next, obtain the inode number of this le with the command
ls -li le1.txt
This will produce output similar to the following:
16980 -rw-r{r{ 2 os os 22 May 2018 16:13 le1.txt
where the inode number is boldfaced. (The inode number of le1.txt is likely to be di erent on your system.)
1
COMP 304- Operating Systems ( Spring 2017): Assignment 3 PROBLEM 4
The UNIX ln command creates a link between a source and target le. This command works as follows:
ln [-s] <source le<target le
UNIX provides two types of links: (1) hard links and (2) soft links. Enter the following command to create a hard link between le1.txt and le2.txt:
ln le1.txt le2.txt
What are the inode values of le1.txt and le2.txt? Are they the same or di erent? Do the two les have the same or di erent contents?
Next, edit le2.txt and change its contents. After you have done so, examine the contents of le1.txt. Are the contents of le1.txt and le2.txt the same or di erent? Check their inode numbers again. Are they the same?
Next, enter the following command which removes le1.txt:
rm le1.txt
c) Does le2.txt still exist as well?
Now examine the man pages for both the rm and unlink commands. Afterwards, remove le2.txt by entering the command
strace rm le2.txt
The strace command traces the execution of system calls as the command rm le2.txt is run. What system call is used for removing le2.txt?
Now create a soft link to le3.txt by entering the following command:
ln -s le3.txt le4.txt
After you have done so, obtain the inode numbers of le3.txt and le4.txt using the command ls -li le*.txt
Are the inodes the same, or is each unique?
Next, edit the contents of le4.txt. Have the contents of le3.txt been altered as well?
Last, delete le3.txt. After you have done so, explain what happens when you attempt to edit le4.txt.
Explain how hard link and soft link work based on these experiments. Where each can be used?
Student Name: Page 2 of 2