diff options
author | Andreas Eversberg <jolly@eversberg.eu> | 2013-05-05 09:15:11 +0200 |
---|---|---|
committer | Andreas Eversberg <jolly@eversberg.eu> | 2013-05-09 08:58:09 +0200 |
commit | 783aa4bcb8aab7fbcd1b91ad225018a06e950f50 (patch) | |
tree | 60db876c2cb472c43bc9fee0cafda13a5f8a1927 /src/pcu_main.cpp | |
parent | b6bb55d88c2f85b4cba17330524a40c24e8945b6 (diff) |
Allow to enable realtime priority for the BTS process
I ported the Holger's scheduling patch from sysmobts to osmo-pcu.
This is usefull, if PCU uses direct access to the DSP of sysmobts.
The latency to respond to a PH-READY_TO_SEND.ind may not be higher
than 18ms. Currently we are using nice to increase our priority but
for a heavily loaded cell this is not enough. Add an option to enable
realtime scheduling and use it in the screenrc.
Linux offers two realtime scheduling classes these are SCHED_FIFO
and SCHED_RR. For SCHED_FIFO the process is running as long as possible
(potentially taking all the CPU and never yielding it), for SCHED_RR
the process can still be pre-empted at the end of the timeslice.
Using SCHED_RR appears to be the more safe option as a run-a-way
sysmobts process will not be able to take all the CPU time.
Diffstat (limited to 'src/pcu_main.cpp')
-rw-r--r-- | src/pcu_main.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp index 5bb646e7..4f23dd76 100644 --- a/src/pcu_main.cpp +++ b/src/pcu_main.cpp @@ -26,6 +26,7 @@ #include <unistd.h> #include <getopt.h> #include <signal.h> +#include <sched.h> extern "C" { #include "pcu_vty.h" #include <osmocom/vty/telnet_interface.h> @@ -41,6 +42,7 @@ extern struct vty_app_info pcu_vty_info; void *tall_pcu_ctx; extern void *bv_tall_ctx; static int quit = 0; +static int rt_prio = -1; #ifdef DEBUG_DIAGRAM extern struct timeval diagram_time; @@ -56,6 +58,8 @@ static void print_help() "provided by BTS\n" " -n --mnc MNC use given MNC instead of value " "provided by BTS\n" + " -r --realtime PRIO Use SCHED_RR with the specified " + "priority\n" ); } @@ -70,10 +74,11 @@ static void handle_options(int argc, char **argv) { "mcc", 1, 0, 'm' }, { "mnc", 1, 0, 'n' }, { "version", 0, 0, 'V' }, + { "realtime", 1, 0, 'r' }, { 0, 0, 0, 0 } }; - c = getopt_long(argc, argv, "hc:m:n:V", + c = getopt_long(argc, argv, "hc:m:n:Vr:", long_options, &option_idx); if (c == -1) break; @@ -97,6 +102,9 @@ static void handle_options(int argc, char **argv) print_version(1); exit(0); break; + case 'r': + rt_prio = atoi(optarg); + break; default: fprintf(stderr, "Unknown option '%c'\n", c); exit(0); @@ -141,6 +149,7 @@ void sighandler(int sigset) int main(int argc, char *argv[]) { + struct sched_param param; struct gprs_rlcmac_bts *bts; int rc; @@ -212,6 +221,18 @@ int main(int argc, char *argv[]) signal(SIGUSR1, sighandler); signal(SIGUSR2, sighandler); + /* enable realtime priority for us */ + if (rt_prio != -1) { + memset(¶m, 0, sizeof(param)); + param.sched_priority = rt_prio; + rc = sched_setscheduler(getpid(), SCHED_RR, ¶m); + if (rc != 0) { + fprintf(stderr, "Setting SCHED_RR priority(%d) failed: %s\n", + param.sched_priority, strerror(errno)); + exit(1); + } + } + while (!quit) { osmo_gsm_timers_check(); osmo_gsm_timers_prepare(); |