4
$\begingroup$

Quoting wikipedia, a system call is:

In computing, a system call is how a program requests a service from an operating system's kernel. This may include hardware related services (e.g. accessing the hard disk), creating and executing new processes, and communicating with integral kernel services (like scheduling). System calls provide an essential interface between a process and the operating system.

In ordinary operating systems, when a system call is made the operating system enters kernel mode and performs the requested operation.

What happens to a system call made by a process in a virtual machine? Is it handled by the virtual machine only, or is it delegated to the outer kernel to be operated by the hardware-facing kernel?

$\endgroup$

migrated from operatingsystems.stackexchange.com Sep 11 '14 at 12:39

  • 4
    $\begingroup$ This question has been asked and answered on stackoverflow at: stackoverflow.com/questions/14415050/… $\endgroup$ – unxnut Aug 24 '14 at 20:06
  • 3
    $\begingroup$ The answer there is too short, and doesn't convey much. Hence I feel a better answer is due here. $\endgroup$ – Stark07 Aug 25 '14 at 11:43
  • $\begingroup$ What research have you done? Have you read standard materials on how virtual machines work? This is covered by many standard resources. $\endgroup$ – D.W. Sep 12 '14 at 0:13
7
$\begingroup$

There are 3 common strategies to handle this:
1. Hypervisor traps system calls from guest: The hypervisor checks whether the privileged instruction(effectively system call) came from the guest OS itself, or from a user-space program within the guest OS. If it's the former case, then the hypervisor will actually forward the call to the hardware, although through the virtualization instructions. If it's the latter, the hypervisor will redirect the call to the guest OS, and then proceed.
2. Binary translation: Here the hypervisor checks the code from the guest OS in what are called as "basic blocks", scanning for privileged instructions. Wherever it finds them, it replaces them with calls to it's own procedures to system calls. It then proceeds to cache these blocks & eventually builds a whole set of such blocks.
3. Paravirtualization: Here the guest OS itself is modified so that instead of making calls to the hardware, it has APIs to invoke the hypervisor to get its hardware I/O done.

Source: Modern Operating Systems by Andrew Tanenbaum

$\endgroup$
  • 1
    $\begingroup$ With greater hardware support for virtualization, many system calls do not need to touch the hypervisor. E.g., with nested page tables, a guest OS can update its page tables without invoking the hypervisor. $\endgroup$ – Paul A. Clayton Sep 20 '14 at 20:09
  • $\begingroup$ Is any of those strategies specific to a specific type of hypervisor? $\endgroup$ – Nikos Jan 1 '18 at 13:48

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.