System Call

A system call is a mechanism used by an application to request a service from the operating system’s kernel.

Purpose: It allows user-level processes to request services of the kernel, which has privileged access to hardware and system resources.

Resources

Examples of system calls

  • Reading or writing files,
  • creating processes,
  • communicating over networks

Are all system calls done through traps?

Yes, all system calls are triggered through traps (or equivalent mechanisms like software interrupts). Here’s why.

Major System Calls

  • read()
  • malloc is (sometimes) a system call when you actually need more memory at runtime
    • malloc resides in user space, runtime C library
    • the (sometimes) is because the underlying runtime C library can be smarter about how malloc is done to reduce the number system calls that the program does to request for more memory