By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,346 Members | 2,318 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,346 IT Pros & Developers. It's quick & easy.

system function

P: n/a
bob
Which is faster - a call to a system function or a call to a library
function?

Apr 11 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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

P: n/a
<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

P: n/a
bob
This is what they asked me in an interview. what do you think they
were getting at?

Apr 11 '06 #4

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a
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.