12.KernelSync - KernelSynchronization...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Kernel Synchronization with material from Understanding the Linux  Kernel (O’Reilly)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Synchronization In The Kernel Past lectures: Synchronization constructs Today’s lecture: What does this stuff look like in an OS? We have source code for Linux… We mostly run on x86 platforms Lets look at some specifics.
Background image of page 2
3 Disabling Interrupts Key observations: On a uni-processor, an operation is atomic if no context- switch is allowed in the middle of the operation Context switch occurs because of: Internal events: system calls and exceptions External events: interrupts Mutual exclusion can be achieved by preventing context switch Prevention of context switch Eliminate internal events: easy (under program control) Eliminate external events: disable interrupts Hardware delays the processing of interrupts until interrupts are enabled
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Lock Implementation: A Naïve Solution Will this work on a uni-processor? What is wrong with this solution? Once interrupts are disabled, the thread can’t be stopped Can starve other threads Critical sections can be arbitrarily long Can’t bound the amount of time needed to respond to interrupts But this is used all over the place in uniprocessor OSes to do short tasks. It is a large source of bugs. What would typical failure conditions be? Lock::Acquire()  { disable interrupts; } Lock::Release()  { enable interrupts;} Lock::Acquire()  { disable interrupts; } Lock::Release()  { enable interrupts;}
Background image of page 4
5 Disabling Interrupts in Linux Usually some small number of interrupt levels, statically assigned (e.g., reset = 0, timer = 1, network = 3, disk = 4, software = 7) When you “disable interrupts” you disable them for your level and higher. When you reenable interrupts, you need to do so at the
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 03/09/2012.

Page1 / 18

12.KernelSync - KernelSynchronization...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online