

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


















1
2
Figure 4.1 Docsity.com
4
5
7
8
10
11
1: void nested2(int x) 2: { 3: int y = 9; 4: printf("hello2= %d,%d\n", x, y); 5: }
6: void nested1(int x) 7: { 8: int y = 6; 9: printf("hello1= %d, %d\n", x, y); 10: nested2(77); 11:}
12: void nested0(int x) 13: { 14: int y = 0; 15: printf("hello0= %d, %d\n", x, y); 16: nested1(13); 17: } 18: int main(void) 19: { 20: int z = 1; 21: nested0(3); 22: fflush(stdin); 23: getchar(); 24: return 0; 25: }
13
14
After
line 20
z 1
After line 14 After call on line 21
z 1
x 3 y 0 line 21
z 1
z 1
Etc.
key: thread 1 thread 2
Problem : The stack pointer and the stack data are both being shared by 2 threads, in an unsynchronized manner!
Docsity.com
19
20
http://www.cprince.com/courses/cs5631/lectures/Chapter (Adapted from Figure 4.9; runs on OS X)
23
Many-to-one
One-to-one
Many-to-many
Docsity.com