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
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Many Cores Java - Session One: Threads and Threads
1. Threads and Threads
session one
starting with a single core
copyright 2013 Robert Burrell Donkin robertburrelldonkin.name
this work is licensed under a Creative Commons Attribution 3.0 Unported License
2. Threads, Threads and Processes
from 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. 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. 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
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. Caches, Caches, Caches
● Moore's 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. Pre-emptive multi-tasking operating
systems use involuntary context
switching to provide the illusion of
parallel processes even when the
hardware supports only a single thread
of execution.
Take Away
9. Break Out
● Exercises
○ https://github.com/RobertBurrellDonkin/kata-manycore-
threadsandthreads
● Try
○ On Windows
■ perfmon
■ typeperf
○ On Linux
■ vmstat
■ iostat
■ mpstat