this post was submitted on 02 Sep 2023
20 points (100.0% liked)
Programming
13368 readers
2 users here now
All things programming and coding related. Subcommunity of Technology.
This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I think one of the motivations for having separate modes like this, with (some) separate registers for each, is to reduce the time taken to switch contexts between modes. If they didn't have separate registers, the data in the user mode registers would have to be saved somewhere when making a switch into kernel mode, and then copied back again when switching back to user mode.
There are no separate registers, every call to kernel mode takes extra time precisely because it has to save all the caller's registers, then restore them again before returning.
It involves even more registers than what's visible to the user, because the kernel also has to change the ones related to memory and device access permissions.