Created
January 30, 2017 18:40
-
-
Save dvyukov/202576d437c84ffbbe52e9ccd77e1b44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// autogenerated by syzkaller (http://github.com/google/syzkaller) | |
#include <pthread.h> | |
#include <sys/timerfd.h> | |
#define NTHR 8 | |
#define NSET 8 | |
#define TFD_TIMER_CANCEL_ON_SET (1 << 1) | |
void *thrset(void *arg) | |
{ | |
int fd = (long)arg; | |
struct itimerspec its, old; | |
its.it_interval.tv_sec = 0; | |
its.it_interval.tv_sec = 10000; | |
timerfd_settime(fd, TFD_TIMER_ABSTIME|TFD_TIMER_CANCEL_ON_SET, &its, &old); | |
return 0; | |
} | |
void *thr(void *arg) | |
{ | |
for (;;) { | |
int fd = timerfd_create(CLOCK_REALTIME, 0); | |
int i; | |
pthread_t th[NSET]; | |
for (i = 0; i < NSET; i++) | |
pthread_create(&th[i], 0, thrset, (void*)(long)fd); | |
for (i = 0; i < NSET; i++) | |
pthread_join(th[i], 0); | |
close(fd); | |
} | |
return 0; | |
} | |
int main() | |
{ | |
int i; | |
pthread_t th[NTHR]; | |
for (i = 0; i < NTHR; i++) | |
pthread_create(&th[i], 0, thr, 0); | |
for (i = 0; i < NTHR; i++) | |
pthread_join(th[i], 0); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment