Due: Monday, November 20, 2017, 11:00 am (Session A) 1:00 pm (Session B) (start of the class)

  1. Download hw10_question1.c. Familiarize yourself with it, run it, and answer these questions:
    1. Explain in one short sentence what the function does.
    2. Which thread joins the main thread first?
  2. Download hw10_question2.c. The goal is to give each thread a number (my_num). There is a global variable sum, we are trying to get it to be 10. Threads can add their numbers to the global variable if they will bring it closer to 10 or to 10, but not if they will bring it over 10. Familiarize yourself with it, run it, and answer these questions:
    1. What can go wrong if we use thread_sum10_A?
    2. What can go wrong if we use thread_sum10_B?
    3. Write a version of thread_sum10 that does work.

    © 2017 Ying Li. Page last modified: .