---
title: "OS abstraction, extended machine, system call"
subject: "Operating System"
chapter: 1
key: "semester_6/operating_system:os-abstraction-system-call"
source: https://www.bctengineer.com/q/semester_6/operating_system/os-abstraction-system-call
site: BCT Engineering
---

# OS abstraction, extended machine, system call

Operating System · Chapter 1: Introduction to Operating System

- Asked in: 2069 Bhadra, 5+5 marks
- Video: [Ch: 1.2 Aspect of Operating system - Operating system as extended machine !! By Achyut Bhattarai ...](https://www.youtube.com/watch?v=6r0BdnRpLXI) — Abinasi Achyut Bhattarai
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/operating_system/os-abstraction-system-call
- Whole chapter: https://www.bctengineer.com/md/semester_6/operating_system/chapter-1

## Question

How does an operating system create abstraction? Explain with reference to OS as an extended machine. Define system call and explain its working mechanism with a suitable example.

## Short answer

The OS abstracts hardware by providing files, processes, and virtual memory, hiding controller details. A system call allows user programs to request privileged services via a library function. For write(), the wrapper places the call number and executes TRAP; the kernel handler performs the I/O and returns.

## Answer

#### How an OS creates abstraction (OS as an extended machine)

Real hardware is complex: a disk is a controller with registers, sectors, cylinders, commands and interrupts. A programmer cannot be expected to handle this. The OS therefore builds a **layer of abstraction** above the hardware: it hides the details and exports simple, uniform and powerful objects.

- **Disk and storage** become **files and directories**; a programmer opens, reads and writes a named file without caring about blocks.
- **CPU** becomes **processes/threads**; each process appears to own a CPU.
- **Physical memory** becomes an **address space (virtual memory)**.
- **Network card** becomes a **socket**; **terminals/keyboard** become simple character streams.

In this role the OS acts as an **extended machine (virtual machine)**: it turns the ugly raw machine into a more convenient and better-looking machine, as seen from the application's point of view. Since the programmer sees only the abstractions, the program is also more portable among different hardware.

```text
 Application  --> sees: files, processes, memory
 ----------------------------------------------
 OS (abstraction layer)
 ----------------------------------------------
 Hardware     --> disk controllers, registers, IRQs
```

#### System call and its working mechanism

A **system call** is the interface between a user program and the OS: it is a controlled entry point by which a user program asks the kernel to do a privileged operation (file I/O, process creation, memory allocation). Examples: `open`, `read`, `write`, `fork`, `exec`, `exit`.

**Working** (example: `write(fd, buf, n)` in C):

1. The program calls the library wrapper `write`, passing parameters on the stack or in registers.
2. The wrapper puts the system-call number in a register and executes a **TRAP** (software interrupt) instruction.
3. The CPU switches from **user mode to kernel mode** and jumps to the kernel's system-call handler.
4. The handler uses the call number to index the **system-call table**, validates the parameters, and runs the kernel routine (for `write`, it passes the data to the file system and device driver).
5. After completion the kernel stores the return value, switches back to user mode and returns control to the instruction after the TRAP.

The mode switch protects the OS because user programs cannot execute privileged instructions directly; they must go through well-defined entries.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Which pairing of hardware to OS abstraction is correct?
   A. Disk to sockets, CPU to files, memory to processes
   B. Disk to processes, CPU to sockets, memory to files
   C. Disk to files, CPU to processes, physical memory to address space
   D. Network card to files, disk to address space, CPU to directories
   Answer: C. Disks become files, CPU becomes processes/threads, memory becomes virtual address space. (Key point: Abstraction mapping)

2. Why does abstraction make programs more portable?
   A. Programs are rewritten for each device
   B. The OS exposes controller registers
   C. Programs run without an OS
   D. The programmer sees only abstractions and not hardware-specific details
   Answer: D. Programs depend on uniform abstractions, not on specific hardware. (Key point: Portability)

3. What does the system-call handler do with the call number?
   A. Indexes the system-call table, validates parameters, and runs the kernel routine
   B. Executes a TRAP again
   C. Hands control to the shell
   D. Deletes the library wrapper
   Answer: A. After the TRAP, the handler dispatches via the table. (Key point: System call mechanism)

4. Why is the mode switch to kernel mode needed?
   A. To make the program run faster
   B. User programs cannot execute privileged instructions directly, so they must use well-defined entries
   C. To avoid using the system-call table
   D. To let user code access hardware freely
   Answer: B. It protects the OS. (Key point: Why mode switch)

## Related in Operating System

- [Extended machine, kernel, system call](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Aextended-machine-kernel-syscall) — Operating System, chapter 1
- [OS as resource manager and extended machine](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Aos-resource-manager-extended-machine) — Operating System, chapter 1
- [System call; monolithic and VM architecture](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Asystem-call-architecture) — Operating System, chapter 1
- [OS as virtual machine; functions](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Aos-virtual-machine-functions) — Operating System, chapter 1
- [System call; read() execution](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Asystem-call-read-example) — Operating System, chapter 1

## Related in other subjects

- [Call by value versus call by reference](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Acall-by-value-vs-reference) — Computer Programming, chapter 6, asked 8×
- [Encapsulation and abstraction working together](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Aencapsulation-abstraction-together) — Object Oriented Analysis and Design, chapter 1
- [DNS and its working mechanism](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Adns-working) — Distributed System, chapter 2, asked 3×
- [Types of doors by working mechanism](https://www.bctengineer.com/question.md?key=semester_6%2Fbuilding_technology%3Adoor-types-working) — Building Technology, chapter 6, asked 2×
