SlideShare uma empresa Scribd logo
1 de 9
Baixar para ler offline
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
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
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
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
Why Multi-Task...?
● liveliness
● responsiveness
○ (to people)
● performance
○ (sometimes)
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
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
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
Break Out
● Exercises
○ https://github.com/RobertBurrellDonkin/kata-manycore-
threadsandthreads
● Try
○ On Windows
■ perfmon
■ typeperf
○ On Linux
■ vmstat
■ iostat
■ mpstat

Mais conteúdo relacionado

Mais procurados

Threads - Why Can't You Just Play Nicely With Your Memory_
Threads - Why Can't You Just Play Nicely With Your Memory_Threads - Why Can't You Just Play Nicely With Your Memory_
Threads - Why Can't You Just Play Nicely With Your Memory_
Robert Burrell Donkin
 

Mais procurados (19)

Linux NUMA & Databases: Perils and Opportunities
Linux NUMA & Databases: Perils and OpportunitiesLinux NUMA & Databases: Perils and Opportunities
Linux NUMA & Databases: Perils and Opportunities
 
Threads - Why Can't You Just Play Nicely With Your Memory_
Threads - Why Can't You Just Play Nicely With Your Memory_Threads - Why Can't You Just Play Nicely With Your Memory_
Threads - Why Can't You Just Play Nicely With Your Memory_
 
Mosix Cluster
Mosix ClusterMosix Cluster
Mosix Cluster
 
Presentation on flynn’s classification
Presentation on flynn’s classificationPresentation on flynn’s classification
Presentation on flynn’s classification
 
Zk meetup talk
Zk meetup talkZk meetup talk
Zk meetup talk
 
Event Driven with LibUV and ZeroMQ
Event Driven with LibUV and ZeroMQEvent Driven with LibUV and ZeroMQ
Event Driven with LibUV and ZeroMQ
 
Coal 16 mapping in Assembly Programming
Coal 16 mapping in Assembly ProgrammingCoal 16 mapping in Assembly Programming
Coal 16 mapping in Assembly Programming
 
L03
L03L03
L03
 
Flynn taxonomies
Flynn taxonomiesFlynn taxonomies
Flynn taxonomies
 
Flynn's classification
Flynn's classificationFlynn's classification
Flynn's classification
 
L04
L04L04
L04
 
Aca2 07 new
Aca2 07 newAca2 07 new
Aca2 07 new
 
Modeling & design multi-core NUMA simulator
Modeling & design multi-core NUMA simulatorModeling & design multi-core NUMA simulator
Modeling & design multi-core NUMA simulator
 
Lecture4
Lecture4Lecture4
Lecture4
 
SUZETTE TEGA(CHS-EDP)
SUZETTE TEGA(CHS-EDP)SUZETTE TEGA(CHS-EDP)
SUZETTE TEGA(CHS-EDP)
 
Userspace RCU library : what linear multiprocessor scalability means for your...
Userspace RCU library : what linear multiprocessor scalability means for your...Userspace RCU library : what linear multiprocessor scalability means for your...
Userspace RCU library : what linear multiprocessor scalability means for your...
 
Resource Management with Systemd and cgroups
Resource Management with Systemd and cgroupsResource Management with Systemd and cgroups
Resource Management with Systemd and cgroups
 
Transaction Process System and Recovery
Transaction Process System and RecoveryTransaction Process System and Recovery
Transaction Process System and Recovery
 
Aca2 01 new
Aca2 01 newAca2 01 new
Aca2 01 new
 

Destaque

A Java Fork_Join Framework
A Java Fork_Join FrameworkA Java Fork_Join Framework
A Java Fork_Join Framework
Hiroshi Ono
 
Concurrency in java
Concurrency in javaConcurrency in java
Concurrency in java
Abhra Basak
 
Coordinating non blocking io melb-clj
Coordinating non blocking io melb-cljCoordinating non blocking io melb-clj
Coordinating non blocking io melb-clj
Logan Campbell
 
Through the JMX Window
Through the JMX WindowThrough the JMX Window
Through the JMX Window
C2B2 Consulting
 
Bigtable
BigtableBigtable
Bigtable
nextlib
 
Tutorial4 Threads
Tutorial4  ThreadsTutorial4  Threads
Tutorial4 Threads
tech2click
 
Practiced agile developer with tdd & bdd
Practiced agile developer with tdd & bdd Practiced agile developer with tdd & bdd
Practiced agile developer with tdd & bdd
Sakares Saengkaew
 
Multi-core architectures
Multi-core architecturesMulti-core architectures
Multi-core architectures
nextlib
 

Destaque (20)

A Java Fork_Join Framework
A Java Fork_Join FrameworkA Java Fork_Join Framework
A Java Fork_Join Framework
 
What Your Jvm Has Been Trying To Tell You
What Your Jvm Has Been Trying To Tell YouWhat Your Jvm Has Been Trying To Tell You
What Your Jvm Has Been Trying To Tell You
 
Concurrency in java
Concurrency in javaConcurrency in java
Concurrency in java
 
Closures for Java
Closures for JavaClosures for Java
Closures for Java
 
Thousands of Threads and Blocking I/O
Thousands of Threads and Blocking I/OThousands of Threads and Blocking I/O
Thousands of Threads and Blocking I/O
 
Correct and efficient synchronization of java thread
Correct and efficient synchronization of java threadCorrect and efficient synchronization of java thread
Correct and efficient synchronization of java thread
 
Coordinating non blocking io melb-clj
Coordinating non blocking io melb-cljCoordinating non blocking io melb-clj
Coordinating non blocking io melb-clj
 
#JavaOne What's in an object?
#JavaOne What's in an object?#JavaOne What's in an object?
#JavaOne What's in an object?
 
Through the JMX Window
Through the JMX WindowThrough the JMX Window
Through the JMX Window
 
Reactive Principles and Microservices
Reactive Principles and MicroservicesReactive Principles and Microservices
Reactive Principles and Microservices
 
Lecture on Java Concurrency Day 3 on Feb 11, 2009.
Lecture on Java Concurrency Day 3 on Feb 11, 2009.Lecture on Java Concurrency Day 3 on Feb 11, 2009.
Lecture on Java Concurrency Day 3 on Feb 11, 2009.
 
IT MATCH: Vastgoedfinanciering voor zelfstandigen / freelancers in België
IT MATCH: Vastgoedfinanciering voor zelfstandigen / freelancers in BelgiëIT MATCH: Vastgoedfinanciering voor zelfstandigen / freelancers in België
IT MATCH: Vastgoedfinanciering voor zelfstandigen / freelancers in België
 
JVM Memory Management Details
JVM Memory Management DetailsJVM Memory Management Details
JVM Memory Management Details
 
Java Memory Consistency Model - concepts and context
Java Memory Consistency Model - concepts and contextJava Memory Consistency Model - concepts and context
Java Memory Consistency Model - concepts and context
 
Threads in Java
Threads in JavaThreads in Java
Threads in Java
 
Bigtable
BigtableBigtable
Bigtable
 
JAVA NIO
JAVA NIOJAVA NIO
JAVA NIO
 
Tutorial4 Threads
Tutorial4  ThreadsTutorial4  Threads
Tutorial4 Threads
 
Practiced agile developer with tdd & bdd
Practiced agile developer with tdd & bdd Practiced agile developer with tdd & bdd
Practiced agile developer with tdd & bdd
 
Multi-core architectures
Multi-core architecturesMulti-core architectures
Multi-core architectures
 

Semelhante a Many Cores Java - Session One: Threads and Threads

High-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringHigh-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uring
ScyllaDB
 

Semelhante a Many Cores Java - Session One: Threads and Threads (20)

An End to Order (many cores with java, session two)
An End to Order (many cores with java, session two)An End to Order (many cores with java, session two)
An End to Order (many cores with java, session two)
 
An End to Order
An End to OrderAn End to Order
An End to Order
 
Operating System.pdf
Operating System.pdfOperating System.pdf
Operating System.pdf
 
Threads and processes
Threads and processesThreads and processes
Threads and processes
 
Class 1
Class   1Class   1
Class 1
 
Linux Locking Mechanisms
Linux Locking MechanismsLinux Locking Mechanisms
Linux Locking Mechanisms
 
PyCon Canada 2019 - Introduction to Asynchronous Programming
PyCon Canada 2019 - Introduction to Asynchronous ProgrammingPyCon Canada 2019 - Introduction to Asynchronous Programming
PyCon Canada 2019 - Introduction to Asynchronous Programming
 
Lec 9-os-review
Lec 9-os-reviewLec 9-os-review
Lec 9-os-review
 
Efficient Buffer Management
Efficient Buffer ManagementEfficient Buffer Management
Efficient Buffer Management
 
Functional? Reactive? Why?
Functional? Reactive? Why?Functional? Reactive? Why?
Functional? Reactive? Why?
 
Realtime
RealtimeRealtime
Realtime
 
Threads - Why Can't You Just Play Nicely With Your Memory?
Threads - Why Can't You Just Play Nicely With Your Memory?Threads - Why Can't You Just Play Nicely With Your Memory?
Threads - Why Can't You Just Play Nicely With Your Memory?
 
General Purpose GPU Computing
General Purpose GPU ComputingGeneral Purpose GPU Computing
General Purpose GPU Computing
 
Concurrency, Parallelism And IO
Concurrency,  Parallelism And IOConcurrency,  Parallelism And IO
Concurrency, Parallelism And IO
 
Linux Internals - Part II
Linux Internals - Part IILinux Internals - Part II
Linux Internals - Part II
 
Linux-Internals-and-Networking
Linux-Internals-and-NetworkingLinux-Internals-and-Networking
Linux-Internals-and-Networking
 
High-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringHigh-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uring
 
Optimizing Linux Servers
Optimizing Linux ServersOptimizing Linux Servers
Optimizing Linux Servers
 
Keeping Latency Low and Throughput High with Application-level Priority Manag...
Keeping Latency Low and Throughput High with Application-level Priority Manag...Keeping Latency Low and Throughput High with Application-level Priority Manag...
Keeping Latency Low and Throughput High with Application-level Priority Manag...
 
Operating System concepts
Operating System conceptsOperating System concepts
Operating System concepts
 

Mais de Robert Burrell Donkin

If the Data Cannot Come To The Algorithm...
If the Data Cannot Come To The Algorithm...If the Data Cannot Come To The Algorithm...
If the Data Cannot Come To The Algorithm...
Robert Burrell Donkin
 

Mais de Robert Burrell Donkin (9)

Threads and Threads
Threads and ThreadsThreads and Threads
Threads and Threads
 
If the Data Cannot Come To The Algorithm...
If the Data Cannot Come To The Algorithm...If the Data Cannot Come To The Algorithm...
If the Data Cannot Come To The Algorithm...
 
If the data cannot come to the algorithm...
If the data cannot come to the algorithm...If the data cannot come to the algorithm...
If the data cannot come to the algorithm...
 
Apache Maven In 10 Slides
Apache Maven In 10 SlidesApache Maven In 10 Slides
Apache Maven In 10 Slides
 
XP In 10 slides
XP In 10 slidesXP In 10 slides
XP In 10 slides
 
Public Sector: Agile and Open Source
Public Sector: Agile and Open SourcePublic Sector: Agile and Open Source
Public Sector: Agile and Open Source
 
An Agile Pick-N-Mix
An Agile Pick-N-MixAn Agile Pick-N-Mix
An Agile Pick-N-Mix
 
The Pomodoro Technique: Introduced Unofficially In 10 Slides
The Pomodoro Technique: Introduced Unofficially In 10 SlidesThe Pomodoro Technique: Introduced Unofficially In 10 Slides
The Pomodoro Technique: Introduced Unofficially In 10 Slides
 
Retrospectives In 10 Slides (With Notes)
Retrospectives In 10 Slides  (With Notes)Retrospectives In 10 Slides  (With Notes)
Retrospectives In 10 Slides (With Notes)
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

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
  • 5. Why Multi-Task...? ● liveliness ● responsiveness ○ (to people) ● performance ○ (sometimes)
  • 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