Linux Programming Unit 2
Linux Programming Unit 2
Library Functions
One problem with using low-level system calls directly for input and output is that they can be very
inefficient. Why?
o System calls are therefore expensive compared to function calls because Linux has to switch
from running your program code to executing its own kernel code and back again.
o The hardware has limitations that can impose restrictions on the size of data blocks that can
be read or written by the low-level system call at any one time.
To provide a higher level interface to device and disk files, UNIIX provides a number of standard
libraries.
These are collections of functions that you can include in your own programs to handle these
problems.
A good example is the standard I/O library that provides buffered output. You can effectively write
data blocks of varying sizes.
Following Figure illustrates the Linux system, showing where the various file functions exist relative to
the user, the device drivers, the kernel, and the hardware.