codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Subjects
🖥️

Operating Systems

25 chapters

1Intro to OS & Kernel Architecture2Process Concept & Lifecycle3System Calls & Interrupts4Process Management & PCB5Inter-Process Communication (IPC)6CPU Scheduling (FCFS, SJF, RR)7Threads (User vs Kernel Level)8Process Synchronization9Critical Section Problem10Producer-Consumer Problem11Dining Philosophers Problem12Deadlock Conditions & Prevention13Banker's Algorithm (Avoidance)14Memory Management & Paging15Memory Allocation (First Fit, Best Fit)16Paging and Segmentation17Translation Lookaside Buffer (TLB)18Virtual Memory & Demand Paging19Page Replacement Algorithms20Thrashing21File Systems & Directory Structure22File Allocation Methods23Disk Scheduling Algorithms24I/O Systems & DMA25OS Protection & Security
SubjectsOperating Systems

System Calls & Interrupts

Updated 2026-05-05
2 min read

System Calls & Interrupts

1. User Mode vs Kernel Mode

Modern CPUs operate in two privilege levels:

  • User Mode: Application code runs here with restricted access. It cannot directly access hardware, memory of other processes, or execute privileged instructions.
  • Kernel Mode: The OS kernel runs here with unrestricted access to all hardware and memory.

When a user application needs to perform a privileged operation (reading a file, sending a network packet, allocating memory), it must request the kernel to do it on its behalf. This request is a System Call.

2. System Calls

A System Call (syscall) is a programmatic way for a user-space process to request a service from the OS kernel.

How it works:

  1. The application places the syscall number and arguments into CPU registers.
  2. The application executes a special trap instruction (e.g., int 0x80 on x86, syscall on x86-64).
  3. The CPU switches from User Mode to Kernel Mode and jumps to a predefined location in the kernel (the System Call Handler).
  4. The kernel validates the arguments, performs the requested operation, and places the result in a register.
  5. The CPU switches back to User Mode and returns control to the application.

Categories of System Calls:

  • Process Control: fork(), exec(), exit(), wait()
  • File Management: open(), read(), write(), close()
  • Device Management: ioctl(), read(), write()
  • Information Maintenance: getpid(), alarm(), sleep()
  • Communication: pipe(), socket(), send(), recv()

3. Interrupts

An Interrupt is a signal to the CPU that requires immediate attention. It temporarily halts the current execution and transfers control to an Interrupt Service Routine (ISR) in the kernel.

Types:

  • Hardware Interrupts: Generated by external hardware devices (keyboard press, disk I/O completion, timer tick, network packet arrival). These are asynchronous.
  • Software Interrupts (Traps): Generated by the CPU itself due to a program's instruction (system calls, division by zero, invalid memory access). These are synchronous.

Interrupt Handling:

  1. The device sends an interrupt signal to the CPU via the interrupt controller.
  2. The CPU finishes the current instruction, saves the current state (registers, PC) onto the stack.
  3. The CPU looks up the ISR address in the Interrupt Vector Table (IVT).
  4. The ISR executes, handles the event, and returns.
  5. The CPU restores the saved state and resumes the interrupted program.


PreviousProcess Concept & LifecycleNextProcess Management & PCB

Recommended Gear

Process Concept & LifecycleProcess Management & PCB