[SOLVED] Difference between Library API and System Call API
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Most of the time, code that invokes a system-call occurs within a library. This is done for two reasons: to conceal differences that ought to make no difference, and to provide "the rest of" the functionality needed to do this-or-that beyond the low level stuff provided directly by the operating system.
A true system-call always involves issuing some kind of (implementation specific) instruction that passes through a one-way gate into the privileged-mode world of the operating system. Macros and other features are provided for doing this, since the actual manner of invoking the gate is CPU-type and even CPU-model specific.
Last edited by sundialsvcs; 12-11-2012 at 09:38 AM.
Well, obviously, procedure names like fork() are historic names. Also consider that they are, most logically speaking, "subroutine calls."
Now, it so happens that the implementation of this function involves one-or-more system calls. But do you need to be concerned with "which ones," or even, from one implementation to another, "how many" or "what they do?" No. And that's why the library exists ... so that you can just call what you need to call, to do what you need to do, and "it just works."
System-calls are actually intended to be very low-level interfaces, to very specific functionality which your program cannot accomplish on its own. They're focused, "raw," "unfriendly," and maybe implementation-specific. They're part of the necessary voodoo that gets things done. The library functions that "wrap" them are the rest of the story ... and often, the part that actually does most of the work.
When you call 'fork' for example, it is actually a wrapper function in libc, that fills some registers and executes a special machine instruction (platform dependent, INT 80H on x86) to actually call the kernel.