Time Sharing Systems

Definition

Time-sharing system is a type of operating system in which multiple users use the same computer at the same time through different terminals. Each user gets a small portion of CPU time called a “time slice” or “time quantum” (usually 10-50 milliseconds). The CPU switches between users so quickly that each user feels they have exclusive access to the computer.

Basic Concept

In a time-sharing system:

  • Multiple users work simultaneously on one powerful central computer
  • Each user has their own terminal (keyboard, mouse, screen)
  • CPU allocates time slots to each user in rotation
  • Rapid context switching happens between users
  • Users feel interactive response because switching is very fast

How Time-Sharing Works

The operating system maintains a queue of users waiting for CPU time. It works like this:

  1. User A gets 10ms of CPU time
  2. CPU switches to User B (10ms)
  3. CPU switches to User C (10ms)
  4. CPU returns to User A (10ms)
  5. Process continues in round-robin fashion

Because switching happens in milliseconds (1/1000th of a second), users don’t notice the interruption. Each user’s program appears to run continuously.

Hardware Configuration

Central Computer: One very powerful machine

  • High processing power
  • Large memory
  • Multiple I/O devices
  • Manages all users

User Terminals: Multiple “dumb” terminals connected to central computer

  • Keyboard for input
  • Screen for output
  • No processing power
  • Just input/output devices

Scheduling Mechanism

Round-Robin Scheduling

Each user gets equal CPU time in rotation without priority or special treatment.

Priority Scheduling (Optional)

Some system allocate more time to important users or processes. For example:

  • Teacher’s job gets more time than student’s job
  • Important tasks complete first

Advantages of Time-Sharing Systems

  1. Multiple Users Sharing Cost - One expensive computer serves many users, reducing cost per user
  2. Interactive Computing - Users see immediate responses to their commands
  3. Efficient Resource Utilization - While one user’s program waits for I/O, another user’s program can use CPU
  4. Responsive System - Programs start quickly and feel fast to user
  5. Fairness - Round-robin scheduling ensures all users get equal CPU time
  6. Reduced Turnaround Time - Much faster than batch systems (seconds instead of hours)

Disadvantages of Time-Sharing Systems

  1. Complexity - Operating system design is very complex and difficult to manage
  2. Context Switching Overhead - Saving and loading process states takes processing time
  3. Security Issues - Multiple users sharing system makes it harder to protect privacy and prevent sabotage
  4. Memory Limitations - Limited memory must be shared among multiple users, so each program is restricted in size
  5. Unpredictable Response Time - System performance depends on number of users; more users = slower response
  6. Synchronization Problems - Preventing conflicts when multiple users access same resources is complex
  7. Debugging Difficulty - Hard to debug problems in multi-user environment

Key Components

1. Scheduler

Decides which user process gets CPU next and for how long. Maintains queue of ready processes.

2. Context Switcher

Saves the state (variables, instruction pointer, registers) of current process and loads the state of next process.

3. I/O Manager

Handles requests from multiple users for devices like disk, printer, network. Creates queue of requests and processes them fairly.

4. Memory Manager

Allocates and protects memory for each user. Prevents one user’s program from damaging another’s data.

5. Timer/Interrupt Handler

Generates interrupt when user’s time slice expires. Triggers context switch to next user.

Response Time vs System Load

Response time (time to see result) depends on system usage:

  • Light load (few users) → Very fast response (seconds)
  • Heavy load (many users) → Slower response (longer seconds)
  • Overloaded (too many users) → Very slow or unresponsive

Requirements for Time-Sharing System

  1. Fast CPU - Must switch between users rapidly without user noticing
  2. Sufficient Memory - Enough to hold multiple programs simultaneously
  3. Good I/O System - Handle requests from multiple users without bottleneck
  4. Reliable Interrupt Mechanism - For timing and switching
  5. Memory Protection - Prevent programs from interfering with each other
  6. Fairness Mechanism - Ensure no user starves (always gets turn)
  7. Security - Isolate user data and prevent unauthorized access

Real Examples in History

  • UNIX (1970s) - Revolutionary time-sharing operating system
  • MULTICS (1960s) - Early mainframe time-sharing system
  • CTSS (1960s) - Compatible Time-Sharing System

Modern Operating Systems

All modern operating systems use time-sharing principles:

  • Linux - Multi-user time-sharing system
  • Windows - Multi-user capable
  • macOS - Based on UNIX, time-sharing system

Difference from Batch System

AspectBatch SystemTime-Sharing System
User InteractionNo interactionFull interaction
Response TimeHours/DaysSeconds
Number of UsersOne logical userMany simultaneous
User FeelAutomatic processingHaving own computer
Cost per UserVery highVery low
ComplexitySimpleComplex

Time Quantum (Time Slice)

The amount of CPU time given to each user before switching to next user.

Too small time quantum:

  • Frequent switching
  • Too much context switch overhead
  • System slows down
  • Wastes CPU time on switching

Too large time quantum:

  • User feels delay
  • Not responsive
  • Other users wait too long
  • Becomes like batch system

Optimal time quantum: Usually 10-50 milliseconds after testing and analysis.

Important Terms to Remember

Context Switching: Process of saving current user’s state and loading next user’s state

Time Quantum: Fixed time slice each user gets

Time Slice: Same as time quantum

Response Time: Time from user input to visible result

Turnaround Time: Time from job submission to completion

Throughput: Number of jobs/requests completed per unit time

Typical Exam Questions

  1. What is time-sharing system? Define it.
  2. How does round-robin scheduling work in time-sharing?
  3. What is time quantum/time slice? What happens if it’s too small or too large?
  4. Compare batch and time-sharing systems.
  5. What are advantages and disadvantages?
  6. How does context switching work?
  7. What are requirements for time-sharing system?
  8. Explain hardware configuration (central computer + terminals)
  9. How does response time change with system load?
  10. Name three real time-sharing operating systems.