summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorMichael Brown2017-09-06 00:21:34 +0200
committerMichael Brown2017-09-06 00:23:22 +0200
commit7e6b367b7ef5994916459bcac5d772a0a574c1d3 (patch)
tree321fb6f614d4a933be5853a6511b8d39aa16b28b /src/core
parent[netdevice] Cancel all pending transmissions on any transmit error (diff)
downloadipxe-7e6b367b7ef5994916459bcac5d772a0a574c1d3.tar.gz
ipxe-7e6b367b7ef5994916459bcac5d772a0a574c1d3.tar.xz
ipxe-7e6b367b7ef5994916459bcac5d772a0a574c1d3.zip
[monojob] Check for job progress only once per timer tick
Checking for job progress is essentially a user interface activity, and can safely be performed only once per timer tick (as is already done with checking for keypresses). Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/monojob.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/core/monojob.c b/src/core/monojob.c
index 817f21b2..d426235d 100644
--- a/src/core/monojob.c
+++ b/src/core/monojob.c
@@ -64,7 +64,7 @@ struct interface monojob = INTF_INIT ( monojob_intf_desc );
*/
int monojob_wait ( const char *string, unsigned long timeout ) {
struct job_progress progress;
- unsigned long last_keycheck;
+ unsigned long last_check;
unsigned long last_progress;
unsigned long last_display;
unsigned long now;
@@ -81,26 +81,28 @@ int monojob_wait ( const char *string, unsigned long timeout ) {
if ( string )
printf ( "%s...", string );
monojob_rc = -EINPROGRESS;
- last_keycheck = last_progress = last_display = currticks();
+ last_check = last_progress = last_display = currticks();
while ( monojob_rc == -EINPROGRESS ) {
/* Allow job to progress */
step();
now = currticks();
- /* Check for keypresses. This can be time-consuming,
- * so check only once per clock tick.
+ /* Continue until a timer tick occurs (to minimise
+ * time wasted checking for progress and keypresses).
*/
- elapsed = ( now - last_keycheck );
- if ( elapsed ) {
- if ( iskey() ) {
- key = getchar();
- if ( key == CTRL_C ) {
- monojob_rc = -ECANCELED;
- break;
- }
+ elapsed = ( now - last_check );
+ if ( ! elapsed )
+ continue;
+ last_check = now;
+
+ /* Check for keypresses */
+ if ( iskey() ) {
+ key = getchar();
+ if ( key == CTRL_C ) {
+ monojob_rc = -ECANCELED;
+ break;
}
- last_keycheck = now;
}
/* Monitor progress */