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>
This commit is contained in:
committed by
Antonio Borneo
parent
beff3de2ce
commit
db16b3dc5b
@@ -333,7 +333,7 @@ struct target_timer_callback {
|
||||
unsigned int time_ms;
|
||||
enum target_timer_type type;
|
||||
bool removed;
|
||||
struct timeval when;
|
||||
int64_t when; /* output of timeval_ms() */
|
||||
void *priv;
|
||||
struct target_timer_callback *next;
|
||||
};
|
||||
@@ -407,6 +407,11 @@ int target_call_timer_callbacks(void);
|
||||
* a synchronous command completes.
|
||||
*/
|
||||
int target_call_timer_callbacks_now(void);
|
||||
/**
|
||||
* Returns when the next registered event will take place. Callers can use this
|
||||
* to go to sleep until that time occurs.
|
||||
*/
|
||||
int64_t target_timer_next_event(void);
|
||||
|
||||
struct target *get_target_by_num(int num);
|
||||
struct target *get_current_target(struct command_context *cmd_ctx);
|
||||
@@ -790,4 +795,6 @@ int target_profiling_default(struct target *target, uint32_t *samples, uint32_t
|
||||
|
||||
extern bool get_target_reset_nag(void);
|
||||
|
||||
#define TARGET_DEFAULT_POLLING_INTERVAL 100
|
||||
|
||||
#endif /* OPENOCD_TARGET_TARGET_H */
|
||||
|
||||
Reference in New Issue
Block a user