System call vs POSIX call
Hi All, I'm trying to get the difference between system call and POSIX call. System calls are user mode API's (open(), close(), ioctl(),...) gets the kernel service via software interrupt. What about POSIX calls and how it differs with the system call.? Can anyone clarify me on this.
On Thu, Aug 16, 2018 at 09:51:05PM +0530, Subhashini Rao Beerisetty wrote:
Hi All,
I'm trying to get the difference between system call and POSIX call. System calls are user mode API's (open(), close(), ioctl(),...) gets the kernel service via software interrupt. What about POSIX calls and how it differs with the system call.? Can anyone clarify me on this.
glibc is the library that connects user-space libs/apps to the system call interface (unistd.h basically) so if you do an open() in user-space you are calling glibc and that can call sys_open() but there are POSIX calls that will not necessarily do a system call if they can handle the request with available resources or with cached data. So there is no 1:1 mapping at runtime from POSIX call to system call - and there can be multiple POSIX calls that map to a single system call (e.g. printf -> write) Note that you can do system calls directly with system() but that is generaly not how you do it - you to through the glibc calls which do some checks before invoking the actual system call. Does that clarify it ? thx! hofrat
On Thu, 16 Aug 2018 16:29:29 -0000, Nicholas Mc Guire said:
Note that you can do system calls directly with system() but that is generaly not how you do it - you to through the glibc calls which do some checks before invoking the actual system call.
system() does a fork/exec of a process. syscall() issues an arbitrary system call, but all marshalling of parameters and return codes becomes your problem
On Thu, 2018-08-16 at 15:44 -0400, valdis.kletnieks@vt.edu wrote:
On Thu, 16 Aug 2018 16:29:29 -0000, Nicholas Mc Guire said: [...]
Generally, POSIX specifies a API and doesn't really care it it's a real syscall (which crosses the border of user- and kernel-space by definition), a pure-user-space function or some mixture.
Note that you can do system calls directly with system() but that is generaly not how you do it - you to through the glibc calls which do some checks before invoking the actual system call.
system() does a fork/exec of a process.
... via `/bin/sh -c` so it's actually (at least) 2 of both.
syscall() issues an arbitrary system call, but all marshalling of parameters and return codes becomes your problem
... as well as the availability of that syscall at runtime (and glibc has a lot of compatibility/emulation in that direction). Not everyone everywhere has a (somewhat) recent kernel. MfG, Bernd -- Bernd Petrovitsch Email : bernd@petrovitsch.priv.at LUGA : http://www.luga.at
On Thu, Aug 16, 2018 at 03:44:49PM -0400, valdis.kletnieks@vt.edu wrote:
On Thu, 16 Aug 2018 16:29:29 -0000, Nicholas Mc Guire said:
Note that you can do system calls directly with system() but that is generaly not how you do it - you to through the glibc calls which do some checks before invoking the actual system call.
system() does a fork/exec of a process.
syscall() issues an arbitrary system call, but all marshalling of parameters and return codes becomes your problem
yup - sorry - my bad - thats what I actually had in mind but did not check. thanks for your correction ! thx! hofrat
participants (4)
-
Bernd Petrovitsch -
Nicholas Mc Guire -
Subhashini Rao Beerisetty -
valdis.kletnieks@vt.edu