Skip to contentSkip to conversation

kernel provided system call is an API?

DISCUSSION Shriramana Sharma 4 participants 7 messages Oct 26, 2007 – Oct 29, 2007

lore
Share & tools
lore
#0 lore raw

Hello friends.

1. Can the system calls provided by the kernel be considered an API?

2. When an app using system calls is executed, would any code in the kernel be executed?

Shriramana Sharma.

#1 lore raw
Quoted 1 line · Shriramana Sharma

1. Can the system calls provided by the kernel be considered an API?

System calls aren't strictly an *application* programming interface. Applications are supposed to use the libc functions.

OTOH, the term "system call" is often used to refer to both of the actual system call and the corresponding libc function.

IOW, read() is an API, syscall(SYS_read, ...) isn't.

Quoted 2 lines

2. When an app using system calls is executed, would any code in the kernel be executed?

Yes. That's the point of system calls.

Signature · 1 line
Glynn Clements <[email protected]>
#2 lore raw
Quoted 6 lines · Glynn Clements
Quoted 1 line · Shriramana Sharma

1. Can the system calls provided by the kernel be considered an API?

System calls aren't strictly an *application* programming interface. Applications are supposed to use the libc functions.

OK so is it at least a "programming interface"?

Thanks.

Shriramana Sharma.

#3 lore raw
Quoted 6 lines · Shriramana Sharma
Quoted 4 lines
Quoted 1 line

1. Can the system calls provided by the kernel be considered an API?

System calls aren't strictly an *application* programming interface. Applications are supposed to use the libc functions.

OK so is it at least a "programming interface"?

Yes, although it's intended to be used solely by libc.

Signature · 1 line
Glynn Clements <[email protected]>
#4 lore raw
Quoted 11 lines · Glynn Clements
Quoted 6 lines · Shriramana Sharma
Quoted 4 lines
Quoted 1 line

1. Can the system calls provided by the kernel be considered an API?

System calls aren't strictly an *application* programming interface. Applications are supposed to use the libc functions.

OK so is it at least a "programming interface"?

Yes, although it's intended to be used solely by libc.

I think the "more correct"(TM) explanation would be that:

Each hardware architecture, and OS, will have different methods of
invoking the actual system call. So from memory Linux and FreeBSD uses different methods to initiate a syscall. Althought
the man read(2) "api" from the libc "user"'s perspective are all the same (specified by POSIX etc.) the nitty gritty of getting into the kernel differs.

Signature · 1 line
Hendrik Visage
#5 lore raw
Quoted 11 lines · Hendrik Visage
Quoted 10 lines · Glynn Clements
Quoted 6 lines · Shriramana Sharma
Quoted 4 lines
Quoted 1 line

1. Can the system calls provided by the kernel be considered an API?

System calls aren't strictly an *application* programming interface. Applications are supposed to use the libc functions.

OK so is it at least a "programming interface"?

Quoted 7 lines
Quoted 1 line

Yes, although it's intended to be used solely by libc.

I think the "more correct"(TM) explanation would be that:

Each hardware architecture, and OS, will have different methods of
invoking the actual system call. So from memory Linux and FreeBSD uses different methods to initiate a syscall.

And so do Windows, VMS and HP-UX, and many others.

Quoted 3 lines

Althought the man read(2) "api" from the libc "user"'s perspective are all the same (specified by POSIX etc.) the nitty gritty of getting into the kernel differs.

Right, but we are talking about the interfaces to the _Linux_ kernel and already illustrated in earlier threads what system calls are and how they are invoked by making use of system call wrappers.

Anyhow, Glynn put it straight and did so in a concise manner.

\Steve

--

Steve Grägert
DigitalEther.de
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
In reply to Hendrik Visage
Quoted 9 lines · Hendrik Visage
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

1. Can the system calls provided by the kernel be considered an API?

System calls aren't strictly an *application* programming interface. Applications are supposed to use the libc functions.

OK so is it at least a "programming interface"?

Yes, although it's intended to be used solely by libc.

Quoted 8 lines

I think the "more correct"(TM) explanation would be that:

Each hardware architecture, and OS, will have different methods of
invoking the actual system call. So from memory Linux and FreeBSD uses different methods to initiate a syscall. Althought
the man read(2) "api" from the libc "user"'s perspective are all the same (specified by POSIX etc.) the nitty gritty of getting into the kernel differs.

There's slightly more to it than that. Some of the library functions which interface to system calls do more than just invoke the corresponding system call. E.g. some functions are overriden in the pthread library to add cancellation points.

Also, readdir() has historically been a system call. Linux has a readdir system call, but the readdir() function is built atop the getdents system call for efficiency (getdents returns multiple entries at a time, which reduces the number of context switches required to scan a directory).

Signature · 1 line
Glynn Clements <[email protected]>