Question: Question 2 (7 points): Consider the following snippet of coded logic: pid = fork() /* We are calling system call fork(). The value returned by
Question 2 (7 points): Consider the following snippet of coded logic: pid = fork() /* We are calling system call fork(). The value returned by fork() is stored in variable pid. */ if (pid == 0) { /* If the value of variable pid is equal to 0, then the next 2 instructions will be executed. */ fork() /* Here we are calling system call fork() again. */ thread_create( . . .) /* Here we are calling a function that creates a thread, which in turn simply calculates and displays the first 10 Fibonacci numbers. */ } fork() /* Here we are calling system call fork() again. */ a) How many processes are created, including the original process? b) How many times is the thread_create() function invoked? Answer: Question 3 (6 points): Describe the circumstances under which it is advisable to use each of the following synchronization tools. You may want to consider how long a lock will be held, if the processes are running on a multi-processor machine, and any other factors which you may find to relevant. a) spinlocks b) mutex locks c) counting semaphores Answer:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
