Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions