Save this video free

ECE344 Fall 2026 (Sec 1) Lec 20 - Parallelization Example

Jon Eyolfson · 38:10 · Watch on YouTube

ECE344 Fall 2026 (Sec 1) Lec 20 - Parallelization Example Watch on YouTube →

Overview

Jon Eyolfson uses a bank simulation with 10 million transfers and eight pthreads to show why parallelization requires more than dividing work: shared random-number generation can serialize threads, and unsynchronized account balances create data races. The example develops per-account mutexes, explains transaction-level locking and deadlocks, then uses try-lock retries or consistent account-ID lock ordering to coordinate transfers safely; Eyolfson also reviews likely Test 2 topics.

Key takeaways

Chapters

0:00 Bank Simulation Setup and Serial Baseline
3:14 Eight Threads Expose Work-Partitioning and rand() Bottlenecks
14:20 rand_r() Removes Shared RNG State, but Balances Still Race
18:20 Per-Account Mutexes and Atomic Transfer Transactions
23:53 trylock() Retry Logic and the Same-Account Deadlock
31:11 Account-ID Ordering Prevents Circular Wait
34:08 Test 2 Review: Synchronization, Virtual Memory, and Labs

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

1:59 Mhm. >> Alrighty, welcome back to operating

3:08 systems. Today, lots of slides to get through. So, let's go for it. So, we are running a bank. Joy, this is the setup for it. We're going to do 10 million transfers. So, we have a simulation or I have a simulation that can create a varying number of accounts given by a command line argument. Each account has a unique ID associated with it and a balance. And the balance starts at $8,000. We are going to generate transfers between two random accounts where each one transfers 10% of its current balance to the other. And in order to make the numbers fun when I actually run it, They must call this securely connect to bank function

3:54 before starting their transfer. That's it. That's the whole slides. So, the rest of it is coding example. It's going to be fun. We're going to run a giant bank and you are going to run it, not me, cuz you're going to run you're going to tell me what to write. I am just I'm just the conduit. So, this is the setup. So, we have a few defines here starting balance of $1,000 or 10 transfers. We are going to write this using eight threads. So, ideally, if we want to get our promotion and not get fired, uh we want to go eight times faster. So, here is our struct for an account. It has an ID associated with it and then a balance. Then, I have an array of accounts here and a variable for the number of

4:43 accounts, since it's just an array. And then I have the securely connect to bank function, which I'm not going to show you. Then, there's this transfer function. So, this takes two accounts, an account

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

Related notes

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Jon Eyolfson.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.