Sourceware Bugzilla – Attachment 7196 Details for
Bug 12674
sem_post/sem_wait race causing sem_post to return EINVAL
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
A simpler test program
simple.c (text/x-csrc), 606 bytes, created by
Michael Ballantyne
on 2013-09-13 20:14:51 UTC
(
hide
)
Description:
A simpler test program
Filename:
MIME Type:
Creator:
Michael Ballantyne
Created:
2013-09-13 20:14:51 UTC
Size:
606 bytes
patch
obsolete
>#include <stdio.h> >#include <stdlib.h> >#include <sched.h> >#include <pthread.h> >#include <semaphore.h> >#include <string.h> > >sem_t *varsem; > >void *poster(void *unused) { > if (sem_post(varsem) != 0) { > perror("sem_post() in poster"); > exit(1); > } > pthread_exit(0); >} > >int main(void) { > varsem = malloc(sizeof(sem_t)); > sem_init(varsem, 0, 0); > > pthread_t t; > pthread_create(&t, NULL, &poster, NULL); > > sem_wait(varsem); > > /* destroy the semaphore */ > if (sem_destroy(varsem) != 0) { > perror("destroy failed"); > } > > memset(varsem, '\1', sizeof(sem_t)); > > free(varsem); > > pthread_join(t, NULL); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 12674
:
5671
|
6206
| 7196