Skip to content

Operating Systems & Linux

DSSSB TGT CS — Section B P2 (Rank ~8). Focus: definitions, scheduling tables, deadlock, memory, Linux commands.


1. OS Functions

  • Process management — create, schedule, terminate processes/threads
  • Memory management — allocate/deallocate RAM
  • File management — create, read, write, permissions
  • Device / I/O management — drivers, buffering
  • Security & protection — users, access control
  • User interface — CLI / GUI / shell
  • Resource sharing, error detection, accounting

OS = interface between user/applications and hardware.


2. Types of OS

TypeIdea
BatchJobs collected, run without interaction
MultiprogrammingMultiple programs in memory; CPU switches on I/O wait → higher utilization
Time-sharing / multitaskingTime slices; interactive users
Real-time (RTOS)Deadlines matter (hard/soft)
DistributedMultiple machines appear as one
Network OSShare resources over network
Mobile OSAndroid, iOS
  • Trap: Multiprogramming ≠ multiprocessing. Multiprocessing = multiple CPUs/cores.

3. Process States

Typical states:

New → Ready → Running → Terminated

Also: Waiting/Blocked (I/O), sometimes Suspended.

TransitionCause
Ready → RunningScheduler dispatch
Running → ReadyTime slice / preemption
Running → WaitingI/O or event wait
Waiting → ReadyI/O complete

4. PCB (Process Control Block)

Kernel data structure storing process info:

  • Process ID (PID), state, priority
  • Program counter, CPU registers
  • Memory limits / page tables
  • Open files, I/O status
  • Accounting info

Context switch = save/restore PCB-related CPU state.


5. CPU Scheduling

AlgorithmRulePreemptive?Notes
FCFSArrival orderNoConvoy effect
SJFShortest burst nextNon-preemptiveOptimal avg waiting (known bursts)
SRTFShortest remainingYesPreemptive SJF
Round Robin (RR)Time quantum qYesFair; q too small → overhead
PriorityHighest priority firstCan be eitherStarvation → aging

Comparison (exam)

Metric focusPrefer
Fairness / interactiveRR
Min avg waiting (theory)SJF
SimpleFCFS
Importance-basedPriority
  • Trap: SJF needs burst time estimates; RR response depends on quantum.

6. Deadlock

Necessary conditions (Coffman) — all four:

  1. Mutual exclusion
  2. Hold and wait
  3. No preemption
  4. Circular wait

Break any one → deadlock impossible.

ApproachIdea
PreventionNegate a condition
AvoidanceSafe state (e.g. Banker's algorithm)
Detection + recoveryFind cycle; kill/rollback
IgnoreOstrich approach

Banker's idea: Allocate only if system stays in a safe sequence (can finish all with remaining resources).


7. Memory Management

ConceptIdea
ContiguousSingle block (fixed/variable partitions)
PagingFixed-size pages ↔ frames; no external fragmentation
SegmentationLogical segments (code, data, stack); variable size
Virtual memoryProcess address space > physical RAM via disk
ThrashingToo much paging; little useful work
  • Page table maps logical page → physical frame.
  • Trap: Paging → internal fragmentation; segmentation → external fragmentation.

8. Page Replacement

AlgorithmRule
FIFOReplace oldest page
LRUReplace least recently used
OPT / Belady’s optimalReplace page used farthest in future (theoretical)
  • Belady’s anomaly: more frames can increase faults for FIFO.
  • LRU approximates OPT; OPT is benchmark only.

9. File Systems

  • File = named collection of related data
  • Directory structure: single-level, two-level, tree, DAG
  • Operations: create, delete, open, close, read, write
  • Allocation: contiguous, linked, indexed
  • Access: sequential vs random
  • Linux common FS: ext4, also XFS, Btrfs; Windows: NTFS, FAT

10. Linux Basics

LayerRole
KernelCore: hardware, processes, memory, drivers
ShellCommand interpreter (bash, sh, zsh)
Utilities / appsUser programs
  • Linux is multiuser, multitasking, Unix-like.
  • Root (UID 0) = superuser; full privileges — use carefully.

11. Essential Commands

CommandUse
lsList directory
cdChange directory
pwdPrint working directory
mkdirMake directory
rmRemove file/dir (-r recursive)
cpCopy
mvMove / rename
catDisplay file contents
grepSearch pattern in text
chmodChange permissions
chownChange owner
psProcess status
killSend signal to process (e.g. terminate)

Paths

TypeExample
AbsoluteStarts at //home/user/a.txt
RelativeFrom current dir → docs/a.txt, ../b
  • / = root of filesystem tree (not the same concept as root user, but related naming).
  • Home often /home/username; root user’s home /root.

Permissions (chmod idea)

  • rwx for user/group/others; numeric e.g. 755, 644.
  • chmod 755 file — common exam pattern.

Quick Revision Traps

  1. Multiprogramming (many jobs in memory) vs multiprocessing (many CPUs).
  2. Deadlock needs all four Coffman conditions.
  3. Banker's → safe state avoidance, not prevention of all conditions.
  4. Thrashing = excessive paging.
  5. FIFO can show Belady’s anomaly; LRU/OPT do not (classic claim).
  6. Absolute path starts with /.
  7. root user ≠ filesystem root / (related but distinct).
  8. RR quantum too small → context-switch overhead.