Princeton COS 318 - Non-Preemptive and Preemptive Threads (22 pages)

Previewing pages 1, 2, 21, 22 of 22 page document View the full content.
View Full Document

Non-Preemptive and Preemptive Threads



Previewing pages 1, 2, 21, 22 of actual document.

View the full content.
View Full Document
View Full Document

Non-Preemptive and Preemptive Threads

48 views

Other


Pages:
22
School:
Princeton University
Course:
Cos 318 - Computing for Physical & Social Sciences
Computing for Physical & Social Sciences Documents

Unformatted text preview:

COS 318 Operating Systems Non Preemptive and Preemptive Threads Kai Li Computer Science Department Princeton University http www cs princeton edu courses cos318 Today s Topics Non preemptive threads Preemptive threads Kernel vs user threads Too much milk problem 2 Revisit Monolithic OS Structure Kernel has its address space shared with all processes Kernel consists of Boot loader BIOS Key drivers Threads Scheduler User Process User Process Scheduler Use a ready queue to hold all ready threads Schedule in the same address space thread context switch Schedule in a new address space process context switch Kernel scheduler 3 Non Preemptive Scheduling Terminate call scheduler Scheduler dispatch Running Block for resource call scheduler Yield call scheduler Create Exited Ready Blocked Resource becomes available move to ready queue 4 Scheduler A non preemptive scheduler invoked by calling block yield The simplest form Scheduler save current process thread state choose next process thread to run dispatch load PCB TCB and jump to it Does this work 5 More on Scheduler Should the scheduler use a special stack Should the scheduler simply be a kernel thread 6 Where and How to Save Thread Context Save the context on the thread s stack Many processors have a special instruction to do it efficiently But need to deal with the overflow problem Check before saving Make sure that the stack has no overflow problem Copy it to the TCB residing in the kernel heap Not so efficient but no overflow problems Thread 2 Thread 1 frame frame frame frame Save the context of Thread 1 to its stack frame frame Context frame frame 7 Preemption by I O and Timer Interrupts Why Interrupts Timer interrupt to help CPU management Asynchronous I O to overlap with computation Between instructions Within an instruction except atomic ones CPU Memory Interrupt Manipulate interrupts Disable mask interrupts Enable interrupts Non Masking Interrupts 8 State Transition for Non Preemptive Scheduling Terminate call



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Non-Preemptive and Preemptive Threads and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Non-Preemptive and Preemptive Threads and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?