Which all threads run jn paralle and concurent will the system make independent copies of thread__func for each thread during runtime ?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Which all threads run jn paralle and concurent will the system make independent copies of thread__func for each thread during runtime ?
1 #include<iostream>
2 #include<memory>
3 #include<thread>
4
int Add (int a int b)
>
5
6 {
7
8}
9
10 void threaf_func(int a, int threadno)
11 {
12
13
14
15
16
17
18
19
26
27
28
29
return (a+b);
20}
21
22 int main()
23 {
24
25
30
31
for (int i=0;i<=50; i++)
{
std::cout<<"\n printing the threads
<< threadno <<"\t:\t" <<i<<"\n";
i=Add(i, a);
std::cout<<Add (1,2);
int a1{10}, b1;
//Function Pointer to the Threaf_Func()
void (*ptr_Func) (int,int)
&threaf_func;
std::thread Th1 (ptr_Func,2, 1);
11
Transcribed Image Text:1 #include<iostream> 2 #include<memory> 3 #include<thread> 4 int Add (int a int b) > 5 6 { 7 8} 9 10 void threaf_func(int a, int threadno) 11 { 12 13 14 15 16 17 18 19 26 27 28 29 return (a+b); 20} 21 22 int main() 23 { 24 25 30 31 for (int i=0;i<=50; i++) { std::cout<<"\n printing the threads << threadno <<"\t:\t" <<i<<"\n"; i=Add(i, a); std::cout<<Add (1,2); int a1{10}, b1; //Function Pointer to the Threaf_Func() void (*ptr_Func) (int,int) &threaf_func; std::thread Th1 (ptr_Func,2, 1); 11
29
30
31
32 std::thread
23
4451
void (*ptr_Func) (int,int) = &threaf_func;
std::thread Th1(ptr_Func,2, 1);
Th2(ptr_Func, 1, 2);
33
34
35
36 /* 1) Which all threads
37
38
39
40
41
42
43
44
45 */
46
std::thread Th3 (threaf_func,1,3);
std::thread Th4(threaf_func,2,4);
a) will run in parallel?
b) will be concurrent?
47
48
49
50
51
52
53
54}
Question:
3) will the system make copies of
compiled "threaf_func" instructions
for each thread during runtime?
How will the system go about
executing Th1 and Th2?
-.
std::cin.ignore();
Th1.join();
Th2.join();
Th3.join();
Th4.join();
1) Which all thu
\/
Transcribed Image Text:29 30 31 32 std::thread 23 4451 void (*ptr_Func) (int,int) = &threaf_func; std::thread Th1(ptr_Func,2, 1); Th2(ptr_Func, 1, 2); 33 34 35 36 /* 1) Which all threads 37 38 39 40 41 42 43 44 45 */ 46 std::thread Th3 (threaf_func,1,3); std::thread Th4(threaf_func,2,4); a) will run in parallel? b) will be concurrent? 47 48 49 50 51 52 53 54} Question: 3) will the system make copies of compiled "threaf_func" instructions for each thread during runtime? How will the system go about executing Th1 and Th2? -. std::cin.ignore(); Th1.join(); Th2.join(); Th3.join(); Th4.join(); 1) Which all thu \/
Expert Solution
steps

Step by step

Solved in 5 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY