Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Final Examination: This Is A Closed Book, Closed Notes, No Calculator Exam

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 10

CS 423 Final Exam– Spring 2007 Name:_______________________

University of Illinois at Urbana-Champaign


Department of Computer Science

Final Examination
CS 423 Operating System Design
Spring, 2007

8:00-11:00am Tuesday, May 8th

Print your name and ID number neatly in the space provided below; print your name at the upper
right corner of every page.

Name:

Net ID:

This is a closed book, closed notes, no calculator exam.


Write your answers CLEARLY. The answer will be assumed wrong if the instructors and the TA
cannot read it.

Do all parts of all five problems in this booklet. This booklet should include this title page, and 10
question pages. Do your work inside this booklet, using the empty pages and backs of the pages if
needed. Problems are of various difficulty, hence if you do not know the answer immediately,
progress to the next problem and come back to the unsolved problem later.

Problem Score Grader


1 /15
2 /20
3 /15
4 /10
5 /20
6 /20
Total

Department of Computer Science, University of Illinois at Urbana-Champaign 1


CS 423 Final Exam– Spring 2007 Name:_______________________

1. Problem Overall and MP Related (15 Points)

1. (10 Points) Suppose a user “xyz” has logged into a Linux system and the current directory is
“/home/xyz”. The user types “ls” on the keyboard and then presses enter. Briefly list what happens
inside of the computer system after the “enter” key is pressed. (hint: it will involve almost every major
component of an operating system).
Answer:
1. hardware keyboard interrupt is raised (HW Layer )
2. interrupt handler wakes up keyboard device driver to read the data from the keyboard
(interrupt handler Layer)
3. keyboard device driver returns data to shell program in user mode (device driver Layer)
4. shell program searches $PATH for executable
5. shell creates (forks) a process and executes /bin/ls (process management Layer)
6. the ls process reads current directory (“opendir”, “readdir”) – finds inodes for /home and
for /home/xyz (disk/FS Layer)
a. first do opendir which triggers finding the inodes and caching them in the memory
b. second do readdir – read all files in the directory
7. print out the file entries (FS Layer)

2. (5 Points, 1 each) MP related questions

a) What does the goodness() function in the scheduler do?


Answer: Calculates the appropriate weight for a given process.

b) How do you make the systems call visible to the user space while implementing a system call?
Answer: Writing the header file for it. For example sched_rate.h from the second MP.

c) What does refill_inactive() do?


Answer: Moves nr_pages number of pages from active_list to inactive_list at each invocation.

d) How do you install and remove a simple module?


Answer: insmod, rmmod

e) Which function is called when the file system is first mounted?


Answer: myfs_read_super

Department of Computer Science, University of Illinois at Urbana-Champaign 2


CS 423 Final Exam– Spring 2007 Name:_______________________

2. Problem – Process, Sync, Memory and I/O (20 Points)

1. (4 Points) Two unrelated processes are running on a normal Linux 2.4.18 box. Each happens to
have an instruction MOV AX, MEM[1000], which stores the content of the AX register into a memory
location with the given address. Suppose the two processes execute the instruction at about the same
time, and they do not have any synchronization mechanism to protect this instruction, what will
happen and why?

Answer: nothing special will happen since the “memory location 1000” is different for different
processes (each process has its own address space).

2. (4 Points) Consider a variable partition memory management system with the following hole sizes
in memory order: 10 KB, 4 KB, 20 KB, 18 KB, 7 KB, 9 KB, 12 KB and 15 KB. Now suppose three
memory allocation requests come that ask for 12 KB, 10 KB and 9 KB, respectively. For the following
two allocation strategies, determine which memory block will be allocated.
(1) Best fit:

(2) Worst fit:


Answer: Best fit takes 12 KB, 10 KB, and 9 KB.
Worst fit takes 20 KB, 18 KB, and 15 KB.

3. (5 Points) Suppose that a computer can read or write a memory word in 10 ns. Also suppose that
when an interrupt occurs, all 32 CPU registers, plus the program counter and PSW are pushed onto the
stack. What is the maximum number of interrupts per second this machine can process?

Answer: An interrupt requires pushing 34 words onto the stack. Returning from the interrupt
requires fetching 34 words from the stack. This overhead alone is 680 ns. Thus the maximum
number of interrupts per second is no more than about 1.47 million, assuming no work for each
interrupt.

Department of Computer Science, University of Illinois at Urbana-Champaign 3


CS 423 Final Exam– Spring 2007 Name:_______________________

4. (7 Points) The LRU algorithm can be used in many components of the Operating System (e.g.,
buffer cache in I/O system or page replacement algorithm).
(1) Describe how one may implement LRU for page replacement.

Answer: keep a linked list of all pages in the order of access. Whenever a page is accessed, it is
removed from the list and then inserted at the head of the list.

(2) Implementation of true LRU is rarely used for page replacement. Why is this the case?
Describe two algorithms that can be used to implement approximations of LRU.

Answer: use a counter (shift to right) or use counter to sum up accesses.

Department of Computer Science, University of Illinois at Urbana-Champaign 4


CS 423 Final Exam– Spring 2007 Name:_______________________

3. Problem – Multimedia Systems (15 Points)


1. (4 points) What is I-frame, P-frame and B-frame in MPEG video encoding and what is the
relationship between these frames.

2. (4 Points) Two real-time processes are running on a computer. The first one needs to run for 10 ms
every 25 ms; the second one needs to run for 15 ms every 40 ms. Will RMS always work for them?

Answer: The first process uses 0.400 of the CPU. The second one uses 0.375 of the CPU.
Together they use 0.775. The RMS limit for two processes is 2 (20.5 1), which is 0.828, so RMS
is guaranteed to work.

3. (7 Points) Consider a video on demand (VOD) server that has 1000 movies and 3 disks. Some
movies are more popular than others. Currently each movie is stored on a random location on a
random disk. At any given time, a set of clients may be watching the movie (may or may not be
the same movie, and in case two clients are watching the same movie, they may start the movie at
different times). To serve the VOD clients, currently the server periodically reads some video
data for each client, sends the data to the client, and then discards the memory buffer.

Describe several techniques that can be used to improve the performance of this VOD system.

Answer: (1) stripe movie across different disks. (2) on each disk, popular files are placed at
center; (3) keep memory buffers

Department of Computer Science, University of Illinois at Urbana-Champaign 5


CS 423 Final Exam– Spring 2007 Name:_______________________

4. Problem – Distributed Systems (10 Points)

1. (4 points) In a symmetric multi-processor (SMP) machine, each node has a private hardware cache.
Describe two different ways to achieve cache consistency when one processor writes to data item that
is already cached by some other processor?

Answer: write update or invalidate

2. (6 points) Suppose N threads, each running on one processor, need to access some shared data. If
TSL (Test-and-Set on a shared lock variable) is used to implement synchronization, what kind of
performance problem may occur, (suppose each processor spends relatively long time in the critical
section.) and how can this problem be avoided?

Answer: [see text book, multi-processor, synchronization] basically, each thread should have its own
private lock, TSL on this lock, prevent cache thrashing], a shared token-lock, the private TSL-
protected lock allows for checking the availability of the globally shared token. If not available, then
private lock released, other process can continue to work, and so on. The shared token is used for
accessing the overall shared data.

Department of Computer Science, University of Illinois at Urbana-Champaign 6


CS 423 Final Exam– Spring 2007 Name:_______________________

5. Problem – (Distributed) File System (20 Points)

1. (4 points) Describe how you would implement hard link and symbolic link in a UNIX like file
system

Answer: reference count for hard link, file contains pathname for another file

2. (4 points) What are the cons and pros of stateful vs stateless file servers in a distributed file systems.

Answer: stateful is more efficient, since server already knows about client state (e.g., read offset, etc.)
stateless is more reliable. When either server or client crashes, the other party is not affected. In
comparison, in stateful servers, if client crashes, server needs to detect failure and clean up the state.

3. (4 points) The Google File System is designed to work on thousands of unreliable PCs that may
crash at any time. Give two examples in the design of the Google File System that have taken this fact
into account.

Answer: (1) each chunk is replicated on three chunk servers; (2) whenever master fails and recovers, it
scans all chunk servers to reconstruct the state; (3) master is also replicated; (4) master heartbeat with
chunk servers to detect failures; (4) when write, client pushes data to all replicas, then sends write
request. Primary replica waits till all secondaries have replied, then reply.

4. (4 points) The beginning of a free space bitmap looks like this after the disk partition is first
formatted: 1000 0000 0000 0000 (the first block is used by the root directory). The system always
searches for free blocks staring at the lowest numbered block. So after writing file A, which uses 6
blocks, the bitmap looks like this: 1111 1110 0000 0000. Show the bitmap after each of the following
additional actions (note that the blocks of a file do not need to be allocated contiguously):
(a) File B is written, using 5 blocks
(b) File A is deleted
(c) File C is written, using 8 blocks
(d) File B is deleted
S
Answer: The beginning of the bitmap looks like:
(a) After writing file B: 1111 1111 1111 0000
(b) After deleting file A: 1000 0001 1111 0000
(c) After writing file C: 1111 1111 1111 1100

Department of Computer Science, University of Illinois at Urbana-Champaign 7


CS 423 Final Exam– Spring 2007 Name:_______________________

(d) After deleting file B: 1111 1110 0000 1100

5. (4 points) In a UNIX-like file system, each i-node has 40 bytes for disk block addresses. Because
the file sizes are expected to be small, only one single indirect block and one double indirect block is
used. What is the maximum file size in this file system (expressed in KBs)? Assume each disk block is
4KB, and disk block addresses are 4 bytes.

40 bytes can store 10 disk addresses. 8 of them point to data blocks. One points to single indirect
block, which points to 1024 data blocks. The last address points to a double indirect block which
points to 1024 single indirect blocks. These can point to 1024^2 data blocks. In total (8+1024 +
1024^2) disk blocks can be addressed within a file. Multiply this by 4K for file size.

Department of Computer Science, University of Illinois at Urbana-Champaign 8


CS 423 Final Exam– Spring 2007 Name:_______________________

6. Problem - Security (20 Points)

1. (4 Points) Explain what is access list and what is capability list

2. (4 Points) Explain what is authentication and what is authorization.

3. (5 Points) Consider a system with a trusted server (TS), an application server (AS) and a client C.
Each has a pair of public/private keys. Initially, both AS and C know the public key of TS ( K TSPub) and
TS has already known the public key of AS ( K ASPub). List the steps that C and AS can establish a
secure communication channel (using symmetric key encryption). The communication between any
two parties should not be visible to a third party.

Answer: (1) C sends its public key to TS, encrypted using TS’s public key
(2) TS sends AS’s public key to C, encrypted using C’s public key
(3) C generates a secret key, sends this key to AS, encrypted using AS’s public key
(4) AS and C can now exchange data securely.

The above does not consider authentication. I.e., when AS received secret key from client,
may want to authenticate client. AS can ask C to send some passwd, encrypted using AS’s
public key;

Department of Computer Science, University of Illinois at Urbana-Champaign 9


CS 423 Final Exam– Spring 2007 Name:_______________________

4. (7 Points) Kerberos protocol


Explain in a system where Kerberos protocol is used for authentication, the steps that a client (e.g.,
Alice) must take in order to establish a shared secret key Kab.with some server (e.g., Bob). For this
problem, consider the simple case where ticket granting service is not used and no pre-authentication
is needed. However, the client and server do need to mutually authenticate each other.

Use the following notations in your answer: A for Alice, B for Bob, Ka and Kb are the secret keys that
Alice and Bob, respectively, shares with the KDC (key distribution center). Kab is the session key that
needs to be established between Alice and Bob.

Answer: (1) Alice sends request to Kerberos server kdc


(2) Kerberos server sends Kab back, encrypted using Alice’s secret key; in addition it sends a
and a ticket back to Alice.
(3) Alice decrypts Kab using her secret key, then sends encrypted timestamp & ticket to Bob
(4) Bob decrypts ticket using his secret key and gets Kab. It then uses Kab to decrypt the
timestamp
(5) Bob sends timestamp+1, encrypted using Kab back to Alice
(6) Alice can decrypt this with Kab and thus authenticate Bob

Department of Computer Science, University of Illinois at Urbana-Champaign 10

You might also like