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 298787 Details for
Bug 438484
Libc's implementation of condition variables subject to priority inversion
[?]
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.
testcase
pitest.c (text/x-c), 4.25 KB, created by
Roland Westrelin
on 2008-03-21 11:39:31 UTC
(
hide
)
Description:
testcase
Filename:
MIME Type:
Creator:
Roland Westrelin
Created:
2008-03-21 11:39:31 UTC
Size:
4.25 KB
patch
obsolete
>#include <pthread.h> >#include <stdio.h> >#include <string.h> >#include <stdlib.h> >#include <errno.h> >#include <sys/types.h> >#include <sys/syscall.h> >#include <unistd.h> > >static pthread_cond_t cv; >static pthread_mutex_t mx; > >static volatile int th2_started = 0; >static volatile int th3_started = 0; > >static void *rtthread2(void* arg) { > int status; > > { > struct sched_param param; > param.sched_priority = 70; > if((status = pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m)) != 0) { > fprintf(stderr, "pthread_setschedparam: %s", strerror(status)); > exit(1); > } > } > > printf("RTT 2 %d thread running at RT prio\n", syscall(SYS_gettid)); > > th2_started = 1; > > if((status = pthread_mutex_lock(&mx)) != 0) { > fprintf(stderr, "pthread_mutex_lock: %s", strerror(status)); > exit(1); > } > > printf("RTT 2 got mutex\n"); > > if((status = pthread_mutex_unlock(&mx)) != 0) { > fprintf(stderr, "pthread_mutex_unlock: %s", strerror(status)); > exit(1); > } > > if((status = pthread_cond_signal(&cv)) != 0) { > fprintf(stderr, "pthread_cond_signal: %s", strerror(status)); > exit(1); > } > > printf("RTT 2 signaled\n"); > > return 0; >} > >static void *rtthread3(void* arg) { > int status; > > { > struct sched_param param; > param.sched_priority = 60; > if((status = pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m)) != 0) { > fprintf(stderr, "pthread_setschedparam: %s", strerror(status)); > exit(1); > } > } > > printf("RTT 3 %d thread running at RT prio\n", syscall(SYS_gettid)); > > th3_started = 1; > > while(1); > > return 0; >} > >static void *rtthread1(void* arg) { > int status; > > { > struct sched_param param; > param.sched_priority = 50; > if((status = pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m)) != 0) { > fprintf(stderr, "pthread_setschedparam: %s", strerror(status)); > exit(1); > } > } > > printf("RTT 1 %d thread running at RT prio\n", syscall(SYS_gettid)); > > if((status = pthread_mutex_lock(&mx)) != 0) { > fprintf(stderr, "pthread_mutex_lock: %s", strerror(status)); > exit(1); > } > > { > pthread_t tid2; > if ((status = pthread_create(&tid2, 0, rtthread2, 0)) != 0) { > fprintf(stderr, "pthread_create: %s", strerror(status)); > exit(1); > } > while(!th2_started) { > sleep(1); > } > } > > printf("RTT 2 running\n"); > > { > pthread_t tid3; > if ((status = pthread_create(&tid3, 0, rtthread3, 0)) != 0) { > fprintf(stderr, "pthread_create: %s", strerror(status)); > exit(1); > } > while(!th3_started) { > sleep(1); > } > } > > printf("RTT 3 running\n"); > > if((status = pthread_cond_wait(&cv, &mx)) != 0) { > fprintf(stderr, "pthread_cond_wait: %s", strerror(status)); > exit(1); > } > > > if((status = pthread_mutex_unlock(&mx)) != 0) { > fprintf(stderr, "pthread_mutex_unlock: %s", strerror(status)); > exit(1); > } > > return 0; >} > >int main(int argc, char* argv[]) { > > int status; > pthread_mutexattr_t mxattr; > pthread_condattr_t cvattr; > pthread_t tid; > > if ((status = pthread_mutexattr_init(&mxattr)) != 0) { > fprintf(stderr, "pthread_mutexattr_init: %s", strerror(status)); > return 1; > } > if ((status = pthread_mutexattr_setprotocol(&mxattr, PTHREAD_PRIO_INHERIT)) != 0) { > fprintf(stderr, "pthread_mutexattr_setprotocol: %s", strerror(status)); > return 1; > } > if ((status = pthread_mutex_init(&mx, &mxattr)) != 0) { > fprintf(stderr, "pthread_mutex_init: %s", strerror(status)); > return 1; > } > > if ((status = pthread_condattr_init(&cvattr)) != 0) { > fprintf(stderr, "pthread_condattr_init: %s", strerror(status)); > return 1; > } > if ((status = pthread_condattr_setclock(&cvattr, CLOCK_MONOTONIC)) != 0) { > fprintf(stderr, "pthread_condattr_setclock: %s", strerror(status)); > return 1; > } > if ((status = pthread_cond_init(&cv, &cvattr)) != 0) { > fprintf(stderr, "pthread_cond_init: %s", strerror(status)); > return 1; > } > if ((status = pthread_condattr_destroy(&cvattr)) != 0) { > fprintf(stderr, "pthread_condattr_destroy: %s", strerror(status)); > return 1; > } > > if ((status = pthread_create(&tid, 0, rtthread1, 0)) != 0) { > fprintf(stderr, "pthread_create: %s", strerror(status)); > return 1; > } > > if ((status = pthread_join(tid, 0)) != 0) { > fprintf(stderr, "pthread_join: %s", strerror(status)); > return 1; > } > > 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 438484
: 298787