Docsity

Midterm Exam #3 Good Luck!! QUESTION POINTS ..., Exams of Algorithms and Programming

Toggle sidebar
bg1
Page 1/12
University of California, Berkeley
College of Engineering
Computer Science Division – EECS
Spring 2018 Anthony D. Joseph and Jonathan Ragan-Kelley
Midterm Exam #3
April 25, 2018
CS162 Operating Systems
Your Name:
SID AND 162 Login:
TA Name:
Discussion Section
Time:
General Information:
This is a closed book and TWO 2-sided handwritten notes examination. You have 110 minutes
to answer as many questions as possible. The number in parentheses at the beginning of each
question indicates the number of points for that question. You should read all of the questions
before starting the exam, as some of the questions are substantially more time consuming.
Write all of your answers directly on this paper. Make your answers as concise as possible. If there
is something in a question that you believe is open to interpretation, then please ask us about it!
Good Luck!!
QUESTION
POINTS ASSIGNED
POINTS OBTAINED
1
36
2
22
3
22
4
20
TOTAL
100
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Midterm Exam #3 Good Luck!! QUESTION POINTS ... and more Exams Algorithms and Programming in PDF only on Docsity!

University of California, Berkeley College of Engineering Computer Science Division – EECS

Spring 2018 Anthony D. Joseph and Jonathan Ragan-Kelley

Midterm Exam

April 25, 2018 CS162 Operating Systems

Your Name:

SID AND 162 Login:

TA Name:

Discussion Section Time:

General Information: This is a closed book and TWO 2-sided handwritten notes examination. You have 110 minutes to answer as many questions as possible. The number in parentheses at the beginning of each question indicates the number of points for that question. You should read all of the questions before starting the exam, as some of the questions are substantially more time consuming.

Write all of your answers directly on this paper. Make your answers as concise as possible. If there is something in a question that you believe is open to interpretation, then please ask us about it!

Good Luck!!

QUESTION POINTS ASSIGNED POINTS OBTAINED

TOTAL 100

NAME: _______________________________________

  1. (30 points total) Short answer a. (12 points) True/False and Why? CHECK THE BOX FOR YOUR ANSWER. i) Pintos uses separate user-kernel mode transfer implementations for interrupts and syscalls.

❏ TRUE ❏ FALSE

ii) One only needs a source & destination IP address, source & destination port to uniquely identify a network connection.

❏ TRUE ❏ FALSE

iii) The Two Phase Commit protocol guarantees that all the participants commit or abort at the same time.

❏ TRUE ❏ FALSE

iv) Applying a conservative view of the End-to-End Principle to reliable file transfer means you should only implement reliability functionality at the endpoints.

❏ TRUE ❏ FALSE

Why?

Why?

Why?

Why?

NAME: _______________________________________

d. (4 points) What do the four letters in ACID stand for?

e. (3 points) Briefly explain how from a programmer’s prospective, using RPC differs from using procedure calls.

A______________________________________

C______________________________________

I______________________________________

D______________________________________

NAME: _______________________________________

  1. (22 points total) Revisiting Homework #2. Your new startup lets users watch streaming anime videos, so you reuse the code you wrote for homework #2 to create a simple video server that accepts client connections, reads in the video title string (e.g. "Kimi no Na wa."), and writes back the raw HD video file to the client. - Ignore HTTP formatting and headers – assume we read & write raw strings. - Make sure your code is multithreaded and allows handling of multiple simultaneous client connections. - Assume very large video files (possibly on the order of gigabytes or more). - Do not forget to clean up and not leak resources, including freeing memory and closing file descriptors when appropriate.

a) (16 points) Fill in the below code, including all blank lines and freeform boxes. Assume for this part that system calls will succeed when possible (i.e. you do not have to include, for example, checks for thread creation or malloc success). Also assume that the client connection does not drop or hang up prematurely.

#define MAX_LEN 20

#define BUFFER_SIZE 4096

void *serve_video(void *);

int main() {

pthread_t thread; struct sockaddr serv_addr,

cli_addr; int cli_len;

// sockaddr initialization code omitted

int sockfd = ________(PF_INET, SOCK_STREAM, 0);

________(sockfd, (struct sockaddr *) &serv_addr,

sizeof(serv_addr));

________(sockfd, 5);

while (1) {

int newsockfd = ________(sockfd, (struct

sockaddr *) &cli_addr, &cli_len);

_____________________________

_____________________________

return 0;

NAME: _______________________________________

b) (3 points) Assume you coded part a) correctly. Now suppose that malloc() failed in one the threads running serve_video(). Briefly, in 1-2 sentences, explain what would happen and why.

c) (3 points) Suppose you forgot to close any of your file descriptors in the above code and you run it indefinitely. Briefly, in 1-2 sentences, explain what could happen to your video server and why.

NAME: _______________________________________

  1. (22 points total) Filesystems. The Berkeley Fast File System (FFS) in BSD 4.2 was one of the first file systems that treated the disk like a disk and thus improved performance through spatial locality a. (3 points) What on-disk structures does FFS use to track allocation of inodes and data blocks?

b. (3 points) Why was the innovation in (3a) an improvement over the prior Unix file system in BSD 4.1?

c. (4 points) Recall that FFS tries to spread large files across disk by splitting them into chunks and putting each chunk in a different part of a block group. Given a hard drive with a peak transfer rate of 200Megabytes/s and that seek and rotation combined take on average 16 milliseconds. How big should each chunk of the file be so that we can achieve 2/3 of the peak transfer rate for large files when they are accessed sequentially? Show work outside of the box for partial credit.

d. (12 points) List the set of disk blocks that must be read into memory in order to read the file /cs162/bar/foo.txt in its entirely from a UNIX BSD 4. filesystem. Assume that the file is 12,300 Bytes long and that the disk blocks are 1 Kilobytes long. You can assume that each directory fits into a single disk block.

Blocks:

Number of Blocks: f

NAME: _______________________________________

b. (4 points) If M crashes after step 4 and no one else fails, what key will everyone end up using, once M reboots and recovers? Give the reason why.

c. (4 points) If B crashes after step 4 and no one else fails, what key will everyone end up using, once B reboots and recovers? Give the reason why.

Why:

Key: _________________

Why:

Key: _________________

NAME: _______________________________________

d. (4 points) If M crashes after step 10, what recovery steps must it take after it reboots in order to achieve the correct global state with respect to which encryption key to use?

e. (4 points) If W crashes after step 11, what recovery steps must it take after it reboots in order to achieve the correct global state with respect to which encryption key to use?