Date: September 2, 2024

Topic: Threads vs Processes

Recall

As modern CPUs have multi-cores, a process can be multi-threaded and thus require multiple execution contexts (multiple PCBs)

Notes

Threads and Concurrency

To take advantage of multi-CPU systems, a process needs to have multiple execution contexts

image.png

Threads

A thread is like a worker in a toy shop:


For multi-threaded processes:

Process vs Thread

Single threaded process (left) vs multi-threaded processes (right)

Single threaded process (left) vs multi-threaded processes (right)

Process:

Threads:


<aside> 📌 SUMMARY: Threads allow for multiple processes to be run concurrently, sharing some aspects like code while having different aspects like program counters, stack pointers etc

</aside>


Date: September 2, 2024

Topic: Multithreading

Recall

Multithreading allows for:

Notes

Benefits of Multithreading

While threads may be executing the same code, they may not be executing the exact same instruction at a single point in time, thus needing different program counter, stack pointer, etc





<aside> 📌 SUMMARY: Multi-threading can be beneficial due to shared address spaces, leading to lower memory overhead. Also as data needed by the different threads is more likely to be in processor cache, allowing for hotter caches

</aside>