Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Operating Systems Lecture # 3 Recap Application System Call Trap Operating System Processor Hardware Trap Hardware Time-sharing OS • OS emulates that all processes are making simultaneous progress • Batch mode does not lie all that well • Executes one process to completion, then runs the next one • OS is simpler since no pre-emptive context switching • Time-sharing OS puts up a better pretence • Every process gets a time quantum periodically -- e.g. every 2 msec -- so that everyone makes some progress simultaneously • The OS must include support for pre-emptive contextswitching Concept of a Task in an Operating System • Some way to allocate resources on the hardware for the application • Space (memory) • Data structures for running computation • Some way to execute the application • May be more than execution paths in the application code • Typically called an “execution thread” What is a process? Frame1 Stack Frame2 Heap Static Variables Code Corresponding to each subroutine Invocation Hello(a, b) --> push frame .. Return; --> pop frame What is a thread? Shared “Heap” Static Variables •Different PC Stack1 •Different Registers Stack2 Process Code •Almost same “memory” Context-switching • Capture the state of the running process • Freeze it • Such that you can re-incarnate it later on • Simplest context-switch • Subroutine “return” • Can implement yourself in user space • Called “Cooperative scheduling” or co-routine scheduling Inside the OS • When to context-switch • When make a system call • User to Kernel • When make a blocking system call • Read from disk or keyboard • Process time quantum runs out • Pre-emptive scheduling • Non-text book detail • Scheduling is done when returning from a system call Process States Scheduling • FCFS • Round-robin • Priority