Computer Science 322 Quiz 6 Name__________________________- 1. When a new thread is created it begins execution at: a. The start of the main() b. the line of code following the procedure in the program call to create_thread() in which it was created. c. The start of the function specified in the call to create_thread(). 2. Consider the following code segment: int a = 0; |---> for (c = 0; c < 100000; c++) void xthread( | a = a + 1; int x, | int y) | } { | int c, d; --------- Suppose two threads are created and both run the function xthread which of the following BEST characterizes the sharing of data. a. The variable 'a' is shared b. 'a' and 'x' are shared but but both threads have private 'c' is private. copies of 'x' and 'c'. c. All five variables are shared d. all five variables are private. (i.e. if either thread changes one of them, the change is seen by the other thread. 3. Suppose the above function is run concurrently as 4 separate threads. After all threads complete the value of "a" will be: a. somewhat less than 400000 b. somewhat greater than 400000 or possibly even equal to or possibly even equal to 400000 400000 c. exactly 100000 d. exactly 400000 4. Describe how the following approach to providing mutual exclusion works or fails to work: Both processes have a "Process using Critical Section" flag. Before entering, a process sets its own flag and then loops until the other processes flag is clear. a. Not safe. b. Could cause starvation (livelock). c. Could cause deadlock. d. Causes strictly alternating access to critical section. e. Works correctly 5. In the unsafe version of the mutual exclusion algorithm the failure will occur: a. Every time a process is b. Regardless of whether or not preempted while trying to a process is preempted while enter the CS. trying to enter the CS. c. Only when a process has been preempted while trying to enter the CS.. but not necessarily every time this happens.