mirror of
https://github.com/ioacademy-jikim/debugging
synced 2025-06-08 08:26:14 +00:00
27 lines
502 B
C
27 lines
502 B
C
|
|
#include <time.h>
|
|
#include <pthread.h>
|
|
#include <assert.h>
|
|
#include <errno.h>
|
|
|
|
int main()
|
|
{
|
|
struct timespec abstime;
|
|
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
|
|
|
|
|
|
|
|
|
|
abstime.tv_sec = time(NULL) + 2;
|
|
abstime.tv_nsec = 0;
|
|
|
|
abstime.tv_nsec += 1000000000;
|
|
|
|
assert(pthread_mutex_lock(&mutex)==0);
|
|
assert(pthread_cond_timedwait(&cond, &mutex, &abstime)==EINVAL);
|
|
assert(pthread_mutex_unlock(&mutex)==0);
|
|
|
|
return 0;
|
|
}
|