Introduction
An operating system (OS) is software that manages computer hardware and software resources. It provides services for programs and acts as a bridge between users and hardware. Understanding the basics of operating systems is important for both students and professionals. This cheatsheet covers the most essential concepts in simple language, accompanied by concise examples.
1. Types of Operating Systems
Batch OS: Executes jobs in batches without user interaction.
Time-Sharing OS: Multiple users share the system simultaneously.
Distributed OS: Multiple computers connected and act as one system.
Real-Time OS (RTOS): Gives quick response to inputs, used in embedded systems.
2. Functions of OS
Process Management: Creates, schedules, and terminates processes.
Memory Management: Allocates and tracks memory use.
File System Management: Manages files, directories, and permissions.
Device Management: Controls input/output devices.
Security and Protection: Protects data and user access.
3. Process and Threads
Process: A program in execution.
Example: Running notepad.exe is a process.
Thread: A smaller unit inside a process that executes tasks.
Key Point: Threads share memory of the process, but processes do not share memory by default.
4. Process States
New: Process is created.
Ready: Waiting for CPU.
Running: Executing instructions.
Waiting: Waiting for I/O.
Terminated: Finished execution.
5. Scheduling Algorithms
Decides which process runs on the CPU.
FCFS (First Come First Serve): Runs in order of arrival.
SJF (Shortest Job First): Picks the smallest job first.
Round Robin: Each process gets an equal time slice.
Priority Scheduling: Runs based on priority.
Example (Round Robin with 2 sec time quantum)
P1 (5s), P2 (3s), P3 (1s)
Order: P1→P2→P3→P1→P2→P1
6. Inter-Process Communication (IPC)
Processes exchange data using:
Pipes: One-way communication.
Message Queues: Stores messages for processes.
Shared Memory: Multiple processes access the same memory.
Example (Pipe in Linux)
ls | grep file
7. Deadlock
When processes wait forever for resources. Conditions for deadlock,
Mutual Exclusion
Hold and Wait
No Preemption
Circular Wait
Prevention: Avoid the conditions mentioned above.
8. Memory Management
Paging: Divides memory into fixed-size pages.
Segmentation: Divides memory into variable-size segments.
Virtual Memory: Uses disk space as extra memory.
Example (Page table entry)
Logical Address → Page Number + Offset → Physical Frame
9. File System Concepts
Example (Linux commands)
ls # list files
cat file # show file content
10. Input/Output Management
11. Security and Protection
Authentication: Verifying users (password, fingerprint).
Authorization: Deciding what resources a user can access.
Encryption: Protecting data by encoding it.
Example (Linux file permission)
chmod 755 file.txt
12. System Calls
Interface between programs and OS.
Categories
Process control (fork, exec)
File management (open, read, write)
Device management (ioctl)
Information maintenance (getpid)
Example in C (creating a process)
#include <unistd.h>
int main() {
fork();
return 0;
}
13. Virtualization
Running multiple OS on one machine using hypervisors.
Type 1 Hypervisor: Runs directly on the hardware (e.g., VMware ESXi).
Type 2 Hypervisor: Runs on the host OS (VirtualBox).
14. Real-Time Systems
Used in robotics, medical equipment, and aircraft systems.
Conclusion
Operating systems are the foundation of computer systems. They manage hardware, processes, memory, files, and security while making computers user-friendly. This cheatsheet covered essential concepts like processes, memory, scheduling, file systems, deadlock, and system calls. Having a clear understanding of these basics is necessary for interviews, exams, and real-world system design.