From: Ian Jackson Date: Sun, 9 Jan 2011 19:07:40 +0000 (+0000) Subject: hostside: do serial irq priority poking with a helper script and a pipe in /var/run... X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;ds=sidebyside;h=a45c35ae9738b166beb04588161da5a2b2cdaa11;p=trains.git hostside: do serial irq priority poking with a helper script and a pipe in /var/run, yuck --- diff --git a/hostside/realtime.c b/hostside/realtime.c index 46f6c06..44b01ed 100644 --- a/hostside/realtime.c +++ b/hostside/realtime.c @@ -376,6 +376,25 @@ void check_rusage_check(int always_report) { } } +#define SERINTRPOKE "/var/run/serial-irq-priority-poke" + +static void serial_interrupt_priority(void) { + int fd= open(SERINTRPOKE, O_WRONLY|O_NONBLOCK); + if (fd<0) { + if (errno==ENOENT || errno==EAGAIN || errno==EACCES || errno==EWOULDBLOCK) + return; + diee("failed to open " SERINTRPOKE); + } + static char dummy; + int r= write(fd,&dummy,1); + if (r!=1) { + assert(r<0); + if (!(errno==EWOULDBLOCK)) + diee("failed to write a byte to " SERINTRPOKE); + } + close(fd); +} + /*---------- debugging ----------*/ unsigned long eventcounter; @@ -565,6 +584,7 @@ int main(int argc, const char **argv) { if (nononblock_stdin) oop_fd_nonblock(0,0); serial_open(device); + serial_interrupt_priority(); r= oop_fd_nonblock(serial_fd, 1); if (r) diee("nonblock(serial_fd,1)"); events->on_fd(events, serial_fd, OOP_READ, serial_readable, 0); diff --git a/hostside/serial-irq-priority b/hostside/serial-irq-priority index aee45b4..3b3350b 100755 --- a/hostside/serial-irq-priority +++ b/hostside/serial-irq-priority @@ -1,15 +1,22 @@ #!/bin/bash set -ex -exec 4&2 "start-stop-daemon said $ssd ?"; exit 1;; -esac -pid="${ssd##* }" -pid="${pid%.}" +cd /var/run +p=serial-irq-priority-poke +rm -f $p +mkfifo -m 622 $p +exec 3<>$p -echo chrt -p 55 $pid +while read -n 1 <&3 dummy; do -exec sleep 1000000000 + ssd=`start-stop-daemon --stop -t -u root -n irq/4-serial` + case "$ssd" in + "Would send signal 15 to "*.) + pid="${ssd##* }" + pid="${pid%.}" + chrt -p 55 $pid ||: + ;; + *) echo >&2 "start-stop-daemon said $ssd ?"; continue;; + esac + +done