From 88d7a3fba686289cefd729ebb21318f2cccb4f59 Mon Sep 17 00:00:00 2001 From: Jim Date: Mon, 5 Sep 2011 16:20:26 -0400 Subject: [PATCH] Add a way for device to be polled when CPU is idle. Maybe this can be used to interleave user processes with device & DIM processes, for example, during a file upload. --- em.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/em.c b/em.c index ad0e6de..7ab4629 100644 --- a/em.c +++ b/em.c @@ -1744,13 +1744,16 @@ static unsigned short tstq(ea_t qcbea) { return (qbot-qtop) & qmask; } - -/* I/O device map table, containing function pointers to handle device I/O */ +/* devpoll: number of instructions until device poll + devpollidle: true if device wants to be polled when CPU is idle */ static int devpoll[64] = {0}; +static int devpollidle[64] = {0}; #include "emdev.h" +/* I/O device map table, containing function pointers to handle device I/O */ + #ifdef HOBBY /* this is the "hobby system" controller configuration: @@ -6622,14 +6625,20 @@ d_bdx: /* 0140734 */ stopwatch_start(&sw_idle); utempl = gvp->instpermsec*100; /* limit delay to 100 msecs */ - for (i=0; i<64; i++) /* check device timers */ - if (devpoll[i]) /* poll set? */ - if (devpoll[i] <= 100) { /* too fast! */ - utempl = 1; - break; - } else if (devpoll[i] < utempl) - utempl = devpoll[i]; - + for (i=0; i<64; i++) /* see if any devices */ + if (devpollidle[i]) { /* want a poll when idle? */ + devpoll[i] = 1; /* yes, force it now */ + utempl = 1; + } + if (utempl > 1) + for (i=0; i<64; i++) /* check device timers */ + if (devpoll[i]) /* poll set? */ + if (devpoll[i] <= 100) { /* too fast! */ + utempl = 1; + break; + } else if (devpoll[i] < utempl) + utempl = devpoll[i]; + /* this decrement ensures that if a device had a poll pending, we won't decrement it to zero below, ie, it'll still fire in the main loop */