diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-09-29 04:08:18 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-09-29 04:08:18 +0000 |
commit | 5ea01159059d98c4096bc62eb0ab59c5a5a8daa0 (patch) | |
tree | 975a433a54586c001a70023396bccce97f5732f6 /utils.c | |
parent | efc38277d3698fc001987d5788c334ba5c636ab3 (diff) |
ensure scheduling priority is inherited into new threads (issue #5293)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6692 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'utils.c')
-rwxr-xr-x | utils.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -475,6 +475,19 @@ int ast_pthread_create_stack(pthread_t *thread, pthread_attr_t *attr, void *(*st pthread_attr_init(&lattr); attr = &lattr; } +#ifdef __linux__ + /* On Linux, pthread_attr_init() defaults to PTHREAD_EXPLICIT_SCHED, + which is kind of useless. Change this here to + PTHREAD_INHERIT_SCHED; that way the -p option to set realtime + priority will propagate down to new threads by default. + This does mean that callers cannot set a different priority using + PTHREAD_EXPLICIT_SCHED in the attr argument; instead they must set + the priority afterwards with pthread_setschedparam(). */ + errno = pthread_attr_setinheritsched(attr, PTHREAD_INHERIT_SCHED); + if (errno) + ast_log(LOG_WARNING, "pthread_attr_setinheritsched returned non-zero: %s\n", strerror(errno)); +#endif + if (!stacksize) stacksize = AST_STACKSIZE; errno = pthread_attr_setstacksize(attr, stacksize); |