System call vs Function call

Ankur picture Ankur · Apr 19, 2010 · Viewed 33.4k times · Source

What is the difference between a system call and a function call? Is fopen() a system call or a function call?

Answer

Thomas picture Thomas · Apr 19, 2010

A system call is a call into kernel code, typically performed by executing an interrupt. The interrupt causes the kernel to take over and perform the requested action, then hands control back to the application. This mode switching is the reason that system calls are slower to execute than an equivalent application-level function.

fopen is a function from the C library that, internally, performs one or more system calls. Generally, as a C programmer, you rarely need to use system calls because the C library wraps them for you.