Flashcards in chapter 6: Limited Direct Execution Deck (14):
challenges of time sharing
what does "direct execution" mean
running the program directly on the CPU
direct execution protocol (how it works) (not limited)
create entry for process list
allocate memory for program
load program into memory
set up stack with argc/argv
execute call main()
execute return from main
free memory of process
remove from process list
what is the problem with direct execution?
problem 1: restricted operations
what are the 2 modes to prevent restricted operations
user mode : cant issue IO request
kernel mode : can do whatever
what should a user process do when it wishes to perform some kind of privileged operation such as reading from disk?
user program performs a system call
what is trap and return-from-trap instruction that the OS performs?
trap: jumps into kernel mode
return-from-trap: returns to user mode
how does OS make sure that the trap knows what to run?
the OS initializes a trap table that is mapped to syscall handlers
how does user code execute system call?
it specifies a system-call number which maps to a system call and let the kernel do the thing.
what are the 2 phases in the LDE(limited direct execution) protocol?
1. at boot time, kernel initializes trap table
2. kernel sets up a few things. when process wishes to perform syscall, it traps back into OS, performs it, and return from trap to the process.
if a process is running, the OS isnt. how can OS regain control so that it can switch between processes?
there are 2 ways, cooperative and noncooperative approach
how does the cooperative approach work?
the OS regains control of the CPU by waiting for a system call or an illegal operation to take place.
note: if process goes in infinite loop here, the only way is to reboot the machine
how does the non-cooperative approach work?
a timer interrupt!
when the interrupt is raised, the process is halted and the OS regains control.
note: hardware needs to save state of process to resume running it later