Computer System Architecture - Exercise

Computer System Architecture - Exercise

1. How do clustered systems differ from multiprocessor systems? What is required for two machines in a cluster to cooperate to provide a highly available service?

Clustered Systems vs. Multiprocessor Systems:

  • Clustered Systems: Comprise multiple independent computers (nodes) connected via a network, each with its own memory and OS. They work together to perform tasks and communicate through network protocols.
  • Multiprocessor Systems: Feature multiple processors sharing a common memory and OS, tightly coupled with high-speed interconnects.

Requirements for High Availability:

  1. Shared Storage: Both machines must access the same data storage to maintain consistency.
  2. Failover Mechanism: Automatic transfer of control to a standby machine if the primary machine fails.
  3. Heartbeat Signals: Regular health checks to ensure all nodes are operational.
2. Consider a computing cluster with two nodes running a database. Describe two ways the cluster software can manage data access on the disk. Discuss the benefits and disadvantages of each.

Method 1: Shared Disk Access

  • Description: Both nodes access the same disk.
  • Benefits: Simplicity, real-time data consistency.
  • Disadvantages: Potential for data corruption if not managed properly, single point of failure in the disk.

Method 2: Data Replication

  • Description: Each node has a copy of the data.
  • Benefits: Redundancy, no single point of failure.
  • Disadvantages: Complexity in maintaining data consistency, increased storage requirements.
3. What is the purpose of interrupts? How does an interrupt differ from a trap? Can traps be generated intentionally by a user program? If so, for what purpose?

Purpose of Interrupts:

  • Function: Allow the CPU to respond to asynchronous events, improving system efficiency by handling tasks like I/O operations without continuous polling.

Interrupts vs. Traps:

  • Interrupt: Generated by hardware devices to signal an event (e.g., I/O completion).
  • Trap: Generated by the CPU or software to signal an error or specific condition (e.g., divide by zero).

Intentionally Generated Traps:

  • Usage: Allow user programs to request services from the operating system (system calls) or handle specific conditions for debugging and error management.
4. Explain how the Linux kernel variables HZ and jiffies can be used to determine the number of seconds the system has been running since it was booted.

HZ and Jiffies:

  • HZ: Defines the number of timer interrupts per second.
  • Jiffies: Counter that increments with each timer interrupt.
  • Calculation: uptime (seconds) = jiffies / HZ.
5. Direct memory access is used for high-speed I/O devices to avoid increasing the CPU’s execution load. How does the CPU interface with the device to coordinate the transfer? How does the CPU know when the memory operations are complete? Does DMA interfere with the execution of user programs?

CPU-DMA Coordination:

  • Setup: CPU initializes DMA by setting source, destination, and transfer size in the DMA controller.

Completion Notification:

  • Interrupt: DMA controller sends an interrupt to the CPU upon completing the data transfer.

Interference with User Programs:

  • Cycle Stealing: DMA controller may temporarily use the CPU’s bus cycles, potentially slowing down user programs but not halting them.
6. What is the purpose of privileged mode, and can you construct a secure OS without it? Give arguments for both sides.

Purpose of Privileged Mode:

  • Function: Restricts access to critical instructions and resources, ensuring system stability and security.

Arguments for Secure OS Without Privileged Mode:

  • Possible: By implementing software-based protection mechanisms like sandboxing and virtualization.

Arguments Against:

  • Challenging: Less robust and efficient compared to hardware-based protection, harder to enforce strict security policies.
7. Why are caching systems designed with multiple levels in SMP systems?

Multi-Level Caching:

  • Reason: To balance speed and cost, with small, fast caches (L1) close to the CPU and larger, slower caches (L2/L3) shared among cores, improving overall system performance.
8. Rank the following storage systems from slowest to fastest: Hard-disk drives, Registers, Optical disk, Main memory, Nonvolatile memory, Magnetic tapes, Cache
  1. Magnetic Tapes
  2. Optical Disk
  3. Hard-Disk Drives
  4. Nonvolatile Memory
  5. Main Memory
  6. Cache
  7. Registers
9. What are the advantages and disadvantages of open-source operating systems?

Advantages:

  • Transparency: Code is publicly available for inspection, improving security.
  • Customization: Users can modify the OS to suit their needs.
  • Community Support: Active user and developer communities contribute to improvements and bug fixes.

Disadvantages:

  • Support: May lack professional support compared to commercial OSes.
  • Compatibility: Not all software and hardware are compatible.
  • Complexity: Can be difficult for non-technical users to configure and manage.
10. How does the distinction between kernel mode and user mode function as a rudimentary form of protection (security) system?

Answer: Kernel mode allows the operating system to execute privileged instructions and access hardware directly, while user mode restricts access to prevent user applications from performing potentially harmful operations. This separation helps protect the system from accidental or malicious damage.

11. Which of the following instructions should be privileged? a. Set value of timer. b. Read the clock. c. Clear memory. d. Issue a trap instruction. e. Turn off interrupts. f. Modify entries in device-status table. g. Switch from user to kernel mode. h. Access I/O device.

Answer:

  1. Privileged Instructions:

    • Set value of timer: Requires control over system timing mechanisms to enforce process scheduling.
    • Clear memory: Involves direct manipulation of memory, which could affect system stability.
    • Turn off interrupts: Disabling interrupts can compromise system responsiveness and stability.
    • Modify entries in device-status table: Alters the state of hardware devices, which could interfere with other processes.
    • Switch from user to kernel mode: Elevates process privileges, potentially bypassing security mechanisms.
    • Access I/O device: Direct interaction with hardware that could disrupt system operations.
  2. Non-Privileged Instructions:

    • Read the clock: Only involves retrieving the current time, no modification of system state.
    • Issue a trap instruction: Used to request services from the operating system, typically allowed in user mode.

Sources: