Fixed Asynch I/O issues which may leave pending asynch I/O in limbo when device resets happen (found by Sergey Oboguev)

This commit is contained in:
Mark Pizzolato 2012-04-10 05:43:59 -07:00
parent a339dae651
commit 1cb4eb7960
5 changed files with 18 additions and 1 deletions

View file

@ -2561,6 +2561,7 @@ rq_clrint (cp); /* clr intr req */
for (i = 0; i < (RQ_NUMDR + 2); i++) { /* init units */ for (i = 0; i < (RQ_NUMDR + 2); i++) { /* init units */
uptr = dptr->units + i; uptr = dptr->units + i;
sim_cancel (uptr); /* clr activity */ sim_cancel (uptr); /* clr activity */
sim_disk_reset (uptr);
uptr->cnum = cidx; /* set ctrl index */ uptr->cnum = cidx; /* set ctrl index */
uptr->flags = uptr->flags & ~(UNIT_ONL | UNIT_ATP); uptr->flags = uptr->flags & ~(UNIT_ONL | UNIT_ATP);
uptr->uf = 0; /* clr unit flags */ uptr->uf = 0; /* clr unit flags */

View file

@ -606,7 +606,7 @@ extern int32 sim_asynch_inst_latency;
#elif defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) || defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) #elif defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) || defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)
#define InterlockedCompareExchangePointer(Destination, Exchange, Comparand) __sync_val_compare_and_swap(Destination, Comparand, Exchange) #define InterlockedCompareExchangePointer(Destination, Exchange, Comparand) __sync_val_compare_and_swap(Destination, Comparand, Exchange)
#elif defined(__DECC_VER) #elif defined(__DECC_VER)
#define InterlockedCompareExchangePointer(Destination, Exchange, Comparand) (void *)((int32)_InterlockedCompareExchange64_rel(Destination, Exchange, Comparand)) #define InterlockedCompareExchangePointer(Destination, Exchange, Comparand) (void *)((int32)_InterlockedCompareExchange64(Destination, Exchange, Comparand))
#else #else
#error "Implementation of function InterlockedCompareExchangePointer() is needed to build with USE_AIO_INTRINSICS" #error "Implementation of function InterlockedCompareExchangePointer() is needed to build with USE_AIO_INTRINSICS"
#endif #endif

View file

@ -1073,6 +1073,16 @@ if (close_function (fileref) == EOF)
return SCPE_OK; return SCPE_OK;
} }
t_stat sim_disk_reset (UNIT *uptr)
{
if (!(uptr->flags & UNIT_ATT)) /* attached? */
return SCPE_OK;
_sim_disk_io_flush(uptr);
AIO_VALIDATE;
AIO_UPDATE_QUEUE;
return SCPE_OK;
}
/* Factory bad block table creation routine /* Factory bad block table creation routine
This routine writes a DEC standard 044 compliant bad block table on the This routine writes a DEC standard 044 compliant bad block table on the

View file

@ -78,6 +78,7 @@ t_stat sim_disk_set_capac (UNIT *uptr, int32 val, char *cptr, void *desc);
t_stat sim_disk_show_capac (FILE *st, UNIT *uptr, int32 val, void *desc); t_stat sim_disk_show_capac (FILE *st, UNIT *uptr, int32 val, void *desc);
t_stat sim_disk_set_asynch (UNIT *uptr, int latency); t_stat sim_disk_set_asynch (UNIT *uptr, int latency);
t_stat sim_disk_clr_asynch (UNIT *uptr); t_stat sim_disk_clr_asynch (UNIT *uptr);
t_stat sim_disk_reset (UNIT *uptr);
t_bool sim_disk_isavailable (UNIT *uptr); t_bool sim_disk_isavailable (UNIT *uptr);
t_bool sim_disk_isavailable_a (UNIT *uptr, DISK_PCALLBACK callback); t_bool sim_disk_isavailable_a (UNIT *uptr, DISK_PCALLBACK callback);
t_bool sim_disk_wrp (UNIT *uptr); t_bool sim_disk_wrp (UNIT *uptr);

View file

@ -1715,6 +1715,11 @@ return r;
t_stat sim_tape_reset (UNIT *uptr) t_stat sim_tape_reset (UNIT *uptr)
{ {
MT_CLR_PNU (uptr); MT_CLR_PNU (uptr);
if (!(uptr->flags & UNIT_ATT)) /* attached? */
return SCPE_OK;
_sim_tape_io_flush(uptr);
AIO_VALIDATE;
AIO_UPDATE_QUEUE;
return SCPE_OK; return SCPE_OK;
} }