2 #include <pthread_extra.h>
10 //Prepare mutex array for tests
11 static pthread_mutex_t la
= PTHREAD_MUTEX_INITIALIZER
;
12 static pthread_mutex_t lb
= PTHREAD_MUTEX_INITIALIZER
;
13 static pthread_mutex_t lc
= PTHREAD_MUTEX_INITIALIZER
;
14 static pthread_mutex_t ld
= PTHREAD_MUTEX_INITIALIZER
;
15 static pthread_mutex_t
*lck
[4] = {&la
, &lb
, &lc
, &ld
};
19 clock_gettime(CLOCK_REALTIME
, &tm
);
22 //Lock one of the locks for testing
23 pthread_mutex_lock(lck
[2]);
25 if(!pthread_mutex_timedlock_multi(lck
, 4, &tm
)) {
26 //if(!pthread_mutex_timedlock_two(&la, lck[2], &tm)) {
43 if(pthread_mq_receive_generic(&myq
, &str
, false, PTHREAD_XTIME_FOREVER
))
44 printf("-RECVD: %.6s\t\t(waiting %d)\n", str
, (int)pthread_mq_waiting(&myq
));
45 if(pthread_mq_receive_generic(&myq
, &str
, false, PTHREAD_XTIME_NOBLOCK
))
46 printf("+RECVD: %.6s\t\t(waiting %d)\n", str
, (int)pthread_mq_waiting(&myq
));
52 pthread_mq_send_generic(&myq
, " X ", true, PTHREAD_XTIME_NOBLOCK
);
53 pthread_mq_send_generic(&myq
, " Y ", false, PTHREAD_XTIME_FOREVER
);
63 pthread_mq_init(&myq
, 6, 5);
66 pthread_create(&t
, NULL
, thread_recv
, NULL
);
68 pthread_create(&s
, NULL
, thread_send
, NULL
);
70 pthread_mq_send_generic(&myq
, "AHOJ1", false, NULL
);
71 pthread_mq_send_generic(&myq
, "AHOJ2", false, NULL
);
72 pthread_mq_send_generic(&myq
, "AHOJ3", true, NULL
);
73 pthread_mq_send_generic(&myq
, "AHOJ4", true, NULL
);
74 pthread_mq_send_generic(&myq
, "AHOJ5", false, NULL
);
75 pthread_mq_send_generic(&myq
, "AHOJ6", true, NULL
);
78 pthread_mq_send_generic(&myq
, "B ", false, NULL
);
79 pthread_mq_send_generic(&myq
, "A ", true, NULL
);
80 pthread_mq_send_generic(&myq
, " B ", false, PTHREAD_XTIME_FOREVER
);
81 pthread_mq_send_generic(&myq
, " A ", false, PTHREAD_XTIME_NOBLOCK
);
84 pthread_join(t
, NULL
);