World's most popular travel blog for travel bloggers.

[Solved]: Difference between system calls, system call interface and API?

, , No Comments
Problem Detail: 

Lets take POSIX, whats the difference between POSIX API, libc and actual system calls?

Asked By : BalaK

Answered By : azam

I'll start with system call.

a system call is how a program requests a service from an operating system's kernel. This may include hardware-related services (for example, accessing a hard disk drive), creation and execution of new processes, and communication with integral kernel services such as process scheduling. System calls provide an essential interface between a process and the operating system. Wiki

Another definition.

A system call, sometimes referred to as a kernel call, is a request by an active process made via a software interrupt for a service performed by the kernel. (Source)

The library as an intermediary

Generally, systems provide a library or API that sits between normal programs and the operating system. On Unix-like systems, that API is usually part of an implementation of the C library (libc), such as glibc, that provides wrapper functions for the system calls, often named the same as the system calls they invoke.....For example, in Unix-like systems, fork and execve are C library functions that in turn execute instructions that invoke the fork and exec system calls. Making the system call directly in the application code is more complicated and may require embedded assembly code to be used (in C and C++) as well as knowledge of the low-level binary interface for the system call operation, which may be subject to change over time and thus not be part of the application binary interface; the library functions are meant to abstract this away. Wiki

You may find a couple of popular POSIX system calls here.

TL;DR

So, to summarize, a system call is a request to the kernel for a service. The system call interface is the basic interface between a program and the kernel. The programming library, e.g. libc, has APIs on top of the basic system calls, provided by the kernel, which further ease the job of the developer.

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/52833

0 comments:

Post a Comment

Let us know your responses and feedback