diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-02-11 18:49:27 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2018-03-06 11:30:41 -0500 |
commit | 43ac56766e39d9a85372cdf7c1926ffa049f9342 (patch) | |
tree | 8f08858c1a0f6cb2d7967b9ed33fdd5630f3b715 /klippy/serialqueue.c | |
parent | afc9bcf27bedf0a4f16265ef3acd4990e8f642fe (diff) | |
download | kutter-43ac56766e39d9a85372cdf7c1926ffa049f9342.tar.gz kutter-43ac56766e39d9a85372cdf7c1926ffa049f9342.tar.xz kutter-43ac56766e39d9a85372cdf7c1926ffa049f9342.zip |
serialqueue: Support sending messages at a background priority
Support low-priority message transmits. This may be useful for bulk
commands that should be delayed util the comms are otherwise idle.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/serialqueue.c')
-rw-r--r-- | klippy/serialqueue.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/klippy/serialqueue.c b/klippy/serialqueue.c index 7f7d7fd9..2f7c25a5 100644 --- a/klippy/serialqueue.c +++ b/klippy/serialqueue.c @@ -389,6 +389,7 @@ struct serialqueue { #define MIN_RTO 0.025 #define MAX_RTO 5.000 #define MIN_REQTIME_DELTA 0.250 +#define MIN_BACKGROUND_DELTA 0.005 #define IDLE_QUERY_TIME 1.0 #define DEBUG_QUEUE_SENT 100 @@ -722,8 +723,13 @@ check_send_command(struct serialqueue *sq, double eventtime) if (!list_empty(&cq->ready_queue)) { struct queue_message *qm = list_first_entry( &cq->ready_queue, struct queue_message, node); - if (qm->req_clock < min_ready_clock) - min_ready_clock = qm->req_clock; + uint64_t req_clock = qm->req_clock; + if (req_clock == BACKGROUND_PRIORITY_CLOCK) + req_clock = (uint64_t)( + (sq->idle_time - sq->last_clock_time + MIN_BACKGROUND_DELTA) + * sq->est_freq) + sq->last_clock; + if (req_clock < min_ready_clock) + min_ready_clock = req_clock; } } @@ -907,7 +913,8 @@ serialqueue_send_batch(struct serialqueue *sq, struct command_queue *cq int len = 0; struct queue_message *qm; list_for_each_entry(qm, msgs, node) { - if (qm->min_clock + (1LL<<31) < qm->req_clock) + if (qm->min_clock + (1LL<<31) < qm->req_clock + && qm->req_clock != BACKGROUND_PRIORITY_CLOCK) qm->min_clock = qm->req_clock - (1LL<<31); len += qm->len; } |