Results 1 to 5 of 5
Compared with library functions, invoking system calls directly gives people more freedom for implementing some specific requirements
But I want to know that what's the advantages and disadvantages of using ...
- 08-01-2007 #1Just Joined!
- Join Date
- Jul 2007
- Posts
- 6
what's the difference between system call and library functions
Compared with library functions, invoking system calls directly gives people more freedom for implementing some specific requirements
But I want to know that what's the advantages and disadvantages of using system calls instead of library functions provided that both can finish the task well
- 08-01-2007 #2
I assume that you're referring to, for instance, using the chmod(2) function, rather than the syscall(2) function?
The main advantage to using the library function is the abstraction. Using the system call, you're assuming that the same symbolic macro exists on all systems that use your code, that the call takes the same arguments, etc. Using the library function means that you don't need to worry about these details, and that makes your code more portable.DISTRO=Arch
Registered Linux User #388732
- 08-02-2007 #3Just Joined!
- Join Date
- Jul 2007
- Posts
- 6
reply
Thanks

I am reading <<Advanced Programming in the UNIX Environment>> lately
That's why I proposed the question above
In my opinion,using lots of system calls can assist in understanding essentials
of operating system in despite of "abstraction" you point to, which may be
the concept of software engineering
- 08-02-2007 #4
It depends a great deal on what your intention is. For instance, glibc undoubtedly implements its chmod library function in terms of the chmod syscall.
If you are doing very low-level work and need the precision that a system call grants, or say that you're working on a system where a syscall does not have a library call, then it is acceptable to use syscalls directly. Driver developers do not use the library functions, I imagine.
However, when writing an application, abstraction is usually a good thing. Other people have done the low-level work: understanding it is important, but there is no point in redoing it yourself.DISTRO=Arch
Registered Linux User #388732
- 08-02-2007 #5Just Joined!
- Join Date
- Jul 2007
- Posts
- 6
fantastic comments! I feel the same way
Previously I am a high-level developer(j2ee web application work)
I know the advantages of abstraction,encapsulation and resusability from a high-level programmer's perspective
Right now I take a great interest in digging into linux programming
Actually I am a newbie in linux programming(c,c++,perl,python,except java),that's why I turn to you guys for advice


Reply With Quote
