Investigate the order in which several threads are scheduled to execute with an example C++ program. Observe that the threads may execute in a different order each time the program runs.
- [Olivia] To demonstrate how scheduling … can impact execution, we've written the C++ program … that executes two threads named Barron and Olivia, … that continuously traps vegetables for about one second. … The vegetable chopper function on line nine, … takes in a string argument for a name of which can be used … to uniquely identify this thread. … The function begins by initializing a local variable … on line 10 to count the number of vegetables … this thread chops. … The while loop on line 11 will execute … as long as the Boolean chopping variable … that we initialized on line seven is true. … And with each loop iteration, … it increments the value … of the local vegetable count variable. … Finally, after the while loop finishes, … the vegetable chopper function … prints out how many total vegetables … it chopped on line 14. … Down in the main function on lines 18 and 19, … we create two threads … to execute the vegetable chopper function … and pass in additional arguments … which are the strings Barron and Olivia …
- Parallel computing architectures
- Shared vs. distributed memory
- Thread vs. process
- Execution scheduling
- The thread lifecycle in C++
- Mutual exclusion
- Locking in recursive and shared mutexes
- Acquiring a lock on a mutex with a try lock
- Resolving deadlock and livelock conditions
Skill Level Advanced
1. Parallel Computing Hardware
2. Threads and Processes
3. Mutual Exclusion
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.