Which 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?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2021 Set 1 · Q14
Time
Select all that applyOne or more correct
Solution
Official answer: A) exit; C) sleep
System CallsLet us analyze the behavior of each library function in a UNIX/Linux environment: [cite: 1]
exit: After running registered exit handlers (atexit) and flushing open stdio streams, the exit() library function must terminate the calling process, which strictly requires invoking a kernel termination system call such as exit_group() or _exit(). Hence, it always invokes a system call.
malloc: The standard memory allocator manages a heap pool (arena) in user space. If a memory request can be satisfied from existing free chunks in the arena, no system call is made. A system call (brk() or mmap()) is only invoked when the user-space heap needs to be expanded.
sleep: To suspend the calling thread/process for a requested duration, user space cannot manage hardware timers independently; it must request the kernel to pause execution via system calls such as nanosleep() or clock_nanosleep(). Hence, it always invokes a system call.
strlen: Calculates the length of a string entirely in user-space memory by iterating through characters until the null terminator \0 is found. It never invokes a system call.
Therefore, the correct options are A and C [cite: 1].
Try the question first, then check your work.
Examiner trap
Identify which functions can be fulfilled entirely in user-space memory vs. those that must interact with the kernel for process termination or hardware timer management.
This System Calls previous year question is Q14 of the GATE CSE 2021 Set 1 paper. Find more GATE CSE PYQs on System Calls in Operating Systems, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 4 related System Calls PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
System Calls has 4 GATE CSE PYQs across 4 papers from 2011 to 2024. 2 of them are 1-mark MSQs like this one, and it is the only one in GATE CSE 2021 Set 1.
How GATE tests System CallsIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.