class: title # Locks and Locked Data Structures ## CSC 213 – October 12, 2026 --- # Agenda for Today 1. Department Events 1. Upcoming Work 1. Locks Discussion 1. Exercise 1. Wrap Up --- # Department Events ## CS Table: Applying CS Methods to Other Fields .indent[ Tuesday, October 13th at noon in the CS Commons ] *To receive a token, send an email to let me know you attended no more than 48 hours after the event.* --- class: section, blue # Upcoming Work --- # Assignment: Filesystem Integrity **Due:** Monday, October 12th by 11:59pm **Late Deadline:** Wednesday, October 14th by 10:00am ## Questions **Are we assuming something like `fsck` is running when we describe the recovery process?** Sort of. Explain how a tool like `fsck` could restore the filesystem to a consistent state. Your explanation doesn't have to match exactly what `fsck` would do. You can also ignore the task of detecting the exact error that has occured; you only need to describe the recovery process, not the checking to detect an inconsistent state. --- # Lab: Worm **Due:** Wednesday, October 14th by 11:59pm **Late Deadline:** Monday, October 26th by 11:59pm ## Questions _No new questions since last class._ --- class: section, blue # Locks --- # Discussion: Locks **Questions for think, pair, share:** The following questions refer to the two thread functions below, which run concurrently. ```c int x = 0; int y = 0; ``` .left-col[ ```c void* thr1(void* arg) { if (x == 0) y = 1; return NULL; } ``` ] .right-col[ ```c void* thr2(void* arg) { if (y == 0) x = 1; return NULL; } ``` ] 1. What values of `x` and `y` are possible after both threads have finished? 2. An execution of a parallel program is *"serializable"* if its output could have resulted from running the threads sequentially instead of concurrently. Does the program above always run in a serializable fashion? *Start by thinking of answers on your own. I will let you know when to start discussion.* --- class: section, green # Locks Exercise --- class: section, blue # Wrap Up --- # Reminders ## Upcoming Deadlines - **Filesystem Integrity Assignment:** due tonight, or Wednesday morning with a token - **Worm Lab:** due Wednesday, or Monday after break with a token ## Need help? Use your resources! - Book an appointment during office hours - Attend mentor office hours - Review slides, readings, and other course resources - Use tools like `gdb` and AddressSanitizer to catch and diagnose issues ## Reading - **Condition Variables** (OSTEP, Chapter 30) - **Semaphores** (OSTEP, Chapter 31)