
Understanding Threads in Process Memory Architecture
Explore the concept of threads in process memory architecture, their concurrent execution, memory sharing, and the challenges of multi-threaded programming. Learn about stack, heap, static memory, and how threads can break code execution. Discover the intricacies of moving data between threads and the impact of race conditions in multithreaded environments.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Processs memory architecture Stack Created with new or malloc Free Memory Heap Static
A thread allows for concurrent execution in same process Stack Stack Stack pthread_create() std::thread() Thread1 Thread2 Free Memory Heap Heap Static Static
Threads in a process share a memory space Each thread has its own PC and stack Either thread can access heap/static space One thread could access another thread s stack variables if it could locate them Each thread is independently schedulable Stack Stack Thread1 Thread2 Heap Static
Lets code Start small What is this going to do? Any guesses?
Lets code How far can we push this Let s access some stack variables Lets access some heap variables Now do it from to threads Can we break things? Any odd behavior you observe Can we pass in a method pointer? What about a lambda or functor?
Lets code Why were we able to break it? 1. A line of source makes man lines of assembly 2. What if several threads multi-tasked this code?
Linux can show us thread details std::thread is built on top of pthreads
How do we move data between threads? We really don t have to All memory is shared and we simply use it Race conditions are real and significant More lectures to come on this topic