Next: Using strace
Up: Ceng 425 System Programming
Previous: Examples&Exercises:
Contents
- Your program can invoke to perform system-related functions.
- These functions fall into two categories, based on how they are implemented.
- A library function is an ordinary function that resides in a library external to your program.
- Most of the library functions we've presented so far are in the standard C library, libc.
- A call to a library function is just like any other function call. The arguments are placed in processor registers or onto the stack, and execution is transferred to the start of the function's code, which typically resides in a loaded shared library.
- A system call is implemented in the Linux kernel.
- When a program makes a system call, the arguments are packaged up and handed to the kernel, which takes over execution of the program until the call completes.
- A system call isn't an ordinary function call, and a special procedure is required to transfer control to the kernel.
- Low-level I/O functions such as open and read are examples of system calls on Linux.
- Note that a library function may invoke one or more other library functions or system calls as part of its implementation.
- Linux currently provides about 200 different system calls. A listing of system calls for your version of the Linux kernel is in
/usr/include/asm/unistd.h. Some of these are for internal use by the system, and others are used only in implementing specialized library functions.
Subsections
Next: Using strace
Up: Ceng 425 System Programming
Previous: Examples&Exercises:
Contents
Cem Ozdogan
2007-05-16