Project ForgeSign up free
Operating Systems
Process Scheduling
GATE 2021
Hard

Which one or more of the following standard C library functions will ALWAYS invoke a system call when executed from a single-threaded process in a UNIX/Linux operating system?

(A) exit (B) malloc (C) sleep (D) strlen

  • exit
  • Bmalloc
  • sleep
  • Dstrlen

Explanation

strlen is pure user-space computation — never a syscall. malloc is often satisfied from an already-obtained heap region without needing to ask the kernel for more memory (brk/mmap) — not guaranteed every call. sleep() always requires the kernel's scheduler/timer to suspend the calling process for a duration — there is no way to implement this purely in user space, so it's guaranteed. exit() performs user-space cleanup (flushing buffers, atexit handlers) but ALWAYS eventually calls the underlying _exit() system call to actually terminate the process — a process can never terminate itself without kernel involvement, so this is also guaranteed.

Source: GATE CS 2021 (Session 1 / Set-1) (2021)

This question is part of a 15-day revision cycle — sign in and Project Forge will bring it back the day before you'd forget it.

Start revising free