Homework 1 Solutions

Class average: 8.6 / 10

[1] 1.4   What are the main differences between operating systems for mainframes and PCs?

   Mainframe OSs are designed with expert users in mind, and aim to maximize utilization of the CPU and peripheral devices.  PC OSes are designed for the general (non-expert) user, and aim to maximize convenience and responsiveness.  Furthermore, mainframe OSs are traditionally built for fairness and security among multiple users while PC OSs are intended for a single user (though this distinction is becoming less and less eminent).


[1] 1.11  Consider the various definitions of operating system.  Consider whether the operating system should include applications such as web browsers and mail programs.  Argue both pro and con positions, and support your answers.

Pros:
   It is generally accepted today that almost all users will want web access and email capability, to this end, it is of greater convenience to the user if a web browser and email client are packaged with the OS.  Furthermore, coupling a web browser (or other application) with the OS can provide certain performance advantages.  For example, because IE is coupled with Windows, it is cached while windows boots up - this makes for faster program loading, this is opposed to Mozilla which is not (by default) cached by Linux, and so loads slowly every time it is invoked.

Cons:
   The problems of Microsoft and its monopoly are evident.  It could also be argued that the function of an OS is to provide a basis for applications (e.g. web browsers, email programs) and to act as an intermediary between a user and the hardware.  Thus inclusion of a web browser in the OS would be wrong because it violates the definition of an OS.


[1] 1.x: The chapter stresses the need for an OS to make efficient use of computing resources -- is this really as necessary on a single-user PC with, e.g., a 3 GHz processor?

   If that one user is infinitely patient, perhaps. But if they're like the rest of us, they'd like it to appear that their processes are running simultaneously and as fast as possible, and this requires efficient use of resources. Just because a system doesn't have multiple users doesn't mean it doesn't have competition for its resources. While it may not be as difficult to do on a one-person machine, it is still necessary.


[1] 2.3  What are the differences between a trap and an interrupt?  What is the use of each function?

   Depending on whether we go with the definition from the book or from lecture, an interrupt is either any event which must be handled by the operating system, or an asynchronous hardware- generated event. A trap is either a synchronous, software-generated event (error or no), or an expected one of these (i.e. not an error). They are both used to transfer control to the operating system to receive a service or handle an error.


[2] 2.9  Give two reasons why caches are useful.  What problems do they solve?  What problems to they cause?  If a cache can be made as large as the device for which caching (for instance, as large as a disk), why not make it that large and eliminate the device?

   Caches are useful because they can increase the speed of the average memory access, and they do so without taking up as much physical space as the lower elements of the memory hierarchy.  They ameliorate the (performance critical) memory access time by leveraging spatial and temporal locality.  Unfortunately, caches also introduce an additional level of complexity (coherency and consistency assurance).  We also incur an economic and space (at the computer organization level) penalty when we add a cache.  Making a cache as large as a disk would be ineffective because it would be too costly, the immense size would slow it down, and a cache is generally a volatile memory, while we want data on disks to be persistent.


[1] 2.10  Writing an operating system that can operate without interference from malicious or undebugged user programs requires hardware assistance.  Name three hardware aids for writing an operating system, and describe how they could be used to protect the operating system.

-
Dual-mode bit: Allows hardware-level distinction between user and system modes and hence protects the
  OS from malicious or faulty user programs by restricting dangerous behavior to system mode operation.

- Memory protection (base and limit registers): Base and limit registers effectively define the legal address
  range of a program and as such, they allow the CPU to check that every address a program generates is
  legal, protecting memory from malicious or wonton accesses.

- Fixed-rate clock and counter for interrupts: A clock and counter can be used to implement regular interrupts
  (and context switches to the OS) through which we can avoid the possibility of getting stuck in an infinite
  user-space loop.


[1] 3.7  What is the purpose of system calls?

   System calls provide a protected point of entry to the operating system, so that it can run services that require privilege without granting unlimited privilege to the user program.


[1] 3.11  What is the main advantage of the layered approach to system design?

   The main advantage of the layered approach to system design is modularity, this makes development, maintenance, debugging, and verification easier.


[1] 3.12  What is the main advantage of the microkernel approach to system design?

   The advantage of the microkernel approach to system design is that the kernel is small, so it is easy to deal with (e.g. modify, port).  The microkernel approach is also beneficial in that it allows for easy, user-space extension of capability.