What will be the possible outputs for the following program before the lines a, band c? Format your answer this way: Line a: " Outputis) here Line b N Outputis) here Line c N Outputis) here Sinclude ciostream sinclude

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter1: Fundamentals Of C++ Programming
Section1.3: Preliminary Three: Software Development
Problem 3E: (Electrical eng.) You’ve been asked to write a program that outputs the following specifications:...
icon
Related questions
icon
Concept explainers
Question
Question 11
What will be the possible outputs for the following program before the lines a, b and c? Format your answer this way:
Line a:
/ Output(s) here
Line b:
/ Output(s) here
Line c:
/ Output(s) here
#include <iostream>
#include <thread
#include <mutex>
using namespace std;
mutex ml;
mutex m2;
void funcAO {
for (int i = 0; i < 3; i++)
cout <« i;
void funcB) {
unique_lockmutex> 1(m1);
for (int i = 6; i < 9; i++){
if (i == 8)
return;
cout <« i;
void funcC) {
m2. lock();
for (int i = 3; i < 6; i+)
cout << i;
int main () {
thread th1(funcA);
thread th2(funcA);
th1.join(); th2. join(); // a
thread th3(funcB);
thread th4(funcB);
th3. join(); th4.join(); // b
thread th5(funcC);
thread th6(funcc);
th5. join(); th6.join(); // c
return 0;
Edit Vlew Insert Format Tools Table
Paragraph v B I U A 2 Tiv|
四
To B
12ptv
Transcribed Image Text:Question 11 What will be the possible outputs for the following program before the lines a, b and c? Format your answer this way: Line a: / Output(s) here Line b: / Output(s) here Line c: / Output(s) here #include <iostream> #include <thread #include <mutex> using namespace std; mutex ml; mutex m2; void funcAO { for (int i = 0; i < 3; i++) cout <« i; void funcB) { unique_lockmutex> 1(m1); for (int i = 6; i < 9; i++){ if (i == 8) return; cout <« i; void funcC) { m2. lock(); for (int i = 3; i < 6; i+) cout << i; int main () { thread th1(funcA); thread th2(funcA); th1.join(); th2. join(); // a thread th3(funcB); thread th4(funcB); th3. join(); th4.join(); // b thread th5(funcC); thread th6(funcc); th5. join(); th6.join(); // c return 0; Edit Vlew Insert Format Tools Table Paragraph v B I U A 2 Tiv| 四 To B 12ptv
Expert Solution
steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Knowledge Booster
Operators
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning