#include #include pthread_mutex_t a = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t b = PTHREAD_MUTEX_INITIALIZER; pthread_barrier_t bar; void *ba_lock(void *arg) { int ret, i; pthread_mutex_lock(&b); if (pthread_barrier_wait(&bar) == PTHREAD_BARRIER_SERIAL_THREAD) pthread_barrier_destroy(&bar); pthread_mutex_lock(&a); pthread_mutex_unlock(&a); pthread_mutex_unlock(&b); } int main(void) { pthread_t t; pthread_barrier_init(&bar, NULL, 2); if (pthread_create(&t, NULL, ba_lock, NULL)) { fprintf(stderr, "pthread_create() failed\n"); return 1; } pthread_mutex_lock(&a); if (pthread_barrier_wait(&bar) == PTHREAD_BARRIER_SERIAL_THREAD) pthread_barrier_destroy(&bar); pthread_mutex_lock(&b); pthread_mutex_unlock(&b); pthread_mutex_unlock(&a); pthread_join(t, NULL); return 0; } /cgit.cgi/linux/net-next.git/'>net-next.git
net-next plumbingsTobias Klauser
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2016-12-12 12:17:19 +0000
committerMark Brown <broonie@kernel.org>2016-12-12 12:17:19 +0000
commitc1b0789271b13dd7561f78370122c3183cd74ab0 (patch)
treef4eda3db7bd1b059de81cd4bec7fbb871661dbe2 /drivers/usb/storage/uas.c
parent69973b830859bc6529a7a0468ba0d80ee5117826 (diff)
parent618c808968852609d2d9f0e5cfc351a4807ef8d0 (diff)
Merge remote-tracking branch 'regulator/fix/axp20x' into regulator-linus
Diffstat (limited to 'drivers/usb/storage/uas.c')