Question:medium

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?

Show Hint

Process control and scheduling functions always require kernel involvement.
Updated On: Jan 30, 2026
  • \texttt{exit}
  • \texttt{malloc}
  • \texttt{sleep}
  • \texttt{strlen}
Show Solution

The Correct Option is A, C

Solution and Explanation

Step 1: Identify operations that require kernel services.
A system call is invoked when a function must interact with the operating system kernel, such as for process control, scheduling, or resource management.


Step 2: Examine each function.

exit:
Terminating a process requires notifying the kernel and releasing process resources. Hence, exit always invokes a system call.

sleep:
Suspending a process and rescheduling it after a time interval requires kernel involvement. Therefore, sleep always invokes a system call.

malloc:
Memory allocation is typically handled in user space using the heap. A system call is made only when additional memory is required from the OS, so it does not always invoke a system call.

strlen:
This function simply computes the length of a string in user space and never requires kernel interaction.


Final Conclusion:
The functions that always invoke system calls are:

exit and sleep

Was this answer helpful?
0