Beruflich Dokumente
Kultur Dokumente
fprintf() calls could lead to only one write() call. 5. While there are many dierent processor architectures, most desktop computers and servers use the Intel x86 architecture. From the point of view of operating systems, what are the advantages to this approach? Are there any disadvantages? Advantages: - Hardware development costs are spread over as many systems as possible. - Byte ordering is the same on every system. - Machine code may be somewhat portable between dierent computers. - The OS and drivers are portable between computers (booting XP or Linux on a MacBook Pro). Disadvantages: - Problems in the x86 architecture will aect nearly all computers. This includes hardware issues as well as (possibly) viruses. - The architecture may not be well-optimized for dierent types of systems (low-power, high-performance, etc.). - The x86 architecture tends to sacrice performance for backwards compatibility, and legacy features make certain OS implementation details harder. 6. Why is the process table needed in a timesharing system? Is it also needed in personal computer systems in which only one process exists, that process taking over the entire machine until it is nished? A process table is needed in a timesharing system because we need to know what information went along with a process when we swap it in and out to run it and other processes. In a system where only run process runs at a time, and it runs to completion, a process table is not needed. 7. For each of the following system calls, give a condition that causes it to fail: (a) read(): Read can fail on a closed le handle, end of le already read, a bad string (buer) pointer, or a le not opened for reading. Problems reading the le itself can also cause failure (disk failure, for example). (b) write(): Write can fail on a closed le handle, le not opened for writing, bad string pointer, lack of space on the device, or I/O error. (c) close(): You give close an incorrect le handle/descriptor. (d) fork(): Fork can fail if there are too many processes (either for this user for the whole operating system) or if theres not enough memory. (e) execvp(): Execvp can fail if the path name to the le you want to execute is incorrect, there are too many symbolic links in translating the path or le, or your argument list can be too long. (f ) waitpid(): Waitpid will fail if the process id given to it no longer exists.
8. There are several dierent approaches to operating system design. (a) Describe one advantage the monolithic modular approach has over the microkernel approach. Monolithic kernels are typically higher performance, and may be easier to write. (b) Describe one advantage the microkernel approach has over the monolithic modular approach. When one portion of the microkernel has a critical error, it doesnt necessarily bring down the rest of the microkernel with it. This can make microkernels more reliable. (c) If security is a bigger concern than speed (as it perhaps is today), which operating system design approach would you choose? Either answer is ne, as long as there is a good defense. Having said that, a microkernel makes it harder for rogue kernel processes to mess up the system. Compromising a single server process wouldnt necessarily compromise others. On the other hand, it may be easier to debug a monolithic kernel... 9. Here are some questions for practicing unit conversions: (a) How long is a microyear in seconds? We know that micro = 106 . We also know that a year is 3.155815296 * 107 seconds (source: ask.com). Then, a microyear is 106 * 3.155815296 * 107 31.558 seconds. This is one of those cases where you dont need 8 digits of precision. (b) If a car is traveling 25200 miles per fortnight, fast is it traveling in inches per second? A fortnight is 2 weeks = 14 days = 336 hours = 20,160 minutes = 1,209,600 seconds. 25,200 miles = 133,056,000 feet = 1,596,672,000 inches. 1,596,672,000 inches / 1,209,600 seconds = 1,320 inches/second (equivalent to 75 mph). (c) Micrometers are called microns. How long is a gigamicron? Again, micro = 106 . Giga = 109 . A gigamicron is 106 * 109 meters = 103 meters = 1 kilometer (km). (d) How many bytes are there in 1 terabyte of memory? Memory is measured in powers of 2, not 10, though a gigabyte in disk drive terms is typically a billion bytes. We want to know how many bytes are in a terabyte of memory. A terabyte is 240 bytes, which is 1099511627776 bytes. You get half credit for saying that a terabyte is 1012 bytesits approximately right, and the point of these questions is to get the answers right. (e) The mass of the earth ia 6000 yottagrams. What is that in kilograms? The prex yotta means 1024 . 6000 yottagrams is 6 * 103 * 1024 = 6 * 1027 grams. Since 1 kg = 103 grams, the earth weighs 6 * 1024 kg. 10. On all current computers, at least part of the interrupt handlers are written in assembly language. Why? There are actions (such as saving registers) that happen while an interrupt is being handled. These actions need to be written in assembly because they cannot be expressed in higher level languages. 11. When an interrupt or a system call transfers control to the operating system, a kernel stack area separate from the stack of the interrupted process is generally used. Why? Having a separate area reduces in the need to check that user programs dont overwrite data onto the kernel stack and vice versa. 12. What is the biggest advantage of implementing threads in user space? What is the biggest disadvantage?
Implementing threads in user space can allow a program to run on top of any OS, even if it doesnt support threading. The biggest disadvantage is allowing threads to make system calls that normally cause the OS to block to be made without halting the entire process since that would defeat the point of threading in the rst place. 13. Suppose that we have a message-passing system using mailboxes. When sending to a full mailbox or trying to receive from an empty one, a process does not block. Instead, it gets an error code back. The process responds to the error code by just trying again, over and over, until it succeeds. Does this scheme lead to race conditions? Why or why not? The message-passing system itself will not lead to race conditions, in the worst case it will lead the process starvation. You can argue about what the system does with messages once they are placed in the mailbox, but that is a dierent part of the problem.