How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking
Transcript of How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking
![Page 1: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/1.jpg)
Today
Brief review of last time.How computers manage memory.How computers multitask.
![Page 2: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/2.jpg)
D Flip Flop
![Page 3: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/3.jpg)
Try completing this for D F-FDATA WRITE MEMORY
(previous)MEMORY
0 0 00 0 10 1 00 1 11 0 01 0 11 1 01 1 1
![Page 4: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/4.jpg)
Multiplexer
![Page 5: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/5.jpg)
Demultiplexer
![Page 6: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/6.jpg)
Mini-CPU
![Page 7: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/7.jpg)
What is a program?
A program is a sequence of binary numbers -- instructions.
Each bit of each instruction corresponds to a control line in a programmable circuit (e.g. Pentium processor).
![Page 8: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/8.jpg)
Different CPUs have different machine languages
Intel PentiumPower PCPalmpilot, etc.
“Backwards Compatibility” – Pentium 4’s machine language extends Pentium 2’s machine language
Machine languages now allow complicated calculations (eg for multimedia, graphics) in a single instruction
![Page 9: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/9.jpg)
How to streamline your life (lessons from computer architecture).
COS 1164/3/2006Instructor: Umar Syed
![Page 10: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/10.jpg)
The Tired Librarian
1000 checkouts/returns per dayDistance covered = 1000 x 100ft = 100,000 ft ~ 20 milesPlease help!!!
Reserves
100 ft roundtrip
![Page 11: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/11.jpg)
80-20 “Rule”
Pareto [1906]: 20% of the people own 80% of the wealth
Juran [1930’s]: 20% of the organization does 80% of the work
![Page 12: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/12.jpg)
Better Arrangement
Distance covered per day?(80% x 1000 x 10 ft) + (20% x 1000 x 100 ft) = 28,000 ft
Reserves
“Most popular” shelf: 20% most popular books
10 ftroundtrip
100 ft roundtrip
![Page 13: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/13.jpg)
Even better arrangement
Distance covered per day?(80% x 80% x 1000 x 0 ft) + (20% x 80% x 1000 x 10 ft) + (20% x 1000 x 100 ft) = 21,600 ft
ReservesBooks in the 5th to 20th percentile of popularity
5 ftroundtrip
100 ft roundtrip
Top 4%(i.e. 20% of 20%)
![Page 14: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/14.jpg)
Librarian arrangementReservesDisk
Books in the 5th to 20th percentile of popularityMemory
CacheTop 4%CPU
Computer
Often, today’s computers have even more levels of caching
![Page 15: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/15.jpg)
New and improved
![Page 16: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/16.jpg)
Class Discussion
Is problem solved?
![Page 17: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/17.jpg)
How to predict the most popular memory locations?It’s not easy, because:
Popularity is dynamic.Difficult to predict what a program will do in the future.
Remember the halting problem!Not a lot of time to make predictions.
![Page 18: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/18.jpg)
Computer programs typically exhibit…
Temporal locality“If a memory location is accessed now, it will be accessed again in the near future.”
Spatial locality“If a memory location is accessed now, nearby locations will be accessed in the near future.”
![Page 19: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/19.jpg)
Temporal and spatial locality?
sum 0for i = 1 to n{sum sum + A[i]
}avg sum / n
![Page 20: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/20.jpg)
Simple rules for managing the cache
When accessing a memory location:Bring that location into the cache.Bring nearby locations into the cache.
When the cache gets full:Remove the memory location that was Least Recently Used.
![Page 21: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/21.jpg)
Delay vs. cost of various memories
Cost: $ / GB
Delay: CPU cycles/byte
Hard drive < 1 > 100,000
RAM 200 50-100
Cache 80,000 1
![Page 22: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/22.jpg)
Moral
Performance:Speed is close to that of fastest memory (cache)Overall capacity is that of largest memory (disk)
![Page 23: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/23.jpg)
Virtual Memory
![Page 24: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/24.jpg)
Recall: Compilation
X Y + Z
↕ADD 10 11 12
↕
100 1010 1011 1100
1. Human writes this.
2. “Add contents of Location 11 and 12, and store result in Location 10”
X in Location 10Y in Location 11Z in Location 12
3. Convert to binary
![Page 25: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/25.jpg)
Question:
Program 1 Program 2X Y + Z
↕ADD 10 11 12
↕
100 1010 1011 1100
A B + C
↕ADD 10 11 12
↕
100 1010 1011 1100
What if two programs choose the same memory locations???
![Page 26: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/26.jpg)
Virtual Memory
Program 1 Program 2
Program 1’s view of memory
Program 2’s view of memory:
Program 2
RAM:
Program 1
Virtual memory manager handles the translation.
![Page 27: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/27.jpg)
Virtual Memory
Program 1a
Program 1b
Program 1’s view of memory
Program 1a
RAM
Virtual memory manager also handles RAM-to-HD caching!
Program 1b
Hard Drive
Swap as needed
![Page 28: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/28.jpg)
Program’s view:
Underlying truth:
Virtual Memory
PowerpointMemory:
Address 0 Address 264 - 1
Lec15.ppt P ≠ NP.ppt
![Page 29: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/29.jpg)
Multitasking
“The Multitasking Generation”
![Page 30: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/30.jpg)
An Evening’s Tasks for a Gen-M’er
HomeworkListen to musicInstant MessagingCall Mom (goes to bed by 11 PM!)Answer phoneRead a bit more of Joyce’s UlyssesWatch the Daily Show
How do you do it all?
![Page 31: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/31.jpg)
How does a CPU multitask?
Answer: It doesn’t!
Powerpoint Powerpoint
iTunesWeb browser
Time
Programs
![Page 32: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/32.jpg)
Scheduler’s objectives
FairnessTimelinessCritical tasks processed promptlyLow overhead
Class Discussion: How can one achieve these (often conflicting) goals?
![Page 33: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/33.jpg)
Tasks done by my PC last night
Word processingPlay CDDownload news updatesDownload emailRun clockHidden tasks: handle network traffic, manage disk and RAM traffic, scheduler, etc.
Managed by “Operating System”(WinXP, Linux, MacOS, etc.)
![Page 34: How to streamline your life. (Lessons from computer ... · Lec15.ppt P ≠NP.ppt. Multitasking](https://reader031.fdocuments.in/reader031/viewer/2022020305/5cf7d19a88c9933f408c27de/html5/thumbnails/34.jpg)
Bonus reading (in the “Extras” section): Proof of the halting problem, written in Dr. Seuss rhyme.Please pick up your graded lab reports.