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:
- User A gets 10ms of CPU time
- CPU switches to User B (10ms)
- CPU switches to User C (10ms)
- CPU returns to User A (10ms)
- 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
- Multiple Users Sharing Cost - One expensive computer serves many users, reducing cost per user
- Interactive Computing - Users see immediate responses to their commands
- Efficient Resource Utilization - While one user’s program waits for I/O, another user’s program can use CPU
- Responsive System - Programs start quickly and feel fast to user
- Fairness - Round-robin scheduling ensures all users get equal CPU time
- Reduced Turnaround Time - Much faster than batch systems (seconds instead of hours)
Disadvantages of Time-Sharing Systems
- Complexity - Operating system design is very complex and difficult to manage
- Context Switching Overhead - Saving and loading process states takes processing time
- Security Issues - Multiple users sharing system makes it harder to protect privacy and prevent sabotage
- Memory Limitations - Limited memory must be shared among multiple users, so each program is restricted in size
- Unpredictable Response Time - System performance depends on number of users; more users = slower response
- Synchronization Problems - Preventing conflicts when multiple users access same resources is complex
- 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
- Fast CPU - Must switch between users rapidly without user noticing
- Sufficient Memory - Enough to hold multiple programs simultaneously
- Good I/O System - Handle requests from multiple users without bottleneck
- Reliable Interrupt Mechanism - For timing and switching
- Memory Protection - Prevent programs from interfering with each other
- Fairness Mechanism - Ensure no user starves (always gets turn)
- 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
| Aspect | Batch System | Time-Sharing System |
|---|---|---|
| User Interaction | No interaction | Full interaction |
| Response Time | Hours/Days | Seconds |
| Number of Users | One logical user | Many simultaneous |
| User Feel | Automatic processing | Having own computer |
| Cost per User | Very high | Very low |
| Complexity | Simple | Complex |
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
- What is time-sharing system? Define it.
- How does round-robin scheduling work in time-sharing?
- What is time quantum/time slice? What happens if it’s too small or too large?
- Compare batch and time-sharing systems.
- What are advantages and disadvantages?
- How does context switching work?
- What are requirements for time-sharing system?
- Explain hardware configuration (central computer + terminals)
- How does response time change with system load?
- Name three real time-sharing operating systems.