GateAI
System Calls

GATE CSE 2021 Set 1 · Q14

MSQ1 markMedium

Time

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?

Select all that applyOne or more correct

Pick every correct option

Solution

Step-by-step verified solution

Official answer: A) exit; C) sleep

System Calls

Let us analyze the behavior of each library function in a UNIX/Linux environment: [cite: 1]

  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.

  2. 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.

  3. 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.

  4. 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.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

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

Where do you stand for GATE?

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.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

System Calls in GATE CSE

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 Calls

More from GATE CSE 2021 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2021 Set 1 · Q14 · MSQ

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

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.