How does protected memory work? In order to protect memory, you must first set up some sort of permission flag in the given page/segment. Now, when you yield and the next thread is on the CPU, what prevents it from writing in your memory space?
The processor must know that the "current" thread is not in fact you. How is this implemented? You could have some area in the processor which stores the current PID, and that would (I assume) most likely be set by the kernel/task scheduler. But how does the processor know when the kernel/task scheduler is running? What is to prevent the current thread from writing over that and claiming to have privileges?
Basically, I guess I'm asking how a process "authenticates" itself when it wants to write somewhere.
The processor must know that the "current" thread is not in fact you. How is this implemented? You could have some area in the processor which stores the current PID, and that would (I assume) most likely be set by the kernel/task scheduler. But how does the processor know when the kernel/task scheduler is running? What is to prevent the current thread from writing over that and claiming to have privileges?
Basically, I guess I'm asking how a process "authenticates" itself when it wants to write somewhere.