What is a system call, and how does it differ from a standard library function call?
Last updated
A system call requests a service directly from the OS kernel and requires a switch to kernel mode, whereas a standard library function is ordinary user-mode code that may or may not eventually make a system call.
System call:
Crosses the user/kernel boundary via a trap; needed for privileged operations (I/O, memory allocation, process creation).
Relatively expensive due to the mode switch and argument validation.
Examples: read(), write(), fork(), open().
Library function:
Runs entirely in user space; often just computation (e.g. strlen(), sqrt()) with no kernel involvement.Some library functions are thin wrappers that eventually invoke a system call.
The overlap:
printf() is a library function that buffers in user space and then calls the write() system call to actually output.So library calls can add convenience/buffering on top of the raw kernel interface.
- https://www.reddit.com/r/cscareeradvice/new/
- https://www.reddit.com/r/macbook/comments/1jg7fl6/24gb_ram_enough_for_software_engineering/
- https://www.reddit.com/r/infosys/comments/1t71add/anyone_received_round_2_mails/
- https://www.reddit.com/r/cscareeradvice/best/
- https://www.reddit.com/r/LeetcodeChallenge/
- https://www.reddit.com/r/infosys/comments/1t71i55/infosys_specialist_programmer_april_26_1st_round/
- https://www.reddit.com/r/programming/comments/1hqo19u/static_search_trees_40x_faster_than_binary_search/