An operating system manages hardware resources and provides services for programs.
Key Functions
- Process Management — scheduling, multitasking
- Memory Management — allocation, virtual memory
- File System — organizing storage
- Security — access control
An operating system manages hardware resources and provides services for programs.
# Process states
New → Ready → Running → Terminated
↓
Waiting → Ready
# Round Robin scheduling def round_robin(processes, quantum): n = len(processes) remaining = [p[1] for p in processes] time = 0 while True: done = True for i in range(n): if remaining[i] > 0: done = False if remaining[i] > quantum: time += quantum remaining[i] -= quantum else: time += remaining[i] remaining[i] = 0 print(f"{processes[i][0]} completed at t={time}") if done: break processes = [("P1", 10), ("P2", 4), ("P3", 6)] round_robin(processes, quantum=3)
What are the main functions of an OS?
Process management, memory management, file system management, security, and I/O management.
What is multitasking?
Multitasking allows multiple processes to share CPU time.
A process is an independent program with its own memory. A thread shares memory with other threads in the same process. Threads are lightweight.