cs4414 Fall 2013
University of Virginia
David Evans
Columbus, 28 Feb 2001 Jeonju, 17 June 2002
Class 2-0:
Once Upon a Proc...
Today’s Main Question
How can several programs
share a processor?
112 September 2013 University of Virginia cs4414
12 September 2013 University of Virginia cs4414 2
Recap:
Last Class
12 September 2013 University of Virginia cs4414 3
Program Computer
Center
Your Program Runs
Program A
Pr...
Kinds of Processor-Sharing
Multiprogramming
User program X runs until it gets stuck, then
supervisor program takes over.
N...
Non-preemptive Preemptive
12 September 2013 University of Virginia cs4414 5
12 September 2013 University of Virginia cs4414 6
MULTICS (1969)
UNIX (1975)
PowerMac G5
(Mac OS 9)
2006
MacBook Air
(Mac ...
Which have preemptive
multitasking?
12 September 2013 University of Virginia cs4414 7
MULTICS (1969)
UNIX (1975)
PowerMac ...
How could I prove it?
12 September 2013 University of Virginia cs4414 8
One-line Proof
12 September 2013 University of Virginia cs4414 9
Quiz
Which are results of preemptive multitasking?
A. A computer running Mac OS X crashes less
than one running Mac OS 9
B...
12 September 2013 University of Virginia cs4414 11
How did Apple add preemptive multitasking to Mac OS?
Mac OS X (Cheetah)...
12 September 2013 University of Virginia cs4414 12
http://www.youtube.com/watch?v=YsWBJ_usRck&t=2m18s
(The answer is
proba...
12 September 2013 University of Virginia cs4414 13
“Once you make them talk, they
won’t be inanimate anymore.”
Steve Jobs ...
12 September 2013 University of Virginia cs4414 14
https://upload.wikimedia.org/wikipedia/commons/7/77/Unix_history-simple...
12 September 2013 University of Virginia cs4414 15
12 September 2013 University of Virginia cs4414 16
12 September 2013 University of Virginia cs4414 17
12 September 2013 University of Virginia cs4414 18
Tim Berners Lee finishing PS1 23 years early!
12 September 2013 University of Virginia cs4414 19
MULTICS
Unix
BSD
Linux
Minix
Android
NextStep
Mac OS X
iOS
Code (carrie...
12 September 2013 University of Virginia cs4414 20
12 September 2013 University of Virginia cs4414 21
12 September 2013 University of Virginia cs4414 22
Non-Malicious
Developers
I am not making this up (really)!:
http://www....
12 September 2013 University of Virginia cs4414 23
So, which API
do I use to
turn on his
microphone?
12 September 2013 University of Virginia cs4414 24
Malicious
Developers
(This one is speculative…)
PRK
senate hearing
Sena...
Actually just a little harder…
12 September 2013 University of Virginia cs4414 25
Malicious
Developers
Is “App Review” Possible?
12 September 2013 University of Virginia cs4414 26
Ok! Never
turns on
microphone.
Some
program
e...
12 September 2013 University of Virginia cs4414 27
Not on my
machine, muc
hachas!
What Seems To Be Possible
12 September 2013 University of Virginia cs4414 28
Ok! Never
turns on
microphone.
Some
program
e...
12 September 2013 University of Virginia cs4414 29
12 September 2013 University of Virginia cs4414 30
USENIX Security 2013 (click picture for talk video)
What Is Actually Possible
12 September 2013 University of Virginia cs4414 31
Ok! Never
turns on
microphone.
Some
program
e...
The Good News!
12 September 2013 University of Virginia cs4414 32
May have been posted by malicious app, not US senator.
How can
preemptive multitasking
even be possible?!?
12 September 2013 University of Virginia cs4414 33
More bad news…?
Pre...
Preemptive (?) Multitasking
12 September 2013 University of Virginia cs4414 34
Program A
Program B
Program C
A
B
A
Supervi...
12 September 2013 University of Virginia cs4414 35
12 September 2013 University of Virginia cs4414 36
Interrupts
12 September 2013 University of Virginia cs4414 37
How frequently
should the
supervisor’s alarm
clock (“kernel
...
My MacBook (Ubuntu)
12 September 2013 University of Virginia cs4414 38
bash-3.2$ uname -a
Darwin Davids-MacBook-Air-2.loca...
Timer Interrupts
12 September 2013 University of Virginia cs4414 39
A B
Super
visor
set alarm clock
switch to program A
Wh...
Who interrupts the supervisor?
12 September 2013 University of Virginia cs4414 40
The supervisor’s supervisor!
12 September 2013 University of Virginia cs4414 41
a.k.a. Hypervisor
12 September 2013 University of Virginia cs4414 42
Support for hypervisor added
to Intel x86 in 2005 (VT-x)
12 September 2013 University of Virginia cs4414 43
More general (quite
similar) idea in MULTICS
(but with 8-levels of
supe...
PS2: The Good Ole Shell
12 September 2013 University of Virginia cs4414 44
$ echo ‘Wha-hoo-wa!’
$ !!
$ traceroute 128.143....
Upcoming SlideShare
Loading in …5
×

Once Upon a Process

1,954 views

Published on

cs4414: Class 4 (Dos a Cero)

How to share a processor among multiple programs - non-preemptive and preemptive multitasking.

Why Senators shouldn't play games on their mobile devices during classified hearings.

Notes: http://www.cs.virginia.edu/~evans/cs4414-fall2013/class4.html

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,954
On SlideShare
0
From Embeds
0
Number of Embeds
1,067
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Once Upon a Process

  1. 1. cs4414 Fall 2013 University of Virginia David Evans Columbus, 28 Feb 2001 Jeonju, 17 June 2002 Class 2-0: Once Upon a Process
  2. 2. Today’s Main Question How can several programs share a processor? 112 September 2013 University of Virginia cs4414
  3. 3. 12 September 2013 University of Virginia cs4414 2
  4. 4. Recap: Last Class 12 September 2013 University of Virginia cs4414 3 Program Computer Center Your Program Runs Program A Program B Program C A B A C Batch Processing Multiprogramming
  5. 5. Kinds of Processor-Sharing Multiprogramming User program X runs until it gets stuck, then supervisor program takes over. Non-preemptive multi-tasking User program X runs until it decides to let the supervisor program run. Preemptive multi-tasking User program X runs until the (approximately) supervisor decides to let another program run. 12 September 2013 University of Virginia cs4414 4
  6. 6. Non-preemptive Preemptive 12 September 2013 University of Virginia cs4414 5
  7. 7. 12 September 2013 University of Virginia cs4414 6 MULTICS (1969) UNIX (1975) PowerMac G5 (Mac OS 9) 2006 MacBook Air (Mac OS X) 2011 Microsoft Windows 2.1x 1988 Which have preemptive multitasking?
  8. 8. Which have preemptive multitasking? 12 September 2013 University of Virginia cs4414 7 MULTICS (1969) UNIX (1975) PowerMac G5 (Mac OS 9) 2006 MacBook Air (Mac OS X) 2011 Microsoft Windows 2.1x 1988
  9. 9. How could I prove it? 12 September 2013 University of Virginia cs4414 8
  10. 10. One-line Proof 12 September 2013 University of Virginia cs4414 9
  11. 11. Quiz Which are results of preemptive multitasking? A. A computer running Mac OS X crashes less than one running Mac OS 9 B. A computer running Mac OS X needs fewer hard reboots than one running Mac OS 9 C. When you watch Gangnam Style even for the 50th time, the video jitters D. A Senator can play poker on an iPhone during an important hearing 12 September 2013 University of Virginia cs4414 10
  12. 12. 12 September 2013 University of Virginia cs4414 11 How did Apple add preemptive multitasking to Mac OS? Mac OS X (Cheetah) 24 March 2001 Mac OS 9.2.2 5 Dec 2001
  13. 13. 12 September 2013 University of Virginia cs4414 12 http://www.youtube.com/watch?v=YsWBJ_usRck&t=2m18s (The answer is probably not in this movie.)
  14. 14. 12 September 2013 University of Virginia cs4414 13 “Once you make them talk, they won’t be inanimate anymore.” Steve Jobs (as quoted by Sorkin earlier in interview)
  15. 15. 12 September 2013 University of Virginia cs4414 14 https://upload.wikimedia.org/wikipedia/commons/7/77/Unix_history-simple.svg
  16. 16. 12 September 2013 University of Virginia cs4414 15
  17. 17. 12 September 2013 University of Virginia cs4414 16
  18. 18. 12 September 2013 University of Virginia cs4414 17
  19. 19. 12 September 2013 University of Virginia cs4414 18 Tim Berners Lee finishing PS1 23 years early!
  20. 20. 12 September 2013 University of Virginia cs4414 19 MULTICS Unix BSD Linux Minix Android NextStep Mac OS X iOS Code (carries license) “Ideas” (no license, possible patent lawsuits) FreeBSD
  21. 21. 12 September 2013 University of Virginia cs4414 20
  22. 22. 12 September 2013 University of Virginia cs4414 21
  23. 23. 12 September 2013 University of Virginia cs4414 22 Non-Malicious Developers I am not making this up (really)!: http://www.pkr.com/en/community/news-events/pkr-for-iphone/ Senator’s Phone
  24. 24. 12 September 2013 University of Virginia cs4414 23 So, which API do I use to turn on his microphone?
  25. 25. 12 September 2013 University of Virginia cs4414 24 Malicious Developers (This one is speculative…) PRK senate hearing Senator’s Phone
  26. 26. Actually just a little harder… 12 September 2013 University of Virginia cs4414 25 Malicious Developers
  27. 27. Is “App Review” Possible? 12 September 2013 University of Virginia cs4414 26 Ok! Never turns on microphone. Some program execution turns on the microphone!
  28. 28. 12 September 2013 University of Virginia cs4414 27 Not on my machine, muc hachas!
  29. 29. What Seems To Be Possible 12 September 2013 University of Virginia cs4414 28 Ok! Never turns on microphone. Some program execution turns on the microphone!Not sure…let’s send it to NSA just in case.
  30. 30. 12 September 2013 University of Virginia cs4414 29
  31. 31. 12 September 2013 University of Virginia cs4414 30 USENIX Security 2013 (click picture for talk video)
  32. 32. What Is Actually Possible 12 September 2013 University of Virginia cs4414 31 Ok! Never turns on microphone. Some program execution turns on the microphone!Not sure…let’s send it to NSA just in case.
  33. 33. The Good News! 12 September 2013 University of Virginia cs4414 32 May have been posted by malicious app, not US senator.
  34. 34. How can preemptive multitasking even be possible?!? 12 September 2013 University of Virginia cs4414 33 More bad news…? Preemptive multi-tasking User program X runs until the supervisor decides to let another program run.
  35. 35. Preemptive (?) Multitasking 12 September 2013 University of Virginia cs4414 34 Program A Program B Program C A B A Supervisor Supervisor Supervisor A
  36. 36. 12 September 2013 University of Virginia cs4414 35
  37. 37. 12 September 2013 University of Virginia cs4414 36
  38. 38. Interrupts 12 September 2013 University of Virginia cs4414 37 How frequently should the supervisor’s alarm clock (“kernel timer interrupt”) go off to check on the workers?
  39. 39. My MacBook (Ubuntu) 12 September 2013 University of Virginia cs4414 38 bash-3.2$ uname -a Darwin Davids-MacBook-Air-2.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu- 1699.32.7~1/RELEASE_X86_64 x86_64 bash-3.2$ gcc timer.c ; ./a.out kernel timer interrupt frequency is approx. 4016 Hz or higher timer.c is a 50-line C program from http://www.advenage.com/topics/linux-timer-interrupt-frequency.php (link on notes) Midterm exemption opportunity: make a Rust version (and convince me it is accurate)
  40. 40. Timer Interrupts 12 September 2013 University of Virginia cs4414 39 A B Super visor set alarm clock switch to program A What makes the alarm clock ring? Supervisor set alarm clock switch to program B Supervisor
  41. 41. Who interrupts the supervisor? 12 September 2013 University of Virginia cs4414 40
  42. 42. The supervisor’s supervisor! 12 September 2013 University of Virginia cs4414 41 a.k.a. Hypervisor
  43. 43. 12 September 2013 University of Virginia cs4414 42 Support for hypervisor added to Intel x86 in 2005 (VT-x)
  44. 44. 12 September 2013 University of Virginia cs4414 43 More general (quite similar) idea in MULTICS (but with 8-levels of supervision in hardware by 1975)
  45. 45. PS2: The Good Ole Shell 12 September 2013 University of Virginia cs4414 44 $ echo ‘Wha-hoo-wa!’ $ !! $ traceroute 128.143.22.36 $ id -p ray $ !! $ fsck; !mount -u VA!

×