DOC PREVIEW
Princeton COS 318 - Project #3

This preview shows page 1-2-3-4 out of 13 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS318 Project #3Continuing from Project 2Multi-ThreadingWhat do you have to do?LockLock (cont.)Condition VariablesSemaphoreMutexBarrierHandling InterruptsSlide 12The End1CS318 Project #3Preemptive Kernel2Continuing from Project 2Project 2 involved:Context SwitchStack ManipulationSaving StateMoving between threads, but in a non-preemptive environment3Multi-ThreadingNow you have to deal with the possibility of your context switch being interruptedTimer Interrupt (10 ms)Page Fault (later)TLB Miss (later)4What do you have to do?Implement locking primitives (thread.c)LockAcquire & ReleaseConditionSignal, Wait, BroadcastSemaphoreUp & DownBarrierWaitTimer Interrupt (entry.S)Also handle irq7 - call fake_irq7 instead of scheduler_entry5LockAcquiring and releasing a lock must be done atomicallyOtherwise …Release LockThread 1Thread 2Acquire LockCritical Section Critical SectionRelease LockAcquire Lock6Lock (cont.)Acquiring and Releasing of the lock should be done in a single threaded contextHow do you do this?Turn interrupts off for as small a window as possible7Condition VariablesWait operation cause the current thread to block on put itself of a wait listSignal causes a random thread on the wait list to start runningBroadcast wakes up all waiting threadsCondition Variables can “lose” signals if no thread is on the wait list to receive it8SemaphoreUse when you need a way to store wakeup signalsProducer-Consumer ProblemTwo operationsUp -> Called to wakeup a thread, if no thread is ready to be woken up, the wakeup signal is storedDown -> Called to see if a wakeup signal is stored, otherwise sleep9MutexA semaphore used for mutual exclusionSemaphore should only ever have values 0 and 1Useful when only one thread should execute a piece of code at a time10BarrierUsed to synchronize multiple threads at a single pointUsually the boundary between passes of phases of an algorithmCount number of threads stoppedCount number of threads started11Handling InterruptsSetting up of interrupt vector table already done for you.You only need to implement irq0_entry, fake_irq7_entrysyscall_entry already provided.12Handling InterruptsFor all interruptsSave the current stateTell the Interrupt Controller to allow more interrupts (EOI)Process the interruptUse iret to return from interruptsCall scheduler to move to next process on timer interrupt13The


View Full Document

Princeton COS 318 - Project #3

Documents in this Course
Overview

Overview

25 pages

Deadlocks

Deadlocks

25 pages

lectute 2

lectute 2

28 pages

Lecturel

Lecturel

24 pages

Real mode

Real mode

49 pages

Lecture 2

Lecture 2

54 pages

lecture 5

lecture 5

27 pages

Load more
Download Project #3
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Project #3 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 Project #3 2 2 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?