diff options
author | Lukas Larsson <[email protected]> | 2014-02-23 18:26:38 +0100 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2014-02-24 15:16:07 +0100 |
commit | a35d0f5f82f8152f1b953eda039807a7d4f4e9b9 (patch) | |
tree | 0410287577061d3ed630e76608bc865613c2b19d /erts/emulator/beam | |
parent | 2bf4f22a9488d94ac1fc3c72a4e9d84151744004 (diff) | |
download | otp-a35d0f5f82f8152f1b953eda039807a7d4f4e9b9.tar.gz otp-a35d0f5f82f8152f1b953eda039807a7d4f4e9b9.tar.bz2 otp-a35d0f5f82f8152f1b953eda039807a7d4f4e9b9.zip |
ose: Thread priorities configurable from lmconf
The pattern used for getting the priority from the lmconf
is based on the name of the process created. The pattern is:
ERTS_%%PROCESS_NAME%%_PRIO
with the %%PROCESS_NAME%% replaced by the prefix of the process
the priority applies to. eg:
ERTS_SCHEDULER_PRIO=24
applies to processes with name SCHEDULER_1, SCHEDULER_2 etc.
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r-- | erts/emulator/beam/erl_async.c | 14 | ||||
-rw-r--r-- | erts/emulator/beam/erl_process.c | 38 | ||||
-rw-r--r-- | erts/emulator/beam/erl_trace.c | 5 |
3 files changed, 36 insertions, 21 deletions
diff --git a/erts/emulator/beam/erl_async.c b/erts/emulator/beam/erl_async.c index afb5bc302f..b3dc327704 100644 --- a/erts/emulator/beam/erl_async.c +++ b/erts/emulator/beam/erl_async.c @@ -166,6 +166,7 @@ async_ready_q(Uint sched_id) #endif + void erts_init_async(void) { @@ -226,18 +227,23 @@ erts_init_async(void) thr_opts.suggested_stack_size = erts_async_thread_suggested_stack_size; -#ifdef ETHR_HAVE_THREAD_NICENESS - thr_opts.prio += 2; -#endif #ifdef ETHR_HAVE_THREAD_NAMES - thr_opts.name = "async_thread"; + thr_opts.name = malloc(sizeof(char)*(strlen("async_XXXX")+1)); #endif for (i = 0; i < erts_async_max_threads; i++) { ErtsAsyncQ *aq = async_q(i); + +#ifdef ETHR_HAVE_THREAD_NAMES + sprintf(thr_opts.name, "async_%d", i+1); +#endif + erts_thr_create(&aq->thr_id, async_main, (void*) aq, &thr_opts); } +#ifdef ETHR_HAVE_THREAD_NAMES + free(thr_opts.name); +#endif /* Wait for async threads to initialize... */ erts_mtx_lock(&async->init.data.mtx); diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c index a4241c6d43..83856ab983 100644 --- a/erts/emulator/beam/erl_process.c +++ b/erts/emulator/beam/erl_process.c @@ -6830,9 +6830,16 @@ erts_start_schedulers(void) opts.detached = 1; +#ifdef ETHR_HAVE_THREAD_NAMES + opts.name = malloc(80); +#endif + #ifdef ERTS_SMP if (erts_runq_supervision_interval) { opts.suggested_stack_size = 16; +#ifdef ETHR_HAVE_THREAD_NAMES + sprintf(opts.name, "runq_supervisor"); +#endif erts_atomic_init_nob(&runq_supervisor_sleeping, 0); if (0 != ethr_event_init(&runq_supervision_event)) erl_exit(1, "Failed to create run-queue supervision event\n"); @@ -6854,17 +6861,13 @@ erts_start_schedulers(void) res = ENOTSUP; } -#ifdef ETHR_HAVE_THREAD_NAMES - opts.name = malloc(sizeof(char)*(strlen("scheduler_XXXX")+1)); -#endif - for (actual = 0; actual < wanted; actual++) { ErtsSchedulerData *esdp = ERTS_SCHEDULER_IX(actual); ASSERT(actual == esdp->no - 1); #ifdef ETHR_HAVE_THREAD_NAMES - sprintf(opts.name,"scheduler_%d", actual+1); + sprintf(opts.name, "scheduler_%d", actual + 1); #endif #ifdef __OSE__ @@ -6872,14 +6875,13 @@ erts_start_schedulers(void) opts.coreNo = (actual+1) % ose_num_cpus(); #endif - res = ethr_thr_create(&esdp->tid, sched_thread_func,(void*)esdp,&opts); + res = ethr_thr_create(&esdp->tid, sched_thread_func, (void*)esdp, &opts); if (res != 0) { break; } - } - + erts_no_schedulers = actual; #ifdef ERTS_DIRTY_SCHEDULERS @@ -6888,12 +6890,18 @@ erts_start_schedulers(void) int ix; for (ix = 0; ix < erts_no_dirty_cpu_schedulers; ix++) { ErtsSchedulerData *esdp = ERTS_DIRTY_CPU_SCHEDULER_IX(ix); +#ifdef ETHR_HAVE_THREAD_NAMES + sprintf(opts.name,"dirty_cpu_scheduler_%d", ix + 1); +#endif res = ethr_thr_create(&esdp->tid,sched_dirty_cpu_thread_func,(void*)esdp,&opts); if (res != 0) erl_exit(1, "Failed to create dirty cpu scheduler thread %d\n", ix); } for (ix = 0; ix < erts_no_dirty_io_schedulers; ix++) { ErtsSchedulerData *esdp = ERTS_DIRTY_IO_SCHEDULER_IX(ix); +#ifdef ETHR_HAVE_THREAD_NAMES + sprintf(opts.name,"dirty_io_scheduler_%d", ix + 1); +#endif res = ethr_thr_create(&esdp->tid,sched_dirty_io_thread_func,(void*)esdp,&opts); if (res != 0) erl_exit(1, "Failed to create dirty io scheduler thread %d\n", ix); @@ -6903,16 +6911,14 @@ erts_start_schedulers(void) #endif ERTS_THR_MEMORY_BARRIER; + #ifdef ETHR_HAVE_THREAD_NAMES - free(opts.name); - opts.name = "aux_thread"; + sprintf(opts.name, "aux"); #endif + #ifdef __OSE__ opts.coreNo = 0; -#endif -#ifdef ETHR_HAVE_THREAD_NICENESS - opts.prio++; -#endif +#endif /* __OSE__ */ res = ethr_thr_create(&aux_tid, aux_thread, NULL, &opts); if (res != 0) @@ -6933,6 +6939,10 @@ erts_start_schedulers(void) actual, actual == 1 ? " was" : "s were"); erts_send_error_to_logger_nogl(dsbufp); } + +#ifdef ETHR_HAVE_THREAD_NAMES + free(opts.name); +#endif } #endif /* ERTS_SMP */ diff --git a/erts/emulator/beam/erl_trace.c b/erts/emulator/beam/erl_trace.c index 43e7435d2a..6978a5f11a 100644 --- a/erts/emulator/beam/erl_trace.c +++ b/erts/emulator/beam/erl_trace.c @@ -3478,12 +3478,11 @@ init_sys_msg_dispatcher(void) sys_message_queue_end = NULL; erts_smp_cnd_init(&smq_cnd); erts_smp_mtx_init(&smq_mtx, "sys_msg_q"); + #ifdef ETHR_HAVE_THREAD_NAMES thr_opts.name = "sys_msg_dispatcher"; #endif -#ifdef ETHR_HAVE_THREAD_NICENESS - thr_opts.prio++; -#endif + erts_smp_thr_create(&sys_msg_dispatcher_tid, sys_msg_dispatcher_func, NULL, |