Many Cores Java - Session One: Threads and Threads

387 views

Published on

Aims to introduce some basic concurrency design concepts by starting with a single core. Takes a top down approach. If you're looking for a guide to implementation, read anything and everything written by Doug Lea. Exercises available at https://github.com/RobertBurrellDonkin/kata-manycore-threadsandthreads

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

  • Be the first to like this

No Downloads
Views
Total views
387
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Many Cores Java - Session One: Threads and Threads

  1. 1. Threads and Threadssession onestarting with a single corecopyright 2013 Robert Burrell Donkin robertburrelldonkin.namethis work is licensed under a Creative Commons Attribution 3.0 Unported License
  2. 2. Threads, Threads and Processesfrom the● hardware perspective○ a thread is a serial code sequence● software perspective○ a thread abstracts a serial code sequence● operating system perspective○ a process abstracts an application instance
  3. 3. Multi-tasking a Single Core● on a single core○ a multitasking operating system■ uses scheduling■ to create the illusion of parallelism● a software platform may also○ use scheduling to create the illusion of parallelism○ but then this is more often called multi-threading
  4. 4. Approaches to Multi-Tasking● cooperative (or voluntary) multi-tasking○ time-sharing○ background processing○ early Apple PCs○ now rarely used● pre-emptive multi-tasking○ time-slicing○ Windows 95 PCs○ now almost universal
  5. 5. Why Multi-Task...?● liveliness● responsiveness○ (to people)● performance○ (sometimes)
  6. 6. Context Switch● a context switch○ stores the current execute state, and○ restores an execution state from storage● from a CPU perspective○ this is an expensive operation● but is often cheap in comparison
  7. 7. Caches, Caches, Caches● Moores Law○ the number of transistors doubles every 2 years● but○ diminishing returns from longer pipelines○ popularity of multi-tasking● so more and bigger caches● so context switching cost now usually low● but scales in a non-linear fashion● excessive context switching expensive
  8. 8. Pre-emptive multi-tasking operatingsystems use involuntary contextswitching to provide the illusion ofparallel processes even when thehardware supports only a single threadof execution.Take Away
  9. 9. Break Out● Exercises○ https://github.com/RobertBurrellDonkin/kata-manycore-threadsandthreads● Try○ On Windows■ perfmon■ typeperf○ On Linux■ vmstat■ iostat■ mpstat

×