Joanna
Joanna

Reputation: 174

Operating Systems: Kernel mode operations

I would appreciate help with determining which of the following operations should be performed/done only in the kernel mode. I tried finding the answer in Silberschatz "Operating System Concepts" but it is still unclear to me. Here is the list of operations to decide whether they should be done in the kernel mode or the user mode:

(1) disable interrupts detection
(2) clear memory
(3) switch from the user mode to the kernel mode
(4) read the state of the clock/timer
(5) determine/program timer. 

Upvotes: 0

Views: 1330

Answers (1)

Ismael Luceno
Ismael Luceno

Reputation: 2118

It is just common sense:

  • Disabling interrupts shouldn't happen in an unprivileged context, so normally you don't allow that.
  • Clearing memory in itself isn't a privileged operation, so it can happen in either context (if memory is "freed", then you have to decide if the contents are sensitive or not before allowing access from any other context, but always clearing the contents is a safe bet).
  • Switch from user mode to kernel mode obviously can only happen in user mode.
  • Reading a clock: if we're talking about hardware clocks, if it provides memory-mapped registers, then you can access it safely from user mode, as long as the mapped region has nothing sensitive (it may or may not, depends on the hardware). If just software you can do anything.
  • Programming a timer may happen on either context depending on the implementation, for example: real-time scheduled contexts may implement timers entirely in user mode without trouble, either by programming a hardware timer and interrupt routing (the later only needs to happen once even if it requires kernel-mode) or implementing it all in software. If not real-time, programming entirely in user space may still possible, but the implementation will require a kernel-side helper (i.e. a real-time task or an interrupt) to trigger the event.

Upvotes: 3

Related Questions