Software & Hardware Basics

advertisement
Introduction to Concurrent Programming
Software & Hardware Basics
Slides by: Ofer Givoli
Based on:
The art of multiprocessor programming
Maurice Herlihy and Nir Shavit, 2008
•
•
Appendix A – Software Basics
Appendix B – Hardware Basics
1
Lets get to know ourselves 
• MAMAS?
• Java?
• C#?
• Remember threads/synchronization?
2
Hardware Basics
3
From: https://software.intel.com/en-us/articles/optimizing-applications-for-numa
4
CPU
Speed:
Size:
Cost:
Power:
L1
Cache
L2
Cache
Fastest
Smallest
Highest
Highest
L3
Cache
Memory
(DRAM)
Slowest
Biggest
Lowest
Lowest
From: Computer Structure 2014 slides, by Lihu Rappoport and Adi Yoaz (modified)
5
Processor 1
Processor 2
L1 cache
L1 cache
L2 cache (shared)
Memory
From: Computer Structure 2014 slides, by Lihu Rappoport and Adi Yoaz
6
SMP (symmetric multiprocessing)
NUMA (Non-uniform memory access)
From: The art of multiprocessor programming, by Maurice Herlihy and Nir Shavit, 2008 (modified)
7
Cache Coherence
From: The art of multiprocessor programming, by Maurice Herlihy and Nir Shavit, 2008 (modified)
8
Spinning
SMP
NUMA
From: The art of multiprocessor programming, by Maurice Herlihy and Nir Shavit, 2008 (modified)
9
Multi-Core and Multi-Threaded Architectures
• Reordering reads-writes to memory
• Memory barrier
• Volatile variables in Java
From: The art of multiprocessor programming, by Maurice Herlihy and Nir Shavit, 2008 (modified)
10
Software Basics
11
Threads
12
…
13
14
Monitors
Monitor model (built-in)
Lock + Wait set
Waiting
-> Runnable -> Running
15
From: The art of multiprocessor programming, by Maurice Herlihy and Nir Shavit, 2008 (modified)
16
Yielding and Sleeping
• yield()
• sleep(t)
17
Thread-Local Objects
From: The art of multiprocessor programming, by Maurice Herlihy and Nir Shavit, 2008 (modified)
18
Thanks!
19
Download