class: title # Locks and Locked Data Structures ## CSC 213 – October 15, 2025 --- # Agenda for Today 1. Department Events 2. Upcoming Work 3. Locks 4. Thread and Lock Exercises 5. Wrap Up --- # Department Events ## CS Extra: Graduate School in CS .indent[ Thursday, October 16th at 4:15pm in Noyce 3821 Refreshments available at 4pm in the CS Commons ] *To receive 0.25% extra credit, send an email to let me know you attended no more than 48 hours after the event.* --- class: section, blue # Upcoming Work --- # Lab: Worm **Due:** Wednesday, October 15th by 11:59pm **Late Deadline:** Wednesday, October 29th by 11:59pm ## Questions **The last test program doesn't work, but my scheduler can run the worm game. What's going on?** This one has us all stumped. If the worm game works and there are no AddressSanitizer issues you probably don't need to worry about the last test case. I'll be interested to hear what's causing this if anyone figures it out. --- 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 ## Lab The worm lab is due tonight for full credit, or the Wednesday after break if you are willing to take the late deduction. Make sure the scheduler works for the worm game, including a clean exit when you crash. ## Assignment There is no assignment this week ## Need Help? My office hours are limited this week (sorry), but I can still answer questions over email and mentor sessions are available on the regular schedule. ## Reading *No reading for the next class.*