A System Call as a Request to the Operating System

A system call asks the operating system to perform an operation under its protected interface, often through a user-space library wrapper.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace opening a path
  2. Distinguish an ordinary function call
  3. Separate the library call from the requested kernel operation
  4. Check error and progress values at the correct layer

Trace opening a path

A file open operation can require path resolution and a permissions check before giving a process an open handle. The program uses a result or error under that interface. File errors by stage show some possible outcomes.

Distinguish an ordinary function call

An arithmetic library helper may run entirely within the application. A file operation can cross a privilege boundary even when invoked by similar-looking source syntax. See privilege modes.[1]

Separate the library call from the requested kernel operation

A buffered library can read a large block of file data and then return individual bytes to callers from its buffer. Several library calls may be served by one underlying read. A library call and an operating-system entry are distinct observations. See buffering output.

Library call asks for one byte
Buffer empty → possible OS read for a larger block
Subsequent library call → buffer already contains data
Total kernel crossings depend on implementation

Check error and progress values at the correct layer

Operating-system operations can return fewer bytes or an error. The library may retry, buffer, translate or expose those results. Use a controlled short-read fixture to test the application boundary without assuming a particular implementation.

References

  1. Remzi H. Arpaci-Dusseau and Andrea C. Arpaci-Dusseau, Operating Systems: Three Easy Pieces ↩