0
$\begingroup$

I'm working with the CPU Pintos and have a question that is:

In which situations can the kernel accessing the data in virtual memory via a pointer lead to problems? And how do you avoid them?

I know that the kernel can access the virtual memory via pointers to the stack, but don't understand when errors may occur.

$\endgroup$
1
$\begingroup$

Same as with any program that uses pointers: dereferencing one that points nowhere sane will give grief. If in the kernel of the system, with little or no protection against accidents (and nobody who can clean up the mess afterwards), it is much worse.

$\endgroup$
1
$\begingroup$

When you try to access data from a user space program, what happens is that the hardware tries to translate your logical address into the physical address of RAM, and then access the data if possible. If the data is not in RAM, then the CPU will switch to code in the OS that tries to load the data into RAM.

Mostly this is possible for code in the kernel as well. However, there is some data that absolutely MUST be in RAM: That is the code for loading virtual memory from disk to the RAM, and all the data that keeps track of what is where in memory. If the code loading data from disk into RAM is on the disk and not in RAM, then obviously you can't execute it.

Many CPUs will produce a fatal error in that situation.

$\endgroup$

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.