kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* System call vs POSIX call
@ 2018-08-16 16:21 Subhashini Rao Beerisetty
  2018-08-16 16:29 ` Nicholas Mc Guire
  0 siblings, 1 reply; 5+ messages in thread
From: Subhashini Rao Beerisetty @ 2018-08-16 16:21 UTC (permalink / raw)
  To: kernelnewbies

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20180816/b4819cd0/attachment.html>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* System call vs POSIX call
  2018-08-16 16:21 System call vs POSIX call Subhashini Rao Beerisetty
@ 2018-08-16 16:29 ` Nicholas Mc Guire
  2018-08-16 19:44   ` valdis.kletnieks at vt.edu
  0 siblings, 1 reply; 5+ messages in thread
From: Nicholas Mc Guire @ 2018-08-16 16:29 UTC (permalink / raw)
  To: kernelnewbies

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* System call vs POSIX call
  2018-08-16 16:29 ` Nicholas Mc Guire
@ 2018-08-16 19:44   ` valdis.kletnieks at vt.edu
  2018-08-16 21:05     ` Bernd Petrovitsch
  2018-08-17  0:49     ` Nicholas Mc Guire
  0 siblings, 2 replies; 5+ messages in thread
From: valdis.kletnieks at vt.edu @ 2018-08-16 19:44 UTC (permalink / raw)
  To: kernelnewbies

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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 486 bytes
Desc: not available
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20180816/7802975b/attachment.sig>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* System call vs POSIX call
  2018-08-16 19:44   ` valdis.kletnieks at vt.edu
@ 2018-08-16 21:05     ` Bernd Petrovitsch
  2018-08-17  0:49     ` Nicholas Mc Guire
  1 sibling, 0 replies; 5+ messages in thread
From: Bernd Petrovitsch @ 2018-08-16 21:05 UTC (permalink / raw)
  To: kernelnewbies

On Thu, 2018-08-16 at 15:44 -0400, valdis.kletnieks at 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 at petrovitsch.priv.at
                     LUGA : http://www.luga.at

^ permalink raw reply	[flat|nested] 5+ messages in thread

* System call vs POSIX call
  2018-08-16 19:44   ` valdis.kletnieks at vt.edu
  2018-08-16 21:05     ` Bernd Petrovitsch
@ 2018-08-17  0:49     ` Nicholas Mc Guire
  1 sibling, 0 replies; 5+ messages in thread
From: Nicholas Mc Guire @ 2018-08-17  0:49 UTC (permalink / raw)
  To: kernelnewbies

On Thu, Aug 16, 2018 at 03:44:49PM -0400, valdis.kletnieks at 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-08-17  0:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-16 16:21 System call vs POSIX call Subhashini Rao Beerisetty
2018-08-16 16:29 ` Nicholas Mc Guire
2018-08-16 19:44   ` valdis.kletnieks at vt.edu
2018-08-16 21:05     ` Bernd Petrovitsch
2018-08-17  0:49     ` Nicholas Mc Guire

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).