Writing Parallel software nro Threading Safety Anatomy of a process 4 main areas the code segment for the code of the executable the data segment for global variables the heap for dynamically allocated variables the stack for parameters of functions and local variables a collection of stack frames Heap Managed by programmer deepfunc Stack Managed by compiler bar Data segment foo Initialized when process starts Code segment Main Process Layout process mthonC+ 16/46 S.Ponce-CERN
Writing Parallel software 16 / 46 S. Ponce - CERN Intro Threading Safety Solutions process python C ++ Anatomy of a process 4 main areas the code segment for the code of the executable the data segment for global variables the heap for dynamically allocated variables the stack for parameters of functions and local variables a collection of stack frames Code segment Data segment Stack ... Heap Managed by programmer Managed by compiler Initialized when process starts Process Layout Main foo bar deepfunc
Writing Parallel software Intro Threading Sofety Solutices 花5 Threads Definition A lightweight process o with its own stack o sharing heap with other threads in the process Common Heap 44 个 个 deepfunc2 Stack Thread 2 bla deepfunc topfunc 2 Stack Thread 1 bar Data segment foo Code segment topfunc 1 Process with 2 threads peocess mthonC+ 17/46 S.Ponce-CERN
Writing Parallel software 17 / 46 S. Ponce - CERN Intro Threading Safety Solutions process python C ++ Threads Definition A lightweight process with its own stack sharing heap with other threads in the process Code segment Data segment Stack Thread 1 ... Stack Thread 2 ... Common Heap Process with 2 threads topfunc 1 foo bar deepfunc ... topfunc 2 bla deepfunc2