This preview shows page 1. Sign up to view the full content.
Unformatted text preview: n with the static attribute. As with global variables, the read/write area of virtual memory contains exactly one instance of each local static variable declared in a program. For example, even though each peer thread in our example program declares cnt in line 27, at runtime there is only one instance of cnt residing in the read/write area of virtual memory. Each peer thread reads and writes this instance. 11.3.3 Shared Variables
A variable Ú is shared if and only if one of its instances is referenced by more than one thread. For example, variable cnt in our example program is shared because it has only one run-time instance, and this instance is referenced by both peer threads. On the other hand, myid is not shared because each of its two instances is referenced by exactly one thread. However, it is important to realize that local automatic variables such as msgs can also be shared. Practice Problem 11.2:
A. Using the analysis from Section 11.3, ﬁll each entry in the following table with “Yes” or “No” for the example program in Figure 11.7. In the...
View Full Document
This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.
- Spring '10
- The American