Operating System Structures

Jun 27, 2024

Operating System Structures

Types of Operating Systems

  1. Multi-programming Operating System
  2. Time-sharing Operating System

Multi-programming Operating System

  • Definition: Placing multiple programs in the main memory to utilize the CPU efficiently.
  • Main Memory Division:
    • Operating System
    • User Programs
  • Example:
    • Assumptions: Programs P1, P2, P3 in main memory.
    • Execution Process:
      • CPU begins executing P1.
      • If P1 needs I/O operation, CPU becomes idle.
      • Operating system allocates CPU to another process (P2).
      • Repeat the above steps if P2 needs I/O operation.
      • Allocate CPU to P3.
  • Process: A program under execution.
  • Efficiency: Executing processes concurrently to utilize CPU effectively.
  • Speed: CPU is faster than main memory; compensating speed difference by keeping more programs in memory.
  • Memory Limitation: Only currently executing programs are kept in main memory due to its smaller size compared to the hard disk.
  • Advantage: Improved CPU performance by keeping multiple programs in main memory.

Time-sharing Operating System

  • Definition: Extension of multi-programming where CPU time is shared among available processes.
  • CPU Time Sharing:
    • CPU time is divided into time slots allocated to each process.
    • Example:
      • Processes P1, P2, P3 in main memory.
      • P1 needs 4ms, P2 needs 6ms, P3 needs 8ms for execution.
      • Operating system allocates 2ms time slot to each process initially.
      • P1 executes for 2ms, remaining 2ms.
      • P2 executes for 2ms, remaining 4ms.
      • P3 executes for 2ms, remaining 6ms.
      • The CPU then cycles back to P1 and repeats.
  • Frequent Switching: CPU frequently switches between processes, enhancing interactivity.
  • User Perspective: Appears as if their process is being executed constantly.

Key Points

  • Multi-programming and Time-sharing systems aim to optimize CPU utilization.
  • Both types involve managing multiple processes but differ in how CPU time is allocated.
  • Multi-programming focuses on keeping the CPU busy by loading several programs into memory.
  • Time-sharing ensures fair CPU time distribution among processes, thus improving user interactivity.