mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-14 08:05:37 +00:00
more priority tweaks
This commit is contained in:
parent
8733a2c895
commit
464155c5cd
@ -989,7 +989,7 @@ SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir, char *bu
|
||||
//APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, switch_size_t stacksize)
|
||||
SWITCH_DECLARE(switch_status_t) switch_threadattr_stacksize_set(switch_threadattr_t *attr, switch_size_t stacksize);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_threadattr_priority_increase(switch_threadattr_t *attr);
|
||||
SWITCH_DECLARE(switch_status_t) switch_threadattr_priority_set(switch_threadattr_t *attr, switch_thread_priority_t priority);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -2016,6 +2016,13 @@ typedef switch_status_t (*switch_module_shutdown_t) SWITCH_MODULE_SHUTDOWN_ARGS;
|
||||
#define SWITCH_MODULE_RUNTIME_FUNCTION(name) switch_status_t name SWITCH_MODULE_RUNTIME_ARGS
|
||||
#define SWITCH_MODULE_SHUTDOWN_FUNCTION(name) switch_status_t name SWITCH_MODULE_SHUTDOWN_ARGS
|
||||
|
||||
typedef enum {
|
||||
SWITCH_PRI_LOW = 1,
|
||||
SWITCH_PRI_NORMAL = 10,
|
||||
SWITCH_PRI_IMPORTANT = 50,
|
||||
SWITCH_PRI_REALTIME = 99,
|
||||
} switch_thread_priority_t;
|
||||
|
||||
typedef enum {
|
||||
SMODF_NONE = 0,
|
||||
SMODF_GLOBAL_SYMBOLS = (1 << 0)
|
||||
|
@ -2272,7 +2272,7 @@ void cc_agent_dispatch_thread_start(void)
|
||||
switch_threadattr_create(&thd_attr, globals.pool);
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_threadattr_priority_increase(thd_attr);
|
||||
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
|
||||
switch_thread_create(&thread, thd_attr, cc_agent_dispatch_thread_run, NULL, globals.pool);
|
||||
}
|
||||
|
||||
|
@ -7748,7 +7748,7 @@ static void launch_conference_thread(conference_obj_t *conference)
|
||||
switch_set_flag_locked(conference, CFLAG_RUNNING);
|
||||
switch_threadattr_create(&thd_attr, conference->pool);
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
switch_threadattr_priority_increase(thd_attr);
|
||||
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_mutex_lock(globals.hash_mutex);
|
||||
switch_mutex_unlock(globals.hash_mutex);
|
||||
|
@ -3930,7 +3930,7 @@ void vm_event_thread_start(void)
|
||||
switch_threadattr_create(&thd_attr, globals.pool);
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_threadattr_priority_increase(thd_attr);
|
||||
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_IMPORTANT);
|
||||
switch_thread_create(&thread, thd_attr, vm_event_thread_run, NULL, globals.pool);
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,10 @@ private:
|
||||
return true;
|
||||
|
||||
/*
|
||||
//BUG in Freeswitch
|
||||
//BUG in Freeswitch
|
||||
|
||||
THANKS FOR NOT REPORTING IT SO WE MUST LIVE WITH A PROBLEM YOU KNOW ABOUT .....
|
||||
|
||||
if(switch_threadattr_priority_increase(
|
||||
(switch_threadattr_t *)_thread_info->_attribute) != 0)
|
||||
return false;
|
||||
|
@ -1741,7 +1741,7 @@ static switch_status_t load_config(int reload_type)
|
||||
switch_threadattr_create(&skypopen_api_thread_attr, skypopen_module_pool);
|
||||
switch_threadattr_detach_set(skypopen_api_thread_attr, 0);
|
||||
switch_threadattr_stacksize_set(skypopen_api_thread_attr, SWITCH_THREAD_STACKSIZE);
|
||||
//switch_threadattr_priority_increase(skypopen_api_thread_attr);
|
||||
|
||||
switch_thread_create(&globals.SKYPOPEN_INTERFACES[interface_id].skypopen_api_thread,
|
||||
skypopen_api_thread_attr, skypopen_do_skypeapi_thread, &globals.SKYPOPEN_INTERFACES[interface_id],
|
||||
skypopen_module_pool);
|
||||
@ -1751,7 +1751,7 @@ static switch_status_t load_config(int reload_type)
|
||||
switch_threadattr_create(&skypopen_signaling_thread_attr, skypopen_module_pool);
|
||||
switch_threadattr_detach_set(skypopen_signaling_thread_attr, 0);
|
||||
switch_threadattr_stacksize_set(skypopen_signaling_thread_attr, SWITCH_THREAD_STACKSIZE);
|
||||
//switch_threadattr_priority_increase(skypopen_signaling_thread_attr);
|
||||
|
||||
switch_thread_create(&globals.SKYPOPEN_INTERFACES[interface_id].skypopen_signaling_thread, skypopen_signaling_thread_attr,
|
||||
skypopen_signaling_thread_func, &globals.SKYPOPEN_INTERFACES[interface_id], skypopen_module_pool);
|
||||
|
||||
@ -2272,7 +2272,7 @@ int start_audio_threads(private_t *tech_pvt)
|
||||
switch_threadattr_create(&tcp_srv_thread_thd_attr, skypopen_module_pool);
|
||||
switch_threadattr_detach_set(tcp_srv_thread_thd_attr, 0);
|
||||
switch_threadattr_stacksize_set(tcp_srv_thread_thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_threadattr_priority_increase(tcp_srv_thread_thd_attr);
|
||||
switch_threadattr_priority_set(tcp_srv_thread_thd_attr, SWITCH_PRI_REALTIME);
|
||||
switch_mutex_lock(tech_pvt->mutex_thread_audio_srv);
|
||||
//DEBUGA_SKYPE("debugging_hangup srv lock\n", SKYPOPEN_P_LOG);
|
||||
if (switch_thread_create(&tech_pvt->tcp_srv_thread, tcp_srv_thread_thd_attr, skypopen_do_tcp_srv_thread, tech_pvt, skypopen_module_pool) ==
|
||||
@ -2290,7 +2290,7 @@ int start_audio_threads(private_t *tech_pvt)
|
||||
switch_threadattr_create(&tcp_cli_thread_thd_attr, skypopen_module_pool);
|
||||
switch_threadattr_detach_set(tcp_cli_thread_thd_attr, 0);
|
||||
switch_threadattr_stacksize_set(tcp_cli_thread_thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_threadattr_priority_increase(tcp_cli_thread_thd_attr);
|
||||
switch_threadattr_priority_set(tcp_cli_thread_thd_attr, SWITCH_PRI_REALTIME);
|
||||
switch_mutex_lock(tech_pvt->mutex_thread_audio_cli);
|
||||
//DEBUGA_SKYPE("debugging_hangup cli lock\n", SKYPOPEN_P_LOG);
|
||||
if (switch_thread_create(&tech_pvt->tcp_cli_thread, tcp_cli_thread_thd_attr, skypopen_do_tcp_cli_thread, tech_pvt, skypopen_module_pool) ==
|
||||
|
@ -1647,7 +1647,7 @@ void sofia_msg_thread_start(int idx)
|
||||
|
||||
switch_threadattr_create(&thd_attr, mod_sofia_globals.pool);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_threadattr_priority_increase(thd_attr);
|
||||
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
|
||||
switch_thread_create(&mod_sofia_globals.msg_queue_thread[i],
|
||||
thd_attr,
|
||||
sofia_msg_thread_run,
|
||||
@ -2373,7 +2373,7 @@ switch_thread_t *launch_sofia_worker_thread(sofia_profile_t *profile)
|
||||
|
||||
switch_threadattr_create(&thd_attr, profile->pool);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_threadattr_priority_increase(thd_attr);
|
||||
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
|
||||
switch_thread_create(&thread, thd_attr, sofia_profile_worker_thread_run, profile, profile->pool);
|
||||
|
||||
while (!sofia_test_pflag(profile, PFLAG_WORKER_RUNNING)) {
|
||||
@ -2753,7 +2753,7 @@ void launch_sofia_profile_thread(sofia_profile_t *profile)
|
||||
switch_threadattr_create(&thd_attr, profile->pool);
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_threadattr_priority_increase(thd_attr);
|
||||
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
|
||||
switch_thread_create(&thread, thd_attr, sofia_profile_thread_run, profile, profile->pool);
|
||||
}
|
||||
|
||||
@ -6114,7 +6114,6 @@ static void launch_media_on_hold(switch_core_session_t *session)
|
||||
switch_threadattr_create(&thd_attr, switch_core_session_get_pool(session));
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_threadattr_priority_increase(thd_attr);
|
||||
switch_thread_create(&thread, thd_attr, media_on_hold_thread_run, session, switch_core_session_get_pool(session));
|
||||
}
|
||||
|
||||
@ -7198,7 +7197,6 @@ static void launch_nightmare_xfer(nightmare_xfer_helper_t *nhelper)
|
||||
switch_threadattr_create(&thd_attr, nhelper->pool);
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_threadattr_priority_increase(thd_attr);
|
||||
switch_thread_create(&thread, thd_attr, nightmare_xfer_thread_run, nhelper, nhelper->pool);
|
||||
}
|
||||
|
||||
|
@ -1577,7 +1577,7 @@ void sofia_presence_event_thread_start(void)
|
||||
switch_threadattr_create(&thd_attr, mod_sofia_globals.pool);
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_threadattr_priority_increase(thd_attr);
|
||||
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_IMPORTANT);
|
||||
switch_thread_create(&thread, thd_attr, sofia_presence_event_thread_run, NULL, mod_sofia_globals.pool);
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ static void launch_monitor_thread(xml_binding_t *binding)
|
||||
|
||||
switch_threadattr_create(&thd_attr, globals.pool);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_threadattr_priority_increase(thd_attr);
|
||||
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_IMPORTANT);
|
||||
switch_thread_create(&binding->thread, thd_attr, monitor_thread_run, binding, globals.pool);
|
||||
}
|
||||
|
||||
|
@ -614,9 +614,24 @@ SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir, char *bu
|
||||
|
||||
/* thread stubs */
|
||||
|
||||
#ifndef WIN32
|
||||
struct apr_threadattr_t {
|
||||
apr_pool_t *pool;
|
||||
pthread_attr_t attr;
|
||||
int priority;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_threadattr_create(switch_threadattr_t ** new_attr, switch_memory_pool_t *pool)
|
||||
{
|
||||
return apr_threadattr_create(new_attr, pool);
|
||||
switch_status_t status;
|
||||
|
||||
if ((status = apr_threadattr_create(new_attr, pool)) == SWITCH_STATUS_SUCCESS) {
|
||||
(*new_attr)->priority = SWITCH_PRI_NORMAL;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_threadattr_detach_set(switch_threadattr_t *attr, int32_t on)
|
||||
@ -629,18 +644,10 @@ SWITCH_DECLARE(switch_status_t) switch_threadattr_stacksize_set(switch_threadatt
|
||||
return apr_threadattr_stacksize_set(attr, stacksize);
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
struct apr_threadattr_t {
|
||||
apr_pool_t *pool;
|
||||
pthread_attr_t attr;
|
||||
int priority;
|
||||
};
|
||||
#endif
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_threadattr_priority_increase(switch_threadattr_t *attr)
|
||||
SWITCH_DECLARE(switch_status_t) switch_threadattr_priority_set(switch_threadattr_t *attr, switch_thread_priority_t priority)
|
||||
{
|
||||
#ifndef WIN32
|
||||
attr->priority = 99;
|
||||
attr->priority = priority;
|
||||
#endif
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ SWITCH_DECLARE(switch_thread_t *) switch_core_launch_thread(switch_thread_start_
|
||||
ts->objs[0] = obj;
|
||||
ts->objs[1] = thread;
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_threadattr_priority_increase(thd_attr);
|
||||
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
|
||||
switch_thread_create(&thread, thd_attr, func, ts, pool);
|
||||
}
|
||||
|
||||
@ -735,7 +735,7 @@ SWITCH_DECLARE(int32_t) set_realtime_priority(void)
|
||||
const char *rt = "/proc/sys/kernel/sched_rt_runtime_us";
|
||||
char data[] = "-1\n";
|
||||
struct sched_param sched = { 0 };
|
||||
sched.sched_priority = 1;
|
||||
sched.sched_priority = SWITCH_PRI_REALTIME;
|
||||
if (sched_setscheduler(0, SCHED_RR, &sched)) {
|
||||
sched.sched_priority = 0;
|
||||
if (sched_setscheduler(0, SCHED_OTHER, &sched)) {
|
||||
|
@ -1554,6 +1554,7 @@ static switch_status_t check_queue(void)
|
||||
switch_threadattr_create(&thd_attr, node->pool);
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_LOW);
|
||||
|
||||
if (switch_thread_create(&thread, thd_attr, switch_core_session_thread_pool_worker, node, node->pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Thread Failure!\n");
|
||||
|
@ -2539,7 +2539,7 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
|
||||
|
||||
switch_threadattr_create(&thd_attr, sql_manager.memory_pool);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_threadattr_priority_increase(thd_attr);
|
||||
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
|
||||
switch_core_sqldb_start_thread();
|
||||
switch_thread_create(&sql_manager.db_thread, thd_attr, switch_core_sql_db_thread, NULL, sql_manager.memory_pool);
|
||||
|
||||
@ -2641,7 +2641,7 @@ SWITCH_DECLARE(void) switch_core_sqldb_start_thread(void)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Starting SQL thread.\n");
|
||||
switch_threadattr_create(&thd_attr, sql_manager.memory_pool);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_threadattr_priority_increase(thd_attr);
|
||||
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
|
||||
switch_thread_create(&sql_manager.thread, thd_attr, switch_core_sql_thread, NULL, sql_manager.memory_pool);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL thread is already running\n");
|
||||
|
@ -545,7 +545,7 @@ SWITCH_DECLARE(void) switch_event_launch_dispatch_threads(uint32_t max)
|
||||
|
||||
switch_threadattr_create(&thd_attr, pool);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_threadattr_priority_increase(thd_attr);
|
||||
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
|
||||
switch_thread_create(&EVENT_DISPATCH_QUEUE_THREADS[index], thd_attr, switch_event_dispatch_thread, EVENT_DISPATCH_QUEUE, pool);
|
||||
while(--sanity && !EVENT_DISPATCH_QUEUE_RUNNING[index]) switch_yield(10000);
|
||||
|
||||
@ -603,7 +603,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_init(switch_memory_pool_t *pool)
|
||||
#endif
|
||||
|
||||
//switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
//switch_threadattr_priority_increase(thd_attr);
|
||||
|
||||
|
||||
switch_queue_create(&EVENT_DISPATCH_QUEUE, DISPATCH_QUEUE_LEN * MAX_DISPATCH, pool);
|
||||
switch_event_launch_dispatch_threads(1);
|
||||
|
@ -656,7 +656,6 @@ static void chat_thread_start(int idx)
|
||||
|
||||
switch_threadattr_create(&thd_attr, chat_globals.pool);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
//switch_threadattr_priority_increase(thd_attr);
|
||||
switch_thread_create(&chat_globals.msg_queue_thread[i],
|
||||
thd_attr,
|
||||
chat_thread_run,
|
||||
|
Loading…
x
Reference in New Issue
Block a user