Final Exam - Practice Questions Flashcards
Prep for Final
How do you map a virtual address to a physical one?
- Use integer division to find the page.
Page = Virtual Address / Page Size
- Calculate the offset offset= virtual address % page size
- Find the frame by mapping the page to a frame via the page table
- physical address=frame∗(page size)+offset
How many table accesses are required to access the following virtual addresses in a 2 level table?
Virtual Address Page
50000 50
50001 50
55020 53
44000 40
If you don’t have the pages for each virtual addresses. Get the page that they are associated with.
Page = Virtual Address / Page Size
Address: 50000. Accessing the L1 page first (+1). Then go to the L2 Page and then go to the page that contains the physical address (+1). From here access the frame containing our physical address (+1). The page to frame is now stored in the TLB.
- (Running Total: 3)
Address: 50001. We already accessed this page before and it’s stored in the TLB. So access it (+1).
- Running Total: 4
Address 55020 isn’t stored in the TLB. So we go to L1 (+1). Then go to the L2 Page and then go to the page that contains the physical address (+1). From here access the frame containing our physical address (+1)
- Running Total: 7
Address 44000 isn’t stored in the TLB. So we go to L1 (+1). Then go to the L2 Page and then go to the page that contains the physical address (+1). From here access the frame containing our physical address (+1)
-Total : 10
How many immediate subdirectories does this directory have?
241772 drwx—— 5 uqjfenw1 uusers 56 Sep 16 12:14 ass3
241772 drwx—— 5 uqjfenw1 uusers 56 Sep 16 12:14 ass3
- The 3rd column minus 2. The parent directory and this directory itself.
What would happen if filea is changed to filec?
241772 drwx—— 5 uqjfenw1 uusers 56 Sep 16 12:14 ass3
202110918 -rw——- 1 uqjfenw1 uusers 26871 Sep 16 12:14 ass3_spec.tex
202110926 -rw——- 2 uqjfenw1 uusers 1621 Sep 17 10:38 filea
202110926 -rw——- 2 uqjfenw1 uusers 1621 Sep 17 10:38 fileb
202110913 -rwx—— 1 uqjfenw1 uusers 18042 Sep 16 11:57 grum.py 202110914 -rwx—— 1 uqjfenw1 uusers 117616 Sep 16 11:59 ls
202110950 ———- 1 uqjfenw1 uusers 801 Sep 16 12:25 smoketest
Nothing. Hard links point to the memory location, not the file. So changing the file name doesn’t change its contents.
The current directory contains a program called grum.py. What command should I use to ensure that I can run grum.py in any directory on the system just by typing grum.py?
Need to export it to the path.
Export PATH = $PATH:home/grum.py
Which command(s) would I need to run in order to allow all users to execute a binary file called smoketest?
chmod a+x smoketest
Which layer(s) of the network stack are affected by the following changes:
i) A copper network cable is replaced with fibre optic cable.
Physical
E) Which layer(s) of the network stack are affected by the following changes. (not including changes in the amount of network traffic).
ii) A new satelite is launched to directly connect London and Sydney.
ii) physical, link
E) Which layer(s) of the network stack are affected by the following changes. (not including changes in the amount of network traffic).
iii) A website changes from http to https.
application
Which layer(s) of the network stack are affected by the following changes. (not including changes in the amount of network traffic).
iv) A network connection is taken down for maintenance.
network
Which layer of the network stack does this belong to?
Port Number
Transport
Which layer of the network stack does this belong to?
Domain name
Application
Which layer(s) of the network stack are affected by the following changes. (not including changes in the amount of network traffic).
IP
Network
Which layer(s) of the network stack are affected by the following changes. (not including changes in the amount of network traffic).
SVN
Application
Which layer(s) of the network stack are affected by the following changes. (not including changes in the amount of network traffic).
TCP
Transport
Which layer(s) of the network stack are affected by the following changes. (not including changes in the amount of network traffic).
SSH
Application
Consider a “unix” filesystem where:
- All i-nodes are cached in RAM
- i-nodes have 10-direct pointers, 1 indirect pointer and 3 double indirect pointers.
- Blocks are 8KB
- Block pointers are 4Bytes
- blocks are numbered from 0.
What are the maximum possible file size for this file system?
Block size is 8KB.
8KB/4 = 8192/4 = 2048
8 KiB * (10 + 2048 + 3* 2048^2) = 100679760 KiB = ~96.016 GiB
Is this a process or a thread?

Both
Is this a process or a thread?

Threads
Is this a process or a thread?

Both.
Is this a thread or a process?

Both.
List two ways a process can find out that a child process has terminated.
- Wait/waitpid
- sigchild handler
If a call to wait(&status) succeeds, which macros should be used to determine the exit status of the process?
WIFEXIT & WEXITSTATUS
Which signal can not be blocked / caught by a process?
SIGKILL #9
Which C function is used to set up a signal handler?
sigaction
Show the last two lines of the file strax
Tail -2 strax
Show the 17th line of the file strax
head 17 strax | tail -1
Output all lines of the file file1 which contain the text: Clara > River
grep -n “Clara > River” file1
Delete all files in the current directory which start with ‘s’ and and end with ‘d’, except the file sd.
rm s*?d
Find all the lines in file file1 which contain the word “dinosaur” and store them in a file called london
grep dinosaur file1 >> london
What does mounting do and what afffect does it have on the file hierachy?
Mounting enables access to a filesystem that was previously inaccessible. This could be a separate drive partition (sidenote: but it doesn’t have to be - e.g. ramfs). It grafts a subtree on to a folder within the tree of the root filesystem.
How many immediate sub-directories does Library have?

- Number in the third column minus 2.
What are the three parts to a HTTP message?
Request/Response Line
Header
Body
What do each of the following HTTP request types do?
GET
HEAD
POST
PUT
DELETE
LINK/UNLINK
And why can we use them?
Get - retrieve entire document
Head - just give me the head
Post - make a new thing
Put - change an existing thing
Delete a thing
They are extra bits of information that your server might request
What do the following HTTP status codes refer to?
100s
200s
300s
400s
500s
100s - informational
200s - Client request successful
300s - Redirection/further action needed
400s - Client request incomplete
500s - Server Errors
What does DNS do?
DNS turns the IP address into a url that is human readable.
What’s a file system?
A data structure for handling the data on a system.
What is metadata?
The information about a file that’s not in the file.
Name, type, location, size, protection, owner and time/date info.
What’s an inode?
A block of data that is associated with the information of the file.
How is a file type stored?
Windows - as an extension (.exe)
Mac - inside the inode as metadata
Unix - file (guess based on the first 4 magic numbers in the file)
What does each inode have? Why is it important?
inodes have inode number. This helps the computer find it.
What are directory used for?
To map the names of files to numbers in the system.
What is at the top of file system?
Slash ( / ) is at the top.
Can you easily modify directories?
No, not without using specific sys calls.
Are inodes unique?
Yes
What’s a hard link?
Two different names but the same inode number.
When you make a hardlink you basically duplicate the reference to the inode data.
What happens when you modify a hard-linked file?
It changes no matter where you access from next.
What happens when you delete a hard linked file?
It decrements the reference count. If it now has a reference count of 0, then it it’s deleted off the system.
Can you make a hard-link to a directory?
No, if you can hard-link directories then you can make cycles. This is a waste of space and you don’t want this.
What’s a soft link?
In the lookup table, instead of linking to an inode (like a hard link), the lookup table contains the name of another linked file
What happens when you delete a soft-linked file?
Nothing. Deleting the things that links to another file doesn’t modify the original.
What happens if you have a soft-linked file and then you delete the original?
You have a dangling pointer.
What is file system mounting?
Linking from one file system to another so that you can have multiple file systems on a sysem.
What is an access list?
An access list is how we control who can access a file.
U, G, O
User, group and other.
Read, Write and Execute
What is a mimimum unit of transfer?
The amount of sectors per block you can send.
What is a sector?
The mimum amount you can read/write from a disk.
What is latency?
The pause between trying to access a disk vs the actual start.
What is bandwidth?
How long to read/write once you start going.
What is disk fragmentation?
Internal fragmentation is the wasted space that a file has been allocated but isn’t used.
What is external fragmentation?
Space is there but it’s all over the place.
What is RAID?
Multiple disks that have the same filesystem.