Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallelism Revisions #43

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
shorten pre-existing example
  • Loading branch information
jespiron committed Jan 10, 2025
commit 6ea3a8a851c83b7a027f32b417bf90c0dc0e65e6
58 changes: 33 additions & 25 deletions week10/slides.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,25 @@ paginate: true

We divide tasks among workers.

* In hardwareland, we call these workers **processors** or **cores**.
* In hardwareland, we call these workers **processors** and **cores**.

* In softwareland, <!-- "we give these workers a different name" -->
* "Processors/CPUs" => Processes
* "Processors" => Processes
* "Cores" => Threads

* **Key difference:** Parallelism utilizes **multiple** processors/cores
* Some concurrency models don't!


<!-- Note:

Students coming from 122 may be unfamiliar with hardware terminology,
so I added this to clarification.

Alternate suggestion is to replace all instances of "cores / processors"
with "threads / processes"
Students coming from 122 may be unfamiliar with processors/cores,
so I added this for clarification.

Alternate suggestion is to remove mention of hardware,
so that this slide is shortened to
"Examples of workers:
* Processes
* Threads"
-->


Expand All @@ -73,47 +75,53 @@ with "threads / processes"
---


# Parallelism vs. Concurrency (Examples)
# Parallelism vs. Concurrency: Examples
<div class="columns">
<div>

## Parallelism

* Have one processor work on loading the webpage, while another updates the progress bar
* Processing 100x100px regions of an image on each core
* 8 cores, 8 threads
* 4 threads load the webpage, 4 threads update the progress bar

</div>
<div>

## Concurrency
## Alternate Concurrency Model

* 1 core, 1 thread
* When blocked on loading the webpage, update the progress bar
Comment on lines +92 to +93
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of our students will not really understand what "blocked on loading the webpage" means. Do you think you could come up with another example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was @jurplel’s example, reworded
His slide originally had two examples (loading webpage, image processing)

How about the second example?

One thread switches between each image region

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • As we load a webpage, take a break sometimes to update the loading progress bar

I think it is important to spell out what exactly "blocked" means here, at least the first time we bring it up


* One core
* As we load a webpage, take a break sometimes to update the loading progress bar
* Often used to do other things while we wait for blocking I/O operations
* e.g. Running garbage collection while we wait for a response over the network

</div>
</div>


---


# Today: Parallelism
- Threads
- Synchronization
- Message Passing
- `Send` and `Sync`
- More Synchronization
- Multithreading
- Interprocess Communication
- Shared Memory
- Synchronization
- Message Passing
- `Send` and `Sync`


---


# Terminology: Threads

* Dangerously overloaded term—can mean one of many things
* For this lecture, we define it as a "stream of instructions"
* In Rust, language threads are 1:1 with OS threads
* **Key point:** Threads share the same resources
For this lecture, we define it as a "stream of instructions"

<!--Speaker note:

Emphasize that "thread" is overloaded term
In Rust, language threads are 1:1 with OS threads

-->

---

Expand Down