System Call Vs Library Function Call
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > System Call Vs Library Function Call




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    System Call Vs Library Function Call  
Prakash Prabhu


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-22-04 11:08 PM

Hi,

What are the differences between a system call and library function
call except for the fact that the former is executed in kernel mode
while the latter in user mode ? ( does this by itself have its own
implications ? )

Thanks,
Prakash





[ Post a follow-up to this message ]



    Re: System Call Vs Library Function Call  
Brian Raiter


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-22-04 11:08 PM

> What are the differences between a system call and library function
> call except for the fact that the former is executed in kernel mode
> while the latter in user mode ? ( does this by itself have its own
> implications ? )

That a little bit like asking "What are the differences between Paris
and Kalamazoo except for the fact that former is in France and the
latter is in the United States?" They are both cities, yes, but
otherwise they have nothing in common. And yes, the differences
between France and the United States are a major reason for the
differences between Paris and Kalamazoo, but it really depends on what
you're interested in. You could spend all day listing differences.

In short: A system call is a call to one of a small set of functions
supplied by the kernel, as part of the kernel, and typically performs
some action that can (or should) only be done while in kernel mode. A
library function call is a function call that at some point somebody
(maybe you) stashed in a library.

b





[ Post a follow-up to this message ]



    Re: System Call Vs Library Function Call  
Nick Landsberg


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-22-04 11:08 PM

Prakash Prabhu wrote:
> Hi,
>
> What are the differences between a system call and library function
> call except for the fact that the former is executed in kernel mode
> while the latter in user mode ? ( does this by itself have its own
> implications ? )
>
> Thanks,
> Prakash

I presume you mean library calls which are analogous to
system calls.  For example, the system calls
open(), close(), read(), write(), lseek(), etc.
can be used directly, but there are stdio library
calls (fopen(), fclose(), etc.) which seem to
do the same thing.

When using the low-level system calls, you often
have to do a lot of work to use them most efficiently.
For example, the fread() and fwrite() functions (library
calls), buffer the I/O at what is probably the optimal
size for the given O/S.  Fwrite() will only issue
a "write()" call when it's buffer is full,
thus minimizing unnecessary write() calls.
(There are ways of overriding this, e.g. fflush()).

These particular library calls are saving you the
effort of having to re-invent buffered I/O all by
yourself every time you write a program which needs
I/O.  Use of the library calls is thus, in the long
run, more productive and also allows your code
to be more portable to other platforms because the
compilers on those other platforms will have the
same standard libraries and will hide the O/S
specific differences from you, for the most
part.




--
"It is impossible to make anything foolproof
because fools are so ingenious"
- A. Bloch





[ Post a follow-up to this message ]



    Re: System Call Vs Library Function Call  
Karthick S.


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-23-04 10:55 PM

prakash.prabhu@gmail.com (Prakash Prabhu) wrote in message news:<85a4cc05.0408200944.7de3840
5@posting.google.com>...
> Hi,
>
> What are the differences between a system call and library function
> call except for the fact that the former is executed in kernel mode
> while the latter in user mode ? ( does this by itself have its own
> implications ? )
>
> Thanks,
> Prakash

Hi,

A library function is a wrapper for a system call (or rarely
other library functions). For example, fopen internally calls open but
does some other calls also (I presume stat) to get more info to be
stored in the structure.
Generally people start by working at the user level (using
library functions) and later in their learning curve move on to system
calls. This helps them understand the applications of the library
functions and the system calls well.

Rgds,
Karthick S.





[ Post a follow-up to this message ]



    Re: System Call Vs Library Function Call  
Dragan Cvetkovic


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-23-04 10:55 PM

karthicks@spymac.com (Karthick S.) writes:

> prakash.prabhu@gmail.com (Prakash Prabhu) wrote in message news:<85a4cc05.
0408200944.7de38405@posting.google.com>... 

[snip]
[vbcol=seagreen]
>      A library function is a wrapper for a system call (or rarely
> other library functions).

What's the system call version of sin(3) or rand(3)?

>      Generally people start by working at the user level (using
> library functions) and later in their learning curve move on to system
> calls.


The above are counterexamples for your theory. Not everything need to be
done by UNIX kernel and therefore not everything is based on system
calls. Most of the <math.h> functions are certainly not system calls, most
of <ctype.h> functions are not there either etc etc.

Dragan

--
Dragan Cvetkovic,

To be or not to be is true. G. Boole      No it isn't.  L. E. J. Brouwer

!!! Sender/From address is bogus. Use reply-to one !!!





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:32 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register