Consider the following data that are shared between two threads and are initialised before the threads are executed, as follows: boolean flag int x = 50; = Thread 1 is defined as follows: true; void run_thread1() { while (flag) { } print x; } Thread 2 is defined as follows: void run_thread2() { x = 60; flag = false; Let us assume that, as there are no data dependencies between the variables flag and x, it is possible that a processor may reorder the instructions for Thread 2. Which of the following statements regarding the possible output of Thread 1 is TRUE? Thread 1 could enter an infinite loop The output could only be 50 The output could either be 50 or 60 None of the mentioned O The output could only be 60
Consider the following data that are shared between two threads and are initialised before the threads are executed, as follows: boolean flag int x = 50; = Thread 1 is defined as follows: true; void run_thread1() { while (flag) { } print x; } Thread 2 is defined as follows: void run_thread2() { x = 60; flag = false; Let us assume that, as there are no data dependencies between the variables flag and x, it is possible that a processor may reorder the instructions for Thread 2. Which of the following statements regarding the possible output of Thread 1 is TRUE? Thread 1 could enter an infinite loop The output could only be 50 The output could either be 50 or 60 None of the mentioned O The output could only be 60
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...
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps
Recommended textbooks for you
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY