5 /* Simple demonstration of lockset tracking at byte granularity. */
9 void* child_fn ( void* arg
)
12 for (i
= 0; i
< 5; i
++)
13 bytes
[2*i
+ 0] ++; /* child accesses: 0 2 4 6 8 */
19 const struct timespec delay
= { 0, 100 * 1000 * 1000 };
22 if (pthread_create(&child
, NULL
, child_fn
, NULL
)) {
23 perror("pthread_create");
27 /* Unprotected relative to child, but harmless, since different
29 for (i
= 0; i
< 5; i
++)
30 bytes
[2*i
+ 1] ++; /* accesses: 1 3 5 7 9 */
32 /* Unprotected relative to child, but harmful; same bytes */
33 for (i
= 0; i
< 3; i
++)
34 bytes
[3*i
+ 1] ++; /* accesses: 1 4(race!) 7 */
36 if (pthread_join(child
, NULL
)) {
37 perror("pthread join");