56
Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Embed Size (px)

Citation preview

Page 1: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Problems discussed in the review session for the final

COSC 4330/6310

Summer 2012

Page 2: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

True or false?

External fragmentation is often the result of using very large page sizes.

Page 3: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

External fragmentation is often the result of using very large page sizes.

– FalseLarger page sizes increase internal fragmentation but it rarely is an issue in virtual memory systems

Page 4: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

True or false?

Global page replacement policies cannot handle real-time processes.

Page 5: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

Global page replacement policies cannot handle real-time processes.

– TrueReal-time processes must keep all their pages in memory all the time, which can only be achieved by giving them a private partition containing all the pages they will ever need

Page 6: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

True or false?

UNIX uses file-specific passwords to control access to files.

Page 7: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

UNIX uses file-specific passwords to control access to files.

– FalseUNIX uses the file access control list to check which file access rights can be granted to a user process

Page 8: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

True or false?

UNIX stores the name of a file in its i-node.

Page 9: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

UNIX stores the name of a file in its i-node.

– FalseSee next answer

Page 10: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

True or false?

A UNIX file can have several names.

Page 11: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

A UNIX file can have several names.

– TrueIt can have as many names as there are directory entries pointing to it

Page 12: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

An example

Two directory entries pointing to same i-node

The file has two names

Bob

RobertFile i-node

Page 13: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

True or false?

UNIX special files are not files.

Page 14: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

UNIX special files are not files.

– True. They are physical devices—or POSIX named semaphores

Page 15: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

TLB misses

When comparing the hit ratios of two translation look-aside buffers, which question should we ask first?

Page 16: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

Are TLB misses handled by the firmware or by the OS?

– If TLB misses are handled by the firmware, the cost of a TLB miss is one extra memory reference

– If TLB misses are handled by the OS,the cost of a TLB miss is two context switches.

Page 17: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

The dirty bit

What is the purpose of the dirty bit?

Page 18: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

The dirty bit tells whether a page has been modified since the last time it was brought into main memory. It is used whenever a page must be expelled from main memory.

– If its dirty bit is ON, the page must be saved to disk before being expelled

– If its dirty bit is OFF, there already is an exact copy of the page on disk.

Page 19: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

The BSD page replacement policy

How does the BSD UNIX page replacement policy simulate a missing page-referenced bit?

What is the main drawback of the technique?

Page 20: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer (I)

How does the BSD UNIX page replacement policy simulate a missing page-referenced bit?

– Whenever the hand of the clock encounters a page that has been recently used, it marks it INVALID instead of clearing its page-referenced bit.

Page 21: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer (II)

What is the main drawback of the technique?

– The main drawback of this technique is that an interrupt will occur the next time that page will be accessed. The cost of handling this interrupt will be roughly equal to two context switches.

Page 22: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Page replacement policies

Among the following page replacement policies:

Local FIFO, Local LRU, Global FIFO, Global LRU, Original Clock,Berkeley Clock, and Windows

– Which ones are the poorest performers?

Page 23: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

Among the following page replacement policies:

Local FIFO, LOCAL LRU, Global FIFO, Global LRU, Original Clock,Berkeley Clock, and Windows

– Which ones are the poorest performers? Local FIFO and Global FIFO

Page 24: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Page replacement policies

Among the following page replacement policies:

Local FIFO, Local LRU, Global FIFO, Global LRU, Original Clock,Berkeley Clock, and Windows

– Which ones cannot be implemented at a reasonable cost?

Page 25: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

Among the following page replacement policies:

Local FIFO, Local LRU, Global FIFO, Global LRU, Original Clock,Berkeley Clock, and Windows

– Which ones cannot be implemented at a reasonable cost? Local LRU and Global LRU

Page 26: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Page replacement policies

Among the following page replacement policies:

Local FIFO, Local LRU, Global FIFO, Global LRU, Original Clock,Berkeley Clock, and Windows

– Which ones provide a decent performance and do not require any special hardware support?

Page 27: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

Among the following page replacement policies:

Local FIFO, Local LRU, Global FIFO, Global LRU, Original Clock,Berkeley Clock, and Windows

– Which ones provide a decent performance and do not require any special hardware support? Berkeley Clock and Windows

Page 28: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Page replacement policies

Among the following page replacement policies:

Local FIFO, LOCAL LRU, Global FIFO, Global LRU, Original Clock,Berkeley Clock, and Windows

– Which ones support real-time processes?

Page 29: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

Among the following page replacement policies:

Local FIFO, LOCAL LRU, Global FIFO, Global LRU, Original Clock,Berkeley Clock, and Windows

– Which ones support real-time processes? Windows

(older exams mention VMS)

Page 30: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Page table organization

A virtual memory system has a virtual address space of 4 GB and a page size of 4 Kilobytes. Each PTE occupies 4 bytes.

a) How many bits are used for the byte offset?

Page 31: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Page table organization

A virtual memory system has a virtual address space of 4 GB and a page size of 4 Kilobytes. Each PTE occupies 4 bytes.

a) How many bits are used for the byte offset? Since 4K =212, the byte offset will

use 12 bits.

Page 32: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Page table organization

A virtual memory system has a virtual address space of 4 GB and a page size of 4 Kilobytes. Each PTE occupies 4 bytes.

b) How many bits are used for the page number?

Page 33: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Page table organization

A virtual memory system has a virtual address space of 4 GBs and a page size of 4 Kilobytes. Each PTE occupies 4 bytes.

b) How many bits are used for the page number? Since 4G = 232,

We have 32-bit virtual addressesOf these 32 bits the page number occupies 32 - 12 = 20 bits

Page 34: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Page table organization

A virtual memory system has a virtual address space of 4 Gigabytes and a page size of 4 Kilobytes. Each PTE occupies 4 bytes.

c) What is the maximum number of page table entries in a page table?

Page 35: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Page table organization

A virtual memory system has a virtual address space of 4 Gigabytes and a page size of 4 Kilobytes. Each PTE occupies 4 bytes.

c) What is the maximum number of page table entries in a page table? Address space/ Page size =

232 / 212 = 220 PTE’s.

Page 36: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Page table organization

A virtual memory system has a virtual address space of 4 GB and a page size of 4 Kilobytes. Each PTE occupies 4 bytes.

d) What is the maximum size of a page table?

Page 37: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Page table organization

A virtual memory system has a virtual address space of 4 GB and a page size of 4 Kilobytes. Each PTE occupies 4 bytes.

d) What is the maximum size of a page table? Since each PTE occupies 4 bytes,

4 x 220= 222 bytes = 4 MB.

Page 38: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

UNIX file organization (I)

A 32-bit UNIX file system has 16 kilobyte pages and i-nodes with 15 block addresses. How many file bytes can be accessed

a) Directly from the i-node?

Page 39: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

A 32-bit UNIX file system has 16 kilobyte pages and i-nodes with 15 block addresses. How many file bytes can be accessed

a) Directly from the i-node? The 12 first blocks that is

12 x 16 KB =192 KB.

Page 40: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

UNIX file organization (II)

A 32-bit UNIX file system has 16 kilobyte pages and i-nodes with 15 block addresses. How many file bytes can be accessed

b) With one level of indirection?

Page 41: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

A 32-bit UNIX file system has 16 kilobyte pages and i-nodes with 15 block addresses. How many file bytes can be accessed

b) With one level of indirection? An indirect block can store

16KB/4B = 4K block addresses. Hence we can access the next

4K x 16K = 64MB of the file

Page 42: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

UNIX file organization (III)

A 32-bit UNIX file system has 16 kilobyte pages and i-nodes with 15 block addresses. How many file bytes can be accessed

c) With two levels of indirections?

Page 43: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

A 32-bit UNIX file system has 16 kilobyte pages and i-nodes with 15 block addresses. How many file bytes can be accessed

c) With two levels of indirections? We should be able to access

4K4K = 224 blocks of 16 KB = 256 GB Since the maximum file size is 4 GB

we will be able to access4 GB – 64 MB – 192 KB

Page 44: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

UNIX file organization (IV)

A 32-bit UNIX file system has 16 kilobyte pages and i-nodes with 15 block addresses. How many file bytes can be accessed

d) With three levels of indirections?

Page 45: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

A 32-bit UNIX file system has 16 kilobyte pages and i-nodes with 15 block addresses. How many file bytes can be accessed

d) With three levels of indirections? None

Page 46: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Internal fragmentation

Internal fragmentation is not a big problem in virtual memory systems. Is it always so in file systems?

Give a hypothetical example to support your argument.

Page 47: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

Internal fragmentation can be a big problem whenever the disk partition contains many files than are much smaller than the block size.

Consider for instance a partition where many files are smaller than 1 KB and the block size is 4KB. More than 75 percent of the space used by these files will be wasted.

Page 48: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Controlling access to files

Alice, Bob and Carol want to share a few files on a UNIX system while preventing other users to access these files. What should they do?

Page 49: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

Alice, Bob and Carol want to share a few files on a UNIX system while preventing other users to access these files. What should they do?

– They should ask their system administrator to create a group “abc” for the three of them.

Page 50: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Access control lists and tickets

Give examples of tickets and access controls lists in the UNIX file system.

Page 51: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

Give examples of tickets and access controls lists in the UNIX file system.– The file descriptor of an opened file

acts as a ticket. – The protection bits of a file constitute

its access control list.

Page 52: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Metadata updates

Give examples of what could happen if metadata updates are written to disk in the wrong order.

How does the “Fast” File System avoid that?

What is the main drawback of this approach?

Page 53: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer (I)

Whenever we create a new file, the block containing the new i-node must be written to disk before the block containing the directory entry pointing to that i-node. Otherwise, a crash happening after the directory block has been written to disk but before the block containing the new i-node has been written to disk would leave the file system in unsafe state

Page 54: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer (II)

The “Fast” File System avoids that by requiring all I/O operations involving metadata updates to be blocking.

This solution dramatically decreases the throughput of the file system.

Page 55: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Question

What are the respective advantages of journaling file systems using(a) synchronous log updates and(b) asynchronous log updates?

Page 56: Problems discussed in the review session for the final COSC 4330/6310 Summer 2012

Answer

Journaling file systems using synchronous log updates guarantee that no metadata data update will be lost when the system crashes.

Journaling file systems using asynchronous log updates are much faster (because they do much less physical I/Os).