Created
June 20, 2014 13:55
-
-
Save smirn0v/4031d38e7a6b70a8795a to your computer and use it in GitHub Desktop.
magic
This file contains hidden or 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
| typedef int (*pthread_create_f)(pthread_t * __restrict, const pthread_attr_t * __restrict, | |
| void *(*)(void *), void * __restrict); | |
| static pthread_create_f real_create = NULL; | |
| #include <pthread.h> | |
| #include <dlfcn.h> | |
| extern "C" int pthread_create(pthread_t * __restrict thread, const pthread_attr_t * __restrict attr, | |
| void *(*start)(void *), void * __restrict arg) | |
| { | |
| int rc; | |
| if (!real_create) | |
| real_create = (pthread_create_f)dlsym(RTLD_NEXT, "pthread_create"); | |
| rc = (*real_create)(thread, attr, start, arg); | |
| struct sched_param param; | |
| int policy; | |
| pthread_getschedparam(*thread, &policy, ¶m); | |
| pthread_setschedparam(*thread, SCHED_FIFO, ¶m); | |
| return rc; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment