Top Banner
cs4414 Fall 2013 University of Virginia David Evans Columbus, 28 Feb 2001 Jeonju , 17 June 2002 Class 2-0: Once Upon a Process
45

Once Upon a Process

May 16, 2015

Download

Technology

David Evans

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
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 2: Once Upon a Process

April 12, 2023 University of Virginia cs4414 2

Today’s Main Question

How can several programs share a processor?

Page 3: Once Upon a Process

April 12, 2023 University of Virginia cs4414 3

Page 4: Once Upon a Process

April 12, 2023 University of Virginia cs4414 4

Recap: Last Class

Program Computer Center

Your Program Runs

Program A

Program B

Program C

A

B

A

C

Batch Processing

Multiprogramming

Page 5: Once Upon a Process

April 12, 2023 University of Virginia cs4414 5

Kinds of Processor-Sharing

MultiprogrammingUser program X runs until it gets stuck, then supervisor program takes over.

Non-preemptive multi-taskingUser program X runs until it decides to let the supervisor program run.

Preemptive multi-taskingUser program X runs until the (approximately) supervisor decides to let another program run.

Page 6: Once Upon a Process

April 12, 2023 University of Virginia cs4414 6

Non-preemptive Preemptive

Page 7: Once Upon a Process

April 12, 2023 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

Which have preemptive

multitasking?

Page 8: Once Upon a Process

April 12, 2023 University of Virginia cs4414 8

Which have preemptive multitasking?

MULTICS (1969)

UNIX (1975)

PowerMac G5(Mac OS 9)

2006

MacBook Air(Mac OS X)

2011

Microsoft Windows 2.1x

1988

Page 9: Once Upon a Process

April 12, 2023 University of Virginia cs4414 9

How could I prove it?

Page 10: Once Upon a Process

April 12, 2023 University of Virginia cs4414 10

One-line Proof

Page 11: Once Upon a Process

April 12, 2023 University of Virginia cs4414 11

QuizWhich 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 9C. When you watch Gangnam Style even for the

50th time, the video jittersD. A Senator can play poker on an iPhone during

an important hearing

Page 12: Once Upon a Process

April 12, 2023 University of Virginia cs4414 12

How did Apple add preemptive multitasking to Mac OS?

Mac OS X (Cheetah)24 March 2001

Mac OS 9.2.25 Dec 2001

Page 13: Once Upon a Process

April 12, 2023 University of Virginia cs4414 13

http://www.youtube.com/watch?v=YsWBJ_usRck&t=2m18s

(The answer is probably not in this movie.)

Page 14: Once Upon a Process

April 12, 2023 University of Virginia cs4414 14

“Once you make them talk, they won’t be inanimate anymore.”

Steve Jobs (as quoted by Sorkin earlier in interview)

Page 16: Once Upon a Process

April 12, 2023 University of Virginia cs4414 16

Page 17: Once Upon a Process

April 12, 2023 University of Virginia cs4414 17

Page 18: Once Upon a Process

April 12, 2023 University of Virginia cs4414 18

Page 19: Once Upon a Process

April 12, 2023 University of Virginia cs4414 19

Tim Berners Lee finishing PS1 23 years early!

Page 20: Once Upon a Process

April 12, 2023 University of Virginia cs4414 20

MULTICS

Unix

BSD

Linux

Minix

Android

NextStep

Mac OS X

iOS

Code (carries license)

“Ideas” (no license, possible patent lawsuits)

FreeBSD

Page 21: Once Upon a Process

April 12, 2023 University of Virginia cs4414 21

Page 22: Once Upon a Process

April 12, 2023 University of Virginia cs4414 22

Page 24: Once Upon a Process

April 12, 2023 University of Virginia cs4414 24

So, which API do I use to turn on his

microphone?

Page 25: Once Upon a Process

April 12, 2023 University of Virginia cs4414 25

MaliciousDevelopers

(This one is speculative…)

PRK

senate hearingSenator’s Phone

Page 26: Once Upon a Process

April 12, 2023 University of Virginia cs4414 26

Actually just a little harder…MaliciousDevelopers

Page 27: Once Upon a Process

April 12, 2023 University of Virginia cs4414 27

Is “App Review” Possible?

Ok! Never turns on microphone.

Some program execution turns on the microphone!

Possibly Malicious PRK

Poker App

Page 28: Once Upon a Process

April 12, 2023 University of Virginia cs4414 28

Not on my machine,

muchachas!

Page 29: Once Upon a Process

April 12, 2023 University of Virginia cs4414 29

What Seems To Be Possible

Ok! Never turns on microphone.

Possibly Malicious PRK

Poker AppSome program execution turns on the microphone!Not sure…

let’s send it to NSA

just in case.

Page 30: Once Upon a Process

April 12, 2023 University of Virginia cs4414 30

Page 31: Once Upon a Process

April 12, 2023 University of Virginia cs4414 31

USENIX Security 2013 (click picture for talk video)

Page 32: Once Upon a Process

April 12, 2023 University of Virginia cs4414 32

What Is Actually Possible

Ok! Never turns on microphone.

Possibly Malicious PRK

Poker AppSome program execution turns on the microphone!Not sure…

let’s send it to NSA

just in case.

Page 33: Once Upon a Process

April 12, 2023 University of Virginia cs4414 33

The Good News!

May have been posted by malicious app, not US senator.

Page 34: Once Upon a Process

April 12, 2023 University of Virginia cs4414 34

How can preemptive multitasking

even be possible?!?

More bad news…?

Preemptive multi-taskingUser program X runs until the

supervisor decides to let another program run.

Page 35: Once Upon a Process

April 12, 2023 University of Virginia cs4414 35

Preemptive (?) Multitasking

Program A

Program B

Program C

A

B

A

Supervisor

Supervisor

Supervisor

A

Page 36: Once Upon a Process

April 12, 2023 University of Virginia cs4414 36

Page 37: Once Upon a Process

April 12, 2023 University of Virginia cs4414 37

Page 38: Once Upon a Process

April 12, 2023 University of Virginia cs4414 38

Interrupts

How frequently should the supervisor’s alarm clock (“kernel timer interrupt”) go off to check on the workers?

Page 39: Once Upon a Process

April 12, 2023 University of Virginia cs4414 39

My MacBook (Ubuntu)

bash-3.2$ uname -aDarwin 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_64bash-3.2$ gcc timer.c ; ./a.outkernel timer interrupt frequency is approx. 4016 Hz or higher

timer.c is a 50-line C program fromhttp://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)

Page 40: Once Upon a Process

April 12, 2023 University of Virginia cs4414 40

Timer Interrupts

A BSupervisor

set alarm clockswitch to program A

What makes the alarm clock ring?

Supervisor

set alarm clockswitch to program B

Supervisor

Page 41: Once Upon a Process

April 12, 2023 University of Virginia cs4414 41

Who interrupts the supervisor?

Page 42: Once Upon a Process

April 12, 2023 University of Virginia cs4414 42

The supervisor’s supervisor!

a.k.a. Hypervisor

Page 43: Once Upon a Process

April 12, 2023 University of Virginia cs4414 43

Support for hypervisor added to Intel x86 in 2005 (VT-x)

Page 44: Once Upon a Process

April 12, 2023 University of Virginia cs4414 44

More general (quite similar) idea in MULTICS (but with 8-levels of supervision in hardware by 1975)

Page 45: Once Upon a Process

April 12, 2023 University of Virginia cs4414 45

PS2: The Good Ole Shell

$ echo ‘Wha-hoo-wa!’$ !!

$ traceroute 128.143.22.36$ id -p ray$ !!$ fsck; !mount -u VA!