0

When a user issue a system call, an interrupt is fired, which switches execution to kernel mode, and then the interrupt handler responsible for system calls execution is executed. Now I believe that this interrupt handler (and all other interrupt handlers) are part of the kernel.

But what about the system calls implementations (for example: the instructions that write data to a file, or the instructions that open a socket), are these instructions considered to be part of the kernel, or are they part of the OS but outside of the kernel?

0

There are many ways to implement system calls, and while "software interrupts" (traps) are one of them, have been used and are still in use, there are other ways, e.g. the syscall instruction (see e.g. here for some more details).

So a system call is a way to call kernel code. The called code is definitely part of the kernel. The calling code is in user space (obviously), and often part of a library (e.g. libc).

The question "is X part of Y" mostly depends on your definition of Y. Define what you mean by "kernel", "OS", and "is part of" (different people define this in different ways), and you'll be able to say if "system calls are part of the kernel, resp. OS".

A better way to think about it is that system calls define an API (application programming interface) to kernel code. As such they are tightly coupled to the kernel (and sometimes specific versions of the kernel).

0

But what about the system calls implementations (for example: the instructions that write data to a file, or the instructions that open a socket), are these instructions considered to be part of the kernel?

They are part of the kernel.

but I suspect you might like some references to go with that assertion

The source code for the read() system call is here: linux-5.0/fs/read_write.c:571

Obviously, if you want to find e.g. the source code that reads from a specific filesystem, you would have to chase through a number of function calls :-).

All of this code gets built into the kernel image, or into a module that can be loaded on-demand to become part of the running kernel. Linux supports several different filesystem types, so they are often built as modules.

It is likely you are using ext4 and also vfat filesystems. You can see the list of loaded kernel modules using lsmod.

On my Fedora 29 system, ext4 is part of the kernel image, but vfat is a loadable module. Therefore lsmod does not show ext4. However modprobe --show-depends ext4 tells me "builtin ext4".

Manual pages:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.