From c018012e703fdb477f78bfde0d8f7ae3ab177489 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sun, 16 Jun 2013 15:49:55 +0200 Subject: osmocon: Add option to set SCHED_RR and prority --- src/host/osmocon/osmocon.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/host/osmocon/osmocon.c b/src/host/osmocon/osmocon.c index 01eafcdf..fc9f97fd 100644 --- a/src/host/osmocon/osmocon.c +++ b/src/host/osmocon/osmocon.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -1202,6 +1203,7 @@ static int parse_mode(const char *arg) "\t\t [ -l /tmp/osmocom_loader ]\n" \ "\t\t [ -m {c123,c123xor,c140,c140xor,c155,romload,mtk} ]\n" \ "\t\t [ -i beacon-interval (mS) ]\n" \ + "\t\t [ -r PRIO ] (set realtime scheduler with given prio)\n" \ "\t\t file.bin\n\n" \ "* Open serial port /dev/ttyXXXX (connected to your phone)\n" \ "* Perform handshaking with the ramloader in the phone\n" \ @@ -1408,12 +1410,13 @@ int main(int argc, char **argv) const char *serial_dev = "/dev/ttyUSB1"; const char *layer2_un_path = "/tmp/osmocom_l2"; const char *loader_un_path = "/tmp/osmocom_loader"; + int rt_prio = -1; dnload.mode = MODE_C123; dnload.beacon_interval = DEFAULT_BEACON_INTERVAL; dnload.do_chainload = 0; - while ((opt = getopt(argc, argv, "d:hl:p:m:cs:i:v")) != -1) { + while ((opt = getopt(argc, argv, "d:hl:p:m:cs:i:r:v")) != -1) { switch (opt) { case 'p': serial_dev = optarg; @@ -1441,6 +1444,9 @@ int main(int argc, char **argv) case 'i': dnload.beacon_interval = atoi(optarg) * 1000; break; + case 'r': + rt_prio = atoi(optarg); + break; case 'h': default: usage(argv[0]); @@ -1508,6 +1514,20 @@ int main(int argc, char **argv) dnload.load_address[2] = (tmp_load_address >> 8) & 0xff; dnload.load_address[3] = tmp_load_address & 0xff; + if (rt_prio != -1) { + struct sched_param schedp; + int rc; + + /* high priority scheduling required for handling bursts */ + memset(&schedp, 0, sizeof(schedp)); + schedp.sched_priority = rt_prio; + rc = sched_setscheduler(0, SCHED_RR, &schedp); + if (rc) { + fprintf(stderr, "Error setting SCHED_RR with prio %d\n", + rt_prio); + } + } + while (1) { if (osmo_select_main(0) < 0) break; -- cgit v1.2.3