Topic 2.3 · Computer Architecture & Kernel Design

System Calls & System Call Interface (SCI)

3 min read1 question to test yourself

1Definition

A System Call is a formal programmatic mechanism through which an application program executing in user mode requests privileged services—such as hardware access, process creation, file I/O, or inter-process communication—from the operating system kernel.

2Simple Explanation

User programs operate in a restricted sandbox. When a program wants to execute an action outside its sandbox (e.g., creating a file on disk or reading network packets), it cannot execute hardware instructions directly. Instead, it calls a standard library API (like glibc in C), which issues a System Call. The System Call triggers a CPU software interrupt, passing control to the Kernel's System Call Interface (SCI). The Kernel validates the request, performs the operation in Kernel Mode, and returns control back to the user program.

3Real-Life Example / Analogy

Ordering Food at a Drive-Thru Window: You (the user app) drive up to the intercom. You cannot walk inside the kitchen and operate the commercial deep fryers (hardware). You speak your order into the speaker (System Call API). The employee inside the restaurant (System Call Interface) receives the request, validates your order, has the kitchen staff prepare the food in the private kitchen (Kernel Space), and passes the bagged food through the window back to your car.

4Diagram / Visual Representation

System call / trap

User application
mkdir('my_dir')

C standard library
Wrapper function

System Call Interface
Kernel system-call table

File system / device layer
Create directory on storage

5Working / How It Works

  1. User Invocation: User program executes high-level function wrapper (e.g., open(), read(), mkdir()).
  2. System Call Number Setup: The library puts the corresponding system call index number into a designated CPU register (e.g., EAX on x86).
  3. Trap Execution: A software interrupt (sysenter or syscall instruction) is triggered.
  4. Kernel Table Lookup: The CPU context switches to Kernel Mode. The SCI uses the index number to locate the target system call handler routine inside the kernel jump table.
  5. Execution & Return: Kernel executes procedure, stores return code in register, and executes return-from-interrupt instruction (sysexit) to restore User Mode.

6Types / Components / Characteristics

  • Categories of System Calls:

    1. Process Control: create process, terminate process, end, abort, load, execute, wait event, allocate memory.
    2. File Management: create file, delete file, open, close, read, write, reposition, chmod.
    3. Device Management: request device, release device, read, write, ioctl.
    4. Information Maintenance: get time/date, set system data, getpid, alarm.
    5. Communication: create pipe, send/receive messages, shmget, mmap.
  • Windows vs. Unix API System Call Mapping:

System Call Category Windows Win32 API System Call Unix / Linux POSIX System Call
Process Control CreateProcess(), ExitProcess(), WaitForSingleObject() fork(), exec(), exit(), wait()
File Management CreateFile(), ReadFile(), WriteFile(), CloseHandle() open(), read(), write(), close(), chmod()
Device Management SetConsoleMode(), ReadConsole(), WriteConsole() ioctl(), read(), write()
Info Maintenance GetCurrentProcessID(), SetTimer(), Sleep() getpid(), alarm(), sleep()
Communication CreatePipe(), CreateFileMapping(), MapViewOfFile() pipe(), shmget(), mmap()

7Solved Examples / Problems

Problem: Explain how the Unix fork() system call operates during process creation. Solution:

  1. When a process calls fork(), the kernel creates an exact duplicate child process sharing the parent's file descriptors.
  2. The fork() system call returns twice:
    • It returns the Child's Process ID (PID > 0) to the Parent Process.
    • It returns 0 to the Child Process.
  3. If process creation fails, it returns -1 to the parent.

8Advantages, Disadvantages & Applications

  • Advantages: Protects hardware integrity, enforces security policies, delivers cross-hardware API uniformity.
  • Disadvantages: Switching between user mode and kernel mode introduces CPU pipeline stall overhead.

9Important Points to Remember

  • System calls are implemented natively in low-level C and Assembly.
  • System calls represent the only valid mechanism for an unprivileged process to enter Kernel Mode.

10Test Your Understanding

  1. MCQ: Which of the following represents the equivalent Unix POSIX system call for Windows CreateProcess()?
    • A) open()
    • B) fork()
    • C) ioctl()
    • D) shmget()
    Show answer
    B.
  2. Conceptual Question: Describe the sequence of hardware and software events during a system call context switch.
  3. Application Question: Write a short C pseudocode block demonstrating how a program checks if it is executing as a parent or child process after calling fork().

Finished this topic?

0 of 27 topics read in Operating Systems

Handwritten notes for the exam

Unit-wise SPPU notes and PYQs for this subject.

Helpful? Share it with your class

Free for everyone, no login needed.

Share topic