Skip to content

Commit

Permalink
Speed up device update in some error cases.
Browse files Browse the repository at this point in the history
When one of these 3 things happens:
- a kick request is delayed
- a kickout lock is held (similar)
- trough count abruptly changes at end of update

then we restart update, but there is no need to wait for
the switch settle delay (since no switch activity necessarily
happened).  A small delay of 50ms is inserted just to keep
the scheduler happy.  This gets rid of some unnecessary delay
when these things happen for a brief time.
  • Loading branch information
bcd committed Nov 21, 2012
1 parent 237ac2c commit 0934f0f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions common/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ void device_update (void)
*/
task_sleep (dev->props->settle_delay);

start_update:
task_sleep (TIME_50MS);

/* The device is probably stable now. Poll all of the
* switches and recount */
device_recount (dev);
Expand Down Expand Up @@ -397,14 +400,14 @@ void device_update (void)
{
/* Container ready to kick, but 1 or more
* locks are held so we must wait. */
goto wait_and_recount;
goto start_update;
}
else if (!device_call_boolean_op (dev, kick_request))
{
/* Inform other modules that a kick was requested.
These handlers can return FALSE to delay (but not
cancel) the kick. */
goto wait_and_recount;
goto start_update;
}
/* TODO - if multiple devices want to kick at the same time,
* they should be staggered a bit. Another case should be
Expand Down Expand Up @@ -445,7 +448,7 @@ void device_update (void)
be a race condition where a switch closure gets missed. */
device_recount (dev);
if (dev->actual_count != dev->previous_count)
goto wait_and_recount;
goto start_update;

task_exit ();
}
Expand Down

0 comments on commit 0934f0f

Please sign in to comment.