aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-sysmo/main.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-05-03 21:30:28 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-05-11 08:34:36 +0200
commitc03fe5af31dcdd5fe144dc2c487249009b991ad1 (patch)
tree228a15c34fa98da1976a7e0770f01a076d7ad336 /src/osmo-bts-sysmo/main.c
parent9be5f8c9c067f15ad3f49d8ba9d1db3b42ca1409 (diff)
sysmobts: Allow to enable realtime priority for the BTS process
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. For a very loaded cell we also require to use readv/writev to allow writing multiple primitives in one syscall.
Diffstat (limited to 'src/osmo-bts-sysmo/main.c')
-rw-r--r--src/osmo-bts-sysmo/main.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c
index a00120e4..595a6ebc 100644
--- a/src/osmo-bts-sysmo/main.c
+++ b/src/osmo-bts-sysmo/main.c
@@ -28,6 +28,7 @@
#include <sys/signal.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sched.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -56,6 +57,7 @@ int pcu_direct = 0;
static const char *config_file = "osmo-bts.cfg";
static int daemonize = 0;
static unsigned int dsp_trace = 0x71c00020;
+static int rt_prio = -1;
int bts_model_init(struct gsm_bts *bts)
{
@@ -108,6 +110,7 @@ static void print_help()
" -V --version Print version information and exit\n"
" -e --log-level Set a global log-level\n"
" -p --dsp-trace Set DSP trace flags\n"
+ " -r --realtime PRIO Use SCHED_RR with the specified priority\n"
" -w --hw-version Print the targeted HW Version\n"
" -M --pcu-direct Force PCU to access message queue for "
"PDCH dchannel directly\n"
@@ -141,10 +144,11 @@ static void handle_options(int argc, char **argv)
{ "dsp-trace", 1, 0, 'p' },
{ "hw-version", 0, 0, 'w' },
{ "pcu-direct", 0, 0, 'M' },
+ { "realtime", 1, 0, 'r' },
{ 0, 0, 0, 0 }
};
- c = getopt_long(argc, argv, "hc:d:Dc:sTVe:p:w:M",
+ c = getopt_long(argc, argv, "hc:d:Dc:sTVe:p:w:Mr:",
long_options, &option_idx);
if (c == -1)
break;
@@ -186,6 +190,9 @@ static void handle_options(int argc, char **argv)
print_hwversion();
exit(0);
break;
+ case 'r':
+ rt_prio = atoi(optarg);
+ break;
default:
break;
}
@@ -235,6 +242,7 @@ static int write_pid_file(char *procname)
int main(int argc, char **argv)
{
struct stat st;
+ struct sched_param param;
struct gsm_bts_role_bts *btsb;
struct ipabis_link *link;
void *tall_msgb_ctx;
@@ -251,6 +259,18 @@ int main(int argc, char **argv)
handle_options(argc, argv);
+ /* enable realtime priority for us */
+ if (rt_prio != -1) {
+ memset(&param, 0, sizeof(param));
+ param.sched_priority = rt_prio;
+ rc = sched_setscheduler(getpid(), SCHED_RR, &param);
+ if (rc != 0) {
+ fprintf(stderr, "Setting SCHED_RR priority(%d) failed: %s\n",
+ param.sched_priority, strerror(errno));
+ exit(1);
+ }
+ }
+
bts = gsm_bts_alloc(tall_bts_ctx);
if (bts_init(bts) < 0) {
fprintf(stderr, "unable to to open bts\n");