LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
LinkBack Search this Thread
Old 12-10-2012, 01:37 PM   #1
ram619
LQ Newbie
 
Registered: Jun 2012
Location: India
Posts: 10

Rep: Reputation: Disabled
Difference between Library API and System Call API


Can anyone please explain difference between Library API , System Call API and System Call.

I tried reading from various sources but still, haven't got valid explanation.

What I understood is

System Call - lowest level thing which talks to OS

System Call API - We call "system call API" and they invoke system call

Library API - We call some library function then that library function calls System call.

But if this is so then what is the difference between a System Call API and Library API ?????

Thanks a lot!!!!!!!!

Last edited by ram619; 12-11-2012 at 05:35 AM. Reason: Elaborated the question
 
Old 12-11-2012, 07:14 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,460

Rep: Reputation: 445Reputation: 445Reputation: 445Reputation: 445Reputation: 445
For example, libc is a library. So is libm and libpthread. They all export functions you can call, but those calls aren't system calls. System call is when you call the kernel.
 
Old 12-11-2012, 08:36 AM   #3
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,060

Rep: Reputation: 972Reputation: 972Reputation: 972Reputation: 972Reputation: 972Reputation: 972Reputation: 972Reputation: 972
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 08:38 AM.
 
Old 12-14-2012, 12:17 PM   #4
ram619
LQ Newbie
 
Registered: Jun 2012
Location: India
Posts: 10

Original Poster
Rep: Reputation: Disabled
Smile System Call Name

Quote:
Originally Posted by NevemTeve View Post
For example, libc is a library. So is libm and libpthread. They all export functions you can call, but those calls aren't system calls. System call is when you call the kernel.
I looked into http://asm.sourceforge.net/syscall.html#p2 . On this Page every system call is starting with sys_ . But I have studied system calls without sys_ 'prefix' like, fork(), read(), write() etc.

Can you please explain, why such conflict.

Thanks again !!!!!!!!!!!!
 
Old 12-14-2012, 03:53 PM   #5
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,060

Rep: Reputation: 972Reputation: 972Reputation: 972Reputation: 972Reputation: 972Reputation: 972Reputation: 972Reputation: 972
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.
 
1 members found this post helpful.
Old 12-15-2012, 02:18 AM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,460

Rep: Reputation: 445Reputation: 445Reputation: 445Reputation: 445Reputation: 445
> Can you please explain, why such conflict.

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.
 
1 members found this post helpful.
Old 12-17-2012, 04:51 AM   #7
ram619
LQ Newbie
 
Registered: Jun 2012
Location: India
Posts: 10

Original Poster
Rep: Reputation: Disabled
Thanks !!!!!!!!!!!
 
Old 12-26-2012, 06:07 AM   #8
nrusimha vinay
LQ Newbie
 
Registered: Dec 2012
Location: hyderabad
Posts: 1

Rep: Reputation: Disabled
what is differnce between fork and clone
 
Old 12-27-2012, 02:40 AM   #9
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,460

Rep: Reputation: 445Reputation: 445Reputation: 445Reputation: 445Reputation: 445
Read the manual: clone is much more flexible (it can start new threads as well as new processes, for example), but linux-specific.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Secure programming with the OpenSSL API, Part 1: Overview of the API LXer Syndicated Linux News 0 06-29-2012 12:30 PM
difference between system call and api vinaytp Linux - Newbie 3 05-06-2009 09:47 AM
How to check for return value from a API call in C language kushalkoolwal Programming 5 08-19-2008 04:55 PM
SDL_sound library API example/document in Linux FC6 sanjay417 Linux - Games 0 02-13-2007 05:29 AM
Shell Script call API treotan Programming 1 08-22-2005 10:59 PM


All times are GMT -5. The time now is 02:49 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration