Call poll at a fixed interval.
authorTim Newsome <tim@sifive.com>
Fri, 9 Jul 2021 19:58:07 +0000 (12:58 -0700)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 31 Jul 2021 09:08:47 +0000 (10:08 +0100)
commitdb16b3dc5b061c152f2478a5b9b7b3a3b0908911
tree97d7d067da9b1a6b51842c28adbb5404ad86d594
parentbeff3de2ce7e275bf8c0051641dfc1acb0ecee9a
Call poll at a fixed interval.

The existing implementation blocks in select() for a fixed amount of
time. This change tracks when the next event (likely poll()) wants to be
run, and uses a shorter timeout in select() if necessary.

Also track all these timeouts using milliseconds as returned by
timeval_ms() instead of `struct timeval` to simplify the code.

This feature is helpful if poll() wants to do something like sample PCs
or memory values for basically the entire time that otherwise OpenOCD
would be hung in select(). See
https://github.com/riscv/riscv-openocd/pull/541 for an example of that.
The RISC-V code using this change will be upstreamed some day, too.

Signed-off-by: Tim Newsome <tim@sifive.com>
Change-Id: I67104a7cf69ed07c8399c14aa55963fc5116a67d
Reviewed-on: http://openocd.zylin.com/6363
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
src/server/server.c
src/target/target.c
src/target/target.h