[LCP]Which one is faster - program with unix system calls or direct c code

Matthew Vanecek linux4us at earthlink.net
Tue Jul 17 13:37:03 UTC 2001


On 16 Jul 2001 11:35:49 -0700, Bill Rausch wrote:
> At 12:16 PM -0500 7/15/01, Matthew Vanecek wrote:
> >Unix system calls may be a smidge quicker wrt execution time.  However,
> >they are a pain to use in many cases, and in most cases, you're not
> 
> System calls are generally slower, not faster. To perform a system 
> call, a context switch has to take place for the kernel to do it's 
> thing.  The standard library routines use buffering specifically to 
> avoid making so many system calls.
> 

How about if you are doing atomic reads/writes, and using fread/fwrite
you would be writing the same number of bytes?  If I read(fd,buf,100),
or fread(buf,100,1,file), which would be faster?  Either way, I'm
reading into buf, but with read(), I'm bypassing all the buffering logic
of fread().  At least, that's the way it looks to me.
--
Matthew Vanecek
perl -e 'print
$i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'
********************************************************************************
For 93 million miles, there is nothing between the sun and my shadow
except me.
I'm always getting in the way of something...




More information about the linuxCprogramming mailing list