class: title # Concurrency with Threads ## CSC 213 – October 9, 2026 --- # Agenda for Today 1. Department Events 1. Upcoming Work 1. Threads Discussion 1. Threads Exercise 1. Wrap Up --- # Department Events ## CS Table: Topic TBD? .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 _No new questions since last class._ --- # 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 # Threads --- # Discussion: Concurrency Basics **Questions for think, pair, share:** 1. How are threads different from the tasks we are implementing in the worm lab? 2. What makes programming with threads difficult? 3. Why would we want to write programs that use threads? *Start by thinking of answers on your own. I will let you know when to start discussion.* --- # Discussion: Threads API Work with your neighbor(s) to answer the following questions about the threads API. You may find it helpful to refer to the `man` pages or the Threads API reading for today. 1. What does `pthread_create` do, and how does it use each of its parameters? What does the return value indicate? ```c int pthread_create(pthread_t *restrict thread, const pthread_attr_t *restrict attr, void *(*start_routine)(void *), void *restrict arg); ``` 2. What does `pthread_join` do, and how does it use each of its parameters? What does the return value indicate? ```c int pthread_join(pthread_t thread, void **retval); ``` --- class: section, green # Threads Exercise --- class: section, blue # Wrap Up --- # Reminders ## Upcoming Deadlines - **Filesystem Integrity Assignment:** due next Monday, or Wednesday morning with a token - **Worm Lab:** due next 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 - **Locks** (OSTEP, Chapter 28) - **Lock-based Concurrent Data Structures** (OSTEP, Chapter 29)