Computer Architecture support to OS

Architectural Features for OS

Features that directly support OS needs include:

  1. Protected Instructions 
  • Direct user access to some hardware resources is not permitted.
  • I/O devices such as discs, printers, etc. can be accessed directly.
  • Instructions that alter the state of memory management (e.g., page table pointers, TLB load) must be under control.
  • special mode bits are set
  • halt instruction
     2. OS Protection
  • Hardware supports a scheme that allows us to tell apart the trusted programmer (operating system designer) from untrusted programmers (regular users).
  • Most architectures support at least two modes of operation: kernel mode and user mode
  • The OS executes in kernel mode, user programs execute in user mode
  • Mode is indicated by a status bit in a protected processor register 
     3. Memory Protection
  •  Need to protect a user program from accessing the data in other user programs 
  •  Need to protect the OS from user programs 
  •  Simplest scheme is base and limit registers:



     4. I/O Control 
       
     5. Synchronization
  • Interrupts cause potential problems because an interrupt can occur at any time -- causing code to execute that interferes with code that was interrupted 
  • OS must be able to synchronize concurrent processes 
  • This requires guaranteeing that certain instruction sequences (read-modify- write) execute atomically 
  • One way to guarantee this is to turn off interrupts before the sequence, execute it, and re-enable interrupts; CPU must have a way to disable interrupts – When would this not be sufficient 
  • Another is to have special instructions that can perform a read/modify/write in a single bus transaction, or can atomically test and conditionally set a bit, based on its previous value     
   
     6. Timer Operation
  • How does the OS prevent against runaway user programs (infinite loops)? 
  • A timer can be set to generate an interrupt in a given time.
  • Before it transfers to a user program, the OS loads the timer with a time to interrupt. 
  • When the time arrives, the executing program is interrupted and the OS regains control. 
  • This ensures that the OS can get the CPU back even if a user program erroneously or purposely continues to execute past some allotted time. 
  • The timer is privileged: only the OS can load it.