472,096 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,096 software developers and data experts.

system function

bob
Which is faster - a call to a system function or a call to a library
function?

Apr 11 '06 #1
8 3062
bo*@coolgroups.com wrote:
Which is faster - a call to a system function or a call to a library
function?


Which functions? Which library? Which system? Your question is too
vague to be meaningful.

Cheers! --M

Apr 11 '06 #2
<bo*@coolgroups.com> wrote:
Which is faster - a call to a system function or a call to a library
function?


If you really have to know, do a hundred million or so of each and measure
the time.
Apr 11 '06 #3
bob
This is what they asked me in an interview. what do you think they
were getting at?

Apr 11 '06 #4
bo*@coolgroups.com wrote:
This is what they asked me in an interview. what do you think they
were getting at?


Perhaps they were trying to get you to tell them the question was too
vague to be meaningful. If you picked either choice they offered you,
they'd know you didn't know what you were talking about.

Cheers! --M

Apr 11 '06 #5
bo*@coolgroups.com wrote:
Which is faster - a call to a system function or a call to a library
function?
and
This is what they asked me in an interview. what do you think they
were getting at?


Probably the expected answer had something to do with this:

If the program environment is a "normal" operating system, a library
function call is a straightforward call executed in the context of the
calling process. As a minimum, the internal overhead consists of
transferring the function parameters and saving the return address.

A system function call, on the other hand, may use some kind of trap
instruction, it may produce a switch to kernel/supervisor mode, may
require saving/restoring process information, etc., a much larger
overhead.

This refers to the time required to do the call/invocation only, with
no reference to the time required to execute the function.

That's why in many systems it is faster to read a file using, for
example, a 16K buffer, than reading it one byte at a time.
It reduces the number of read system calls and their overhead.

Apr 11 '06 #6
Roberto Waltman wrote:
bo*@coolgroups.com wrote:
Which is faster - a call to a system function or a call to a library
function?


and
This is what they asked me in an interview. what do you think they
were getting at?


Probably the expected answer had something to do with this:

If the program environment is a "normal" operating system, a library
function call is a straightforward call executed in the context of the
calling process. As a minimum, the internal overhead consists of
transferring the function parameters and saving the return address.

A system function call, on the other hand, may use some kind of trap
instruction, it may produce a switch to kernel/supervisor mode, may
require saving/restoring process information, etc., a much larger
overhead.

This refers to the time required to do the call/invocation only, with
no reference to the time required to execute the function.

That's why in many systems it is faster to read a file using, for
example, a 16K buffer, than reading it one byte at a time.
It reduces the number of read system calls and their overhead.


But still, the question is too vague as posed. The "library function"
in question may well call one or more of these trapped "system
functions". We really don't have enough information to answer the
question properly.

Cheers! --M

Apr 11 '06 #7
"mlimber" <ml*****@gmail.com> wrote:
But still, the question is too vague as posed. The "library function"
in question may well call one or more of these trapped "system
functions". We really don't have enough information to answer the
question properly.


Agreed - That's why I wrote "*Probably* the *expected* answer had
something to do with ..."

(Any woman would immediately sense the lack of commitment... ;) )

Apr 11 '06 #8
bo*@coolgroups.com wrote:
This is what they asked me in an interview. what do you think they
were getting at?


If they actually expected any answer other than "You'd have to measure to be
sure. Anything else would be complete speculation that could easily be
wrong." then you're better off not working for them anyway.

--
Reginald Blue
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my
telephone."
- Bjarne Stroustrup (originator of C++) [quoted at the 2003
International Conference on Intelligent User Interfaces]
Apr 11 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

36 posts views Thread by AussieRules | last post: by
22 posts views Thread by schneider | last post: by
7 posts views Thread by =?Utf-8?B?SmVycnkgQw==?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.