My professor's notes on system virtualization refer a lot to the term "trap", but don't seem to explicitly define it. I can't seem to find any definition on Google either, other than a small article on "trap-and-emulate". From context I sort of understand that trapping is 'catching' any operations that the virtual OS performs which it no longer has the privilege for (as it is now operating in restricted mode), and forwarding them to the hypervisor to be handled.

However could someone who has a more solid understanding of this give me a better definition?

(also I apologize for poor tagging, as there doesn't seem to be a relevant tag for virtual systems)


A trap is basically a localized exception/fault which occurs when the guest OS does not have the required privileges to run a particular instruction. Operating systems running on top of a virtual machine monitor (a hypervisor) do not know that they are running in the 'user' mode i.e. they can only execute a limited set of instructions, since they do not have full control over the bare-metal. So, when the operating system executes some privileged instructions (instructions which can only be run in the 'kernel' mode or some privileged mode), those instructions create a trap that goes into the hypervisor which then emulates the expected functionality of the OS. Note: that the hypervisor runs the commands and emulates it to the application in a VM, so that the application never knows that it is running in a VM.

Full Virtualization

Source: https://stonefly.com/blog/deep-dive-virtualization

| cite | improve this answer | |

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.