Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 152587 Details for
Bug 217067
A thread in pthread_cond_wait() is being signalled (rapidly) by two other threads but it is not being scheduled.
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
test program for trying to reproduce pthread_cond_wait() hangs
futex.c (text/plain), 1.90 KB, created by
Ernie Petrides
on 2007-04-13 20:52:01 UTC
(
hide
)
Description:
test program for trying to reproduce pthread_cond_wait() hangs
Filename:
MIME Type:
Creator:
Ernie Petrides
Created:
2007-04-13 20:52:01 UTC
Size:
1.90 KB
patch
obsolete
>/* > * futex.c > * > * compile with: cc -g -o futex futex.c -lpthread > */ > >#include <pthread.h> > >#define PADSIZ (1024 - 2 * sizeof(int) \ > - sizeof(pthread_mutex_t) - sizeof(pthread_cond_t)) > >struct synch { > int sem[2]; > pthread_mutex_t mutex; > pthread_cond_t cond; > char pad[PADSIZ]; >}; > >struct synch race = > { 0, 0, PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, "" }; > >struct synch wake[4] = { > { 0, 0, PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, "" }, > { 0, 0, PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, "" }, > { 0, 0, PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, "" }, > { 0, 0, PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, "" }, >}; > >volatile int hung; > >void sleep_on_it(struct synch *p, int x) >{ > pthread_mutex_lock(&p->mutex); > while (p->sem <= 0) > pthread_cond_wait(&p->cond, &p->mutex); > p->sem[x]--; > pthread_mutex_unlock(&p->mutex); >} > >void wake_it_up(struct synch *p, int x) >{ > pthread_mutex_lock(&p->mutex); > p->sem[x]++; > pthread_cond_signal(&p->cond); > pthread_mutex_unlock(&p->mutex); >} > >void *consumer(void *arg) >{ > int x = ((struct synch *)arg != &wake[0]); > > for (;;) { > sleep_on_it(&race, x); > hung = 0; > wake_it_up((struct synch *)arg + 0, 0); > wake_it_up((struct synch *)arg + 1, 0); > } >} > >void *producer(void *arg) >{ > int x = ((struct synch *)arg != &wake[0]); > > for (;;) { > wake_it_up(&race, x); > sleep_on_it((struct synch *)arg + 0, 0); > sleep_on_it((struct synch *)arg + 2, 0); > } >} > >int main(int argc, char *argv[]) >{ > pthread_t t1, t2, t3, t4; > > pthread_create(&t1, NULL, consumer, (void *)&wake[0]); > pthread_create(&t2, NULL, consumer, (void *)&wake[2]); > pthread_create(&t3, NULL, producer, (void *)&wake[0]); > pthread_create(&t4, NULL, producer, (void *)&wake[1]); > > do { > sleep(1); > if (hung++ == 0) > write(1, ".", 1); > } while (hung < 10); > > write(1, "\nhung for 10 seconds at ", 24); > execl("/bin/date", "date", (char *)0); > write(1, "?\n", 2); > exit(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 217067
:
142001
|
145480
|
145684
|
145993
|
145994
|
145995
|
146161
|
146162
|
150237
| 152587 |
152592
|
161087
|
161088
|
161089
|
161090
|
161091
|
161092
|
161093
|
161094
|
161095