Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q3. Consider the following code fragment: 1 pid_t pid; 2 pid = fork(); 3 if (pid == 0) { /* child process */ 4 fork();
Q3. Consider the following code fragment: 1 pid_t pid; 2 pid = fork(); 3 if (pid == 0) { /* child process */ 4 fork(); thread_create (...); 6 } 7 fork(); Answer the following questions and explain (or show how you arrived at) your answer. A) How many unique processes are running after line 7? B) How many threads are created? Q4. Describe the requirements that a solution to the critical section problem must have. Q5. Explain why implementing synchronization primitives by disabling interrupts is not appropri- ate in a single-processor system if the synchronization primitives are to be used in user-level programs. Q6. Assume that a system has multiple processing cores. For each of the following scenarios, describe which is a better locking mechanisma spinlock or a mutex lock where waiting processes sleep while waiting for the lock to become available: The lock is to be held for a short duration. The lock is to be held for a long duration
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started