Operating System Fundamentals: Core Concepts and Design Issues

1.1 Main Purposes of an Operating System

Question: What are the three main purposes of an operating system?

Answer: The three main purposes are:

  1. To provide an environment for a computer user to execute programs.
  2. To allocate the separate resources of the computer as needed to solve the problem at hand. The allocation process should be as fair and efficient as possible.
  3. As a control program, it serves two major functions:
    • Supervision of the execution of user programs to prevent errors and improper use of the computer.
    • Management of the operation and control of I/O devices.

1.2 OS Differences: Batch Systems vs. Personal Computers

Question: What are the main differences between operating systems for mainframe batch systems and those for personal computers?

Answer: Generally, operating systems for batch systems have simpler resource management requirements. Batch systems do not have to be concerned with interacting with a user as much as a personal computer (PC) operating system does. As a result, an operating system for a PC must be concerned with responsiveness and user experience, which batch systems do not prioritize. A pure batch system also may not have to handle time sharing, whereas a modern operating system must switch rapidly between multiple processes to give the illusion of simultaneous execution.

1.3 Steps to Run a Program on a Bare System

Question: List the four steps that are necessary to run a program on a completely empty machine (one without an operating system).

Answer: The four steps are:

  1. 1 [Load the program into memory]
  2. 2 [Set up necessary registers and environment]
  3. [Transfer control to the program’s starting address]
  4. [Handle program termination or errors]

(Note: The original text provided only fragments ‘1’ and ‘2’.)

1.4 Efficiency vs. User Convenience in OS Design

Question: We have stressed the need for an operating system to make efficient use of the computer hardware. When is it appropriate for the operating system to compromise efficiency for the sake of user convenience? Why is such a compromise necessary?

Answer: Single-user systems should maximize use of the system for the user’s benefit, even if it means slightly less efficient hardware utilization. For example, a Graphical User Interface (GUI) might waste CPU cycles compared to a command-line interface, but it significantly optimizes the user’s experience and productivity. This compromise is necessary because, in a single-user environment, the user’s time is often the most critical resource.

1.5 Challenges in Real-Time Operating System Development

Question: What is the main difficulty that a programmer must overcome in writing an operating system for a real-time environment?

Answer: The main difficulty is keeping the operating system within strict time constraints. If the system does not complete a task in a certain time frame, it may cause a breakdown or catastrophic failure in the controlled system (e.g., industrial machinery or medical devices). Therefore, when writing an operating system for a real-time system, the writer must be sure that the scheduling algorithms guarantee timely execution and predictability.

1.6 Should Applications Be Part of the Operating System?

Question: Consider the various definitions of operating system. Next, consider whether the operating system should include applications such as Web browsers and email clients. Argue both that it should and that it should not.

Answer:

Point: Applications Should Be Incorporated

Applications such as web browsers and email tools are performing an increasingly important role in modern desktop computing. To fulfill this role effectively, they should be incorporated as part of the operating system. By doing so, they can provide better performance through tighter integration with system resources. In addition, these important applications can have the same look-and-feel as the operating system software, providing a more cohesive user experience.

Counterpoint: Applications Should Remain Separate

The fundamental role of the operating system is to manage system resources such as the CPU, memory, I/O devices, etc. In addition, its role is to run software applications such as web browsers and email clients. By incorporating such applications into the operating system, we burden the operating system with additional functionality. Such a burden may result in the operating system performing a less-than-satisfactory job of resource management. In addition, we increase the size of the operating system, thereby increasing the likelihood of security vulnerabilities and system instability.

1.7 Function of Kernel Mode and User Mode Distinction

Question: How does the distinction between kernel mode and user mode function to provide protection in a computer system?

Answer: The distinction between kernel mode and user mode provides a mechanism for protecting the operating system and critical hardware resources from user programs. Certain instructions (privileged instructions) can only be executed when the CPU is in kernel mode. Similarly, hardware devices could be accessed only when the program is executing in kernel mode. Control over when interrupts could be enabled or disabled is also restricted to kernel mode. Consequently, the CPU has very limited capability when executing in user mode, preventing accidental or malicious damage to the system.

1.8 Identifying Privileged Instructions

Question: Which of the following instructions should be privileged?

Instructions:

  • Set the value of the timer.
  • Clear memory.
  • Turn off interrupts.
  • Modify entries in the device-status table.
  • Access I/O device.

Answer: All of the listed instructions should be privileged. These operations directly affect system integrity, resource allocation, and hardware control, and thus must be restricted to the operating system kernel to ensure proper functioning and security.

1.9 Difficulties with Early OS Memory Protection

Question: Some early computers protected the operating system by placing it in a memory partition that could not be modified by either the user job or the operating system itself. Describe two difficulties that you think would arise with this scheme.

Answer: Two difficulties are:

  1. Data Exposure: The data required by the operating system (passwords, access controls, accounting information, and so on) would have to be stored in or passed through unprotected memory and thus be accessible to user programs.
  2. Inflexibility/Updates: The operating system itself could not be modified or updated while running, making bug fixes or system upgrades extremely difficult, potentially requiring a complete system shutdown and reboot from external media.

1.10 Advantages of Multiple Operating Modes

Question: Although most systems only distinguish between user and kernel mode, what are the advantages of having multiple modes of operation?

Answer: Multiple modes could provide finer-grained protection and resource control. For example, rather than distinguishing between just user and kernel mode, perhaps a third mode could be introduced for specific system administrators or trusted applications. The machine would go into a specified mode when one of these users was logged in or when the trusted application was running. When the machine was in this mode, a member of the trusted group could execute certain restricted instructions that regular users cannot. Another possibility would be to provide different distinctions within the kernel mode itself. For example, a specific mode could allow USB device drivers to run with elevated privileges but still restrict access to core memory management functions. This would mean that USB devices could be serviced without having to switch to the highest kernel mode, thereby essentially allowing USB device drivers to operate with reduced risk.

1.11 Using Timers to Calculate Current Time

Question: Timers could be used to compute the current time. Provide a short description of how a program could use this approach.

Answer: A program could use the following approach to compute the current time: The program could set a timer for some time in the future and go to sleep. When it is awakened by the interrupt, it could update its local state, which it is using to keep track of the elapsed time since initialization. It could then repeat this process of continually setting timer interrupts and updating its local time counter. This method relies on the operating system or hardware providing accurate, periodic timer interrupts.