Question: Using C++ solving two critical sections. First, create three processes. These three processes will execute two functions, each with a critical section. Print out the

Using C++ solving two critical sections. First, create three processes. These three processes will execute two functions, each with a critical section. Print out the process ID of the process in control of each critical section.

Function 1: in the critical section, iterate a counter from 1-10 print out the value of each counter for each iteration on the same line. Outside the critical section, sleep for one-second use this code : std::this_thread::sleep_for(std::chrono::seconds(1));

Function 2: in critical section, spell out the letters of the alphabet, printing out each letter on the same line separated. Outside the critical section, sleep for one-second use this code : std::this_thread::sleep_for(std::chrono::seconds(1));

Sample:

Process 1001 counting to 10: 1 2 3 4 5 6 7 8 9 10

Process 1002 counting to 10: 1 2 3 4 5 6 7 8 9 10

Process 1003 counting to 10: 1 2 3 4 5 6 7 8 9 10

Process 1001 spelling the alphabet: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Process 1002 spelling the alphabet: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Process 1003 spelling the alphabet: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

process p1 completed

process p2 completed

process p3 completed

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!