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 the 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));
The Output should look like this:
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
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