cs345 – operating systems recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345...

27
cs345 – operating systems Recitation 3

Upload: others

Post on 09-Sep-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

cs345 – operating systemsRecitation 3

Page 2: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 4.5Question?Some operating systems provide a system call rename to give a file a new name. Is there any difference at all between using this call to rename a file and just copying the file to a new file with the new name, followed by deleting the old one?

Page 3: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 4.5Answer:Yes. The rename call does not change the creation time or the time of last modification, but creating a new file causes it to get the current time as both the creation time and the time of last modification. Also, if the disk is full, the copy might fail.

Page 4: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 4.16Question?It has been suggested that efficiency could be improved and disk space saved by storing the data of a short file within the i-node. For the i-node of Fig. 3, how many bytes of data could be stored inside the i-node?

Page 5: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 4.16Answer:There must be a way to signal that the address block pointers hold data, rather than pointers. If there is a bit left over somewhere among the attributes, it can be used. This leaves all nine pointers for data. If the pointers are k bytes each, the stored file could be up to 9*k bytes long. If no bit is left over among the attributes, the first disk address can hold an invalid address to mark the following bytes as data rather than pointers. In that case, the maximum file is 8*k bytes.

Page 6: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 4.22Question?Oliver Owl’s night job at the university computing center is to change the tapes used for overnight data backups. While waiting for each tape to complete, he works on writing his thesis that proves Shakespeare’s plays were written by extraterrestrial visitors. His text processor runs on the system being backed up since that is the only one they have. Is there a problem with this arrangement?

Page 7: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 4.22Answer:Ollie’s thesis may not be backed up as reliably as he might wish. A backup program may pass over a file that is currently open for writing, as the state of the data in such a file may be indeterminate.

Page 8: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 5.9Question?A typical printed page of text contains 50 lines of 80 characters each. Imagine that a certain printer can print 6 pages per minute and that the time to write a character to the printer’s output register is so short it can be ignored. Does it make sense to run this printer using interrupt-driven I/O, if each character printed requires an interrupt that takes 50 μsec all-in to service?

Page 9: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 5.9Answer:The printer prints 50 × 80 × 6 = 24,000 characters/min, which is 400 characters/sec. Each character uses 50 μsec of CPU time for the interrupt, so collectively in each second the interrupt overhead is 20 msec. Using interrupt driven I/O, the remaining 980 msec of time is available for other work. In other words, the interrupt overhead costs only 2% of the CPU, which will hardly affect the running program at all.

Page 10: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 5.10Question?Explain how an OS can facilitate installation of a new device without any need for recompiling the OS. Is everything a file?

Page 11: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 5.10Asnwer:UNIX does it as follows. There is a table indexed by device number, with each table entry being a C struct containing pointers to the functions for opening, closing, reading, and writing and a few other things from the device. To install a new device, a new entry has to be made in this table and the pointers filled in, often to the newly loaded device driver.

A wide range of input/output resources such as documents, directories, hard-drives, modems, keyboards, printers and even some inter-process and network communications are simple streams of bytes exposed through the filesystem name space. The advantage of this approach is that the same set of tools, utilities and APIs can be used on a wide range of resources. There are a number of file types. When a file is opened a file descriptor is created. The file path becoming the addressing system and the file descriptor being the byte stream I/O interface. But file descriptors are also created for things like anonymous pipes and network sockets via different methods. So it is more accurate to say ”Everything is a file descriptor”.

Page 12: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 5.16Question?Compare RAID level 0 through 5 with respect to read performance, write performance, space overhead, and reliability.

Page 13: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 5.16Answer:Read performance: RAID levels 0, 2, 3, 4, and 5 allow for parallel reads to service one read request. However, RAID level 1 further allows two read requests to simultaneously proceed. Write performance: all RAID levels provide similar. Space overhead: There is no space overhead in level 0 and 100% overhead in level 1. With 32-bit data word and six parity drives, the space overhead is about 18.75% in level 2. For a 32-bit data word, the space overhead in level 3 is about 3.13%. Finally, assuming 33 drives in levels 4 and5, the space overhead is 3.13% in them.

Reliability: There is no reliability support in level 0. All other RAID levels can survive one disk crash. In addition, in levels 3, 4 and 5, a single random bit error in a word can be detected, while in level 2, a single random bit error in a word can be detected and corrected.

Page 14: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 5.xQuestion?Can flash memory replace DRAM in a PC or a Server? What will happened if so?

Page 15: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 5.xAnswer:

http://news.mit.edu/2015/cutting-cost-power-big-data-0710

Page 16: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 5.22Question?A disk manufacturer has two 5.25-inch disks that each have 10,000 cylinders. The newer one has double the linear recording density of the older one. Which disk properties are better on the newer drive and which are the same?

Page 17: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 5.22Answer:

The drive capacity and transfer rates are doubled. The seek time and average rotational delay are the same.

Page 18: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 8.2Question?

What happens if two CPUs in a multiprocessor attempt to access exactly the same word of memory at exactly the same instant?

Page 19: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 8.2Answer:Depending on the details of how CPUs are connected to memory, one of them gets through first, for example, seizes the bus first. It completes its memory operation, then the other one happens. It is not predictable which one goes first, but if the system has been designed for sequential consistency, it should not matter

Page 20: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 8.20Question?How must the implementation of send and receive differ between a shared memory multiprocessor system and a multicomputer, and how does this affect performance?

Page 21: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 8.20Answer:On a shared-memory machine it suffices to pass the pointer to the message from the CPU executing the send to the CPU executing the receive, with possible translations between virtual and physical memory addresses. On a multicomputer without shared memory, an address in one CPU’s address space has no meaning to another CPU, so the actual contents of the send buffer have to be transmitted as packets and then reassembled in the buffer of the receiving process. To the programmer the processes look identical, but the time required will be much longer on the multicomputer.

Page 22: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 8.25Question?Some multicomputers allow running processes to be migrated from one node to another. Is it sufficient to stop a process, freeze its memory image, and just ship that off to a different node? Name two nontrivial problems that have to be solved to make this work.

Page 23: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 8.25Answer:The table of open files is kept in the kernel, so if a process has open files, when it is unfrozen and tries to use one of its files, the new kernel does not know about them. A second problem is the signal mask, which is also stored on the original kernel. A third problem is that if an alarm is pending, it will go off on the wrong machine. In general, the kernel is full of bits and pieces of information about the process, and they have to be successfully migrated as well.

Page 24: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 8.29Question?Does it make sense to paravirtualize an operating system if the source code is available? What if it is not?

Page 25: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 8.29Answer:Yes of course. Linux has been paravirtualized precisely because the source code is available. Windows has not been paravirtualized because the source code is not available.

Page 26: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 8.32Question?Running multiple virtual machine on a PC is known to require large amounts of memory. Why? Can you think of any ways to reduce the memory usage? Explain.

Page 27: cs345 – operating systems Recitation 3hy345/assignments/2019/... · 2019. 12. 13. · cs345 –operating systems Recitation 3. Problem 4.5 Question? Some operating systems provide

Problem 8.32Answer:Not only does the machine need memory for the normal (guest) operating system and all its applications, but it also needs memory for the hypervisor functions and data structures needed to execute sensitive instructions on behalf of the guest OS. Type 2 hypervisors have the added cost of the host operating system. Moreover, each VM will have its own operating system. One way to reduce memory usage would be to identified ”shared code” and only keep one copy of this code in memory. For example, a web hosting company may run multiple VMs, each running an identical version of the Linux operating system code and an identical copy of the Apache web server code. In this case, the code segment can be shared across VMs, even though the data regions must be private.