EBK COMPUTER SYSTEMS
EBK COMPUTER SYSTEMS
3rd Edition
ISBN: 8220101459107
Author: O'HALLARON
Publisher: YUZU
Expert Solution & Answer
Book Icon
Chapter 12.4, Problem 12.6PP

A.

Explanation of Solution

Analysis from given section:

For variable instance “ptr”:

  • For main thread:
    • From the given code, the variable “ptr” is a global variable.
    • It is written by the main thread.
  • For peer thread 0 and thread 1:
    • The variable “ptr” is read by the peer threads.

For variable instance “cnt”:

  • For main thread:
    • From the given code, the variable “cnt” is a static variable and it is contains with only one instance in memory. Hence, it is not exist in the main thread.
  • For peer thread 0 and thread 1:
    • The variable “cnt” is read and written by the peer threads.

For variable instance “i.m”:

  • For main thread:
    • From the given code, the variable “i.m” is a local automatic variable.
    • It is stored on the stack of the main thread. Hence, this variable is exist in the main thread.
  • For peer thread 0 and thread 1:
    • The given variable is stored on the main thread, while its corresponding value is passed to the peer threads, the peer threads never place it on the stack. So, it is not shared.

For variable instance “msgs.m”:

  • For main thread:
    • From the given code, the variable “msgs.m” is a local automatic variable.
    • It is stored on the stack of the main thread. Hence, it is exist in the main thread.
  • For peer thread 0 and thread 1:
    • The given variable is stored on the main thread...

B.

Explanation of Solution

Analysis of shared variable from part A:

From the part A, the variables “ptr”,...

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