7 /* Test of the mechanism for showing all locks held by a thread -- one
8 thread has a lock, the other doesn't. Running w/ command line args
9 switches the has/has-not thread around, so as to test lockset
10 retention in both the history mechanism and the primary errors. */
12 pthread_mutex_t mx
= PTHREAD_MUTEX_INITIALIZER
;
16 void* child_fn ( void* arg
)
18 if (arg
) pthread_mutex_lock(&mx
);
20 if (arg
) pthread_mutex_unlock(&mx
);
24 int main ( int argc
, char** argv
)
27 pthread_t child1
, child2
;
29 if (pthread_create(&child1
, NULL
, child_fn
, (void*)(long)(sw
? 0 : 1))) {
30 perror("pthread_create1");
33 sleep(1); /* ensure repeatable results */
34 if (pthread_create(&child2
, NULL
, child_fn
, (void*)(long)(sw
? 1 : 0))) {
35 perror("pthread_create1");
39 if (pthread_join(child1
, NULL
)) {
40 perror("pthread join1");
44 if (pthread_join(child2
, NULL
)) {
45 perror("pthread join2");