sleepAndWakeup

Document Sample
sleepAndWakeup Powered By Docstoc
					Sleep and Wakeup Algorithm
Arvind W. Kiwelekar akiwelekar@gmail.com 02140262041

February 13, 2009

Arvind W. Kiwelekar akiwelekar@gmail.com02140262041 Sleep and Wakeup Algorithm

Process Sleep Algorithm

Arvind W. Kiwelekar akiwelekar@gmail.com02140262041 Sleep and Wakeup Algorithm

Process Sleep Algorithm
Logical Model
0..n Process sleeps 1..1 Event 0..n maps 1..1 Address

process 1 process 2 process 3 process 4

awaiting for I/O Completion

1001

waiting for buffer

1011

waiting for inode process 5 process 6 waiting for ternimanl i/p process 7

1021

Arvind W. Kiwelekar akiwelekar@gmail.com02140262041 Sleep and Wakeup Algorithm

Process Sleep Algorithm

Data Structures Used to Implement Sleep Algo.
1001 1021 1031 P1 P4 P7 Queue of Sleeping Processes P2 P3

f(Event) = sleep Address
Hash

Arvind W. Kiwelekar akiwelekar@gmail.com02140262041 Sleep and Wakeup Algorithm

Process Sleep
input 1. Sleep Address 2. Priority output For iterrupted sleep 1 and 0 for un-interrupted sleep
1 2 3 4 5 6 7

r ais e processor execution l e v e l to block a l l i n t e r r u p t s s e t p ro c e s s s t a t e to s l e e p put p r o c e s s on s l e e p hash queue b a s e d on s l e e p a d d r e s s save s l e e p address in process t a b l e s l o t s e t p ro c e s s p r i o r i t y to i n p u t p r i o r i t y l e v e l

Arvind W. Kiwelekar akiwelekar@gmail.com02140262041 Sleep and Wakeup Algorithm

Process Sleep

8 9 10 11 12 13 14

i f ( p r o c e s s s l e e p i s NOT i n t e r r u p t i b l e ) { do c o n t e x t s w i t c h // p r o c e s s r e s u m e s e x e c u t i o n h e r e when i t wakes up r e s e t p r o c e s s o r p r i o r i t y l e v e l to a l l o w i n t e r r u p t s a s when p r o c e s s went t o s l e e p return (0); }

Arvind W. Kiwelekar akiwelekar@gmail.com02140262041 Sleep and Wakeup Algorithm

Process Sleep

15 16 17 18 19 20 21 22 23

i f ( no s i g n a l i s p e n d i n g a g a i n s t p r o c e s s ) { do c o n t e x t s w i t c h /∗ p r o c e s s r e s u m e s e x e c u t i o n h e r e when i t wakes up ∗/ i f ( no s i g n a l i s p e n d i n g a g i a n s t p r o c e s s ) { r e s e t p r o c e s s o r p r i o r i t y l e v e l to what i t was when p r o c e s s went t o s l e e p return (0) } }

Arvind W. Kiwelekar akiwelekar@gmail.com02140262041 Sleep and Wakeup Algorithm

Process Sleep

25 26 27 28 29 30

remove p r o c e s s fro m s l e e p h a s queue r e s e t p r o c e s s o r p r i o r i t y l e v e l t o what i t was when p r o c e s s went t o s l e e p i f ( p ro c e s s s l e e p p r i o r i t y s e t to catch s i g n a l s ) return (1) do l o n g j m p a l g o r i t h m

Arvind W. Kiwelekar akiwelekar@gmail.com02140262041 Sleep and Wakeup Algorithm

wakeup algorithm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

r ais e processor execution l e v e l to block a l l i n t e r r u p t s f i n d s l e e p hash queue f o r s l e e p a d d r e s s f o r ( e v e r y p r o c e s s a s l e e p on s l e e p a d d r e s s ) { remove p r o c e s s fro m h a s h q u e u e mark p r o c e s s s t a t e ” r e a d y t o r u n ” clear f i e l d in process table entry for sleep address i f ( p r o c e s s n o t l o a d e d i n memory ) wakeup s w a p p e r p r o c e s s ( 0 ) e l s e i f ( awakened p r o c e s s i s more e l i g i b l e t o r u n than c u r r e n t l y running p ro c e s s ) set scheduler flag } r e s t o r e p r o c e s s o r e xe c u t i o n l e v e l to o r i g i n a l l e v e l

Arvind W. Kiwelekar akiwelekar@gmail.com02140262041 Sleep and Wakeup Algorithm

Flaws in Sleep Algorithm

◮

Doesnot remember how many processes are sleeping on one event (Queue) Event to address mapping is many to one.

◮

Arvind W. Kiwelekar akiwelekar@gmail.com02140262041 Sleep and Wakeup Algorithm


				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:23
posted:2/26/2009
language:English
pages:10