LearnFrenzy
Sign in Take a free test

Operating Systems · Topic 1 of 11

OS Basics and System Calls: questions with answers

What a kernel does, user and kernel mode, system calls and traps, interrupts and DMA, booting, kernel designs, virtual machines and containers.

Questions
45
Timed sets
3
Answers run or computed
8
Your accuracy
–

What this topic covers

12 subtopics
  • System calls12
  • Interrupts8
  • Dual mode6
  • Kernel design4
  • Types of OS4
  • Virtualisation3
  • Booting2
  • Kernel2
  • I/O1
  • Processes1
  • Protection1
  • Signals1
  • Beginner 15
  • Intermediate 15
  • Advanced 15

About this topic

An operating system sits between programs and hardware: it shares the CPU, memory and devices among processes and protects them from each other. These questions cover the foundations interviewers start with – the kernel, user and kernel mode, how a system call crosses into the kernel, interrupts and DMA – up to the GATE and systems-interview details such as privileged instructions, vDSO and virtualisation. The C programs were compiled and run, and every calculation was computed by a program.

Free preview

Sample questions

Try each one first, then open the answer for the explanation and why the other options are wrong.

Question 1 System calls Beginner Practice

On Linux, which of these is a system call rather than a C library function?

strlen()
qsort()
printf()
fork()
Show answer and explanation
Correct answer D

Explanation

fork() asks the kernel to create a process. printf() is a library function that formats text in user space and only calls write() when its buffer is flushed; strlen() and qsort() never enter the kernel.

Why the other options are wrong

  • APure user-space computation.
  • BPure user-space computation.
  • CIt formats in user space and eventually calls write().
Question 2 System calls Intermediate Practice

A C program calls read(fd, buf, n). In which order do these steps happen?

libc wrapper puts the call number and arguments in registerstrap instruction switches to kernel modekernel looks up the handler in the system-call tablehandler runs, result returned to user mode
kernel looks up the handler in the system-call tablelibc wrapper puts the call number and arguments in registerstrap instruction switches to kernel modehandler runs, result returned to user mode
trap instruction switches to kernel modehandler runs, result returned to user modelibc wrapper puts the call number and arguments in registerskernel looks up the handler in the system-call table
libc wrapper puts the call number and arguments in registershandler runs, result returned to user modetrap instruction switches to kernel modekernel looks up the handler in the system-call table
Show answer and explanation
Correct answer A

Explanation

On x86-64 Linux the wrapper sets rax to the call number and executes syscall; the kernel indexes its table with rax, runs the handler, and sysret returns with the result in rax.

Why the other options are wrong

  • BThe kernel cannot dispatch before the trap.
  • CArguments are prepared before the trap.
  • DThe handler runs only after the trap and dispatch.
Question 3 System calls Advanced Practice

On Linux, clock_gettime() is called millions of times per second by some programs, yet usually never enters the kernel. Why?

The CPU caches the result of every system call
The compiler replaces the call with a constant
The kernel maps a vDSO (virtual dynamic shared object) into each process; it reads time data the kernel keeps in shared memory, so no trap is needed
clock_gettime is not a system call on any OS
Show answer and explanation
Correct answer C

Explanation

The vDSO turns a few read-only calls into ordinary function calls. A trap costs far more than reading a shared page.

Why the other options are wrong

  • ANo such cache.
  • BTime is not constant.
  • DIt is a system call, served by the vDSO in the fast case.
42 more questions in the timed setsSame format as the samples, with a timer, a question palette and a full review at the end.
Start practising

Operating Systems

All 11 topics

Topics, levels and full mocks
  1. 01 OS Basics and System Calls45 questions · 3 levels
  2. 02 Processes, Threads and fork()45 questions · 3 levels
  3. 03 CPU Scheduling Algorithms45 questions · 3 levels
  4. 04 Process Synchronization and Semaphores45 questions · 3 levels
  5. 05 Deadlocks and Banker's Algorithm45 questions · 3 levels
  6. 06 Memory Management and Paging45 questions · 3 levels
  7. 07 Virtual Memory and Page Replacement45 questions · 3 levels
  8. 08 File Systems and Disk Scheduling45 questions · 3 levels
  9. 09 Threads and Concurrency in Code45 questions · 3 levels
  10. 10 Linux Commands and Shell45 questions · 3 levels
  11. 11 GATE-Style OS Questions (MSQ & NAT)45 questions · 3 levels

Search LearnFrenzy

Esc

Quick links