1
0
mirror of https://github.com/open-simh/simh.git synced 2026-05-04 23:25:46 +00:00

Fixed bugs in disk and tape operations when running without asynch disabled - bugs reported by Jordi Guillaumes i Pons

This commit is contained in:
Mark Pizzolato
2013-01-07 09:25:57 -08:00
parent df4cc945bb
commit 7e1840eb5f
2 changed files with 28 additions and 14 deletions

View File

@@ -239,19 +239,26 @@ static t_bool _disk_is_active (UNIT *uptr)
{ {
struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx;
sim_debug (ctx->dbit, ctx->dptr, "_disk_is_active(unit=%d, dop=%d)\n", uptr-ctx->dptr->units, ctx->io_dop); if (ctx) {
return (ctx->io_dop != DOP_DONE); sim_debug (ctx->dbit, ctx->dptr, "_disk_is_active(unit=%d, dop=%d)\n", uptr-ctx->dptr->units, ctx->io_dop);
return (ctx->io_dop != DOP_DONE);
}
return FALSE;
} }
static void _disk_cancel (UNIT *uptr) static void _disk_cancel (UNIT *uptr)
{ {
struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx;
sim_debug (ctx->dbit, ctx->dptr, "_disk_cancel(unit=%d, dop=%d)\n", uptr-ctx->dptr->units, ctx->io_dop); if (ctx) {
pthread_mutex_lock (&ctx->io_lock); sim_debug (ctx->dbit, ctx->dptr, "_disk_cancel(unit=%d, dop=%d)\n", uptr-ctx->dptr->units, ctx->io_dop);
while (ctx->io_dop != DOP_DONE) if (ctx->asynch_io) {
pthread_cond_wait (&ctx->io_done, &ctx->io_lock); pthread_mutex_lock (&ctx->io_lock);
pthread_mutex_unlock (&ctx->io_lock); while (ctx->io_dop != DOP_DONE)
pthread_cond_wait (&ctx->io_done, &ctx->io_lock);
pthread_mutex_unlock (&ctx->io_lock);
}
}
} }
#else #else
#define AIO_CALLSETUP #define AIO_CALLSETUP

View File

@@ -314,19 +314,26 @@ static t_bool _tape_is_active (UNIT *uptr)
{ {
struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx;
sim_debug (ctx->dbit, ctx->dptr, "_tape_is_active(unit=%d, top=%d)\n", uptr-ctx->dptr->units, ctx->io_top); if (ctx) {
return (ctx->io_top != TOP_DONE); sim_debug (ctx->dbit, ctx->dptr, "_tape_is_active(unit=%d, top=%d)\n", uptr-ctx->dptr->units, ctx->io_top);
return (ctx->io_top != TOP_DONE);
}
return FALSE;
} }
static void _tape_cancel (UNIT *uptr) static void _tape_cancel (UNIT *uptr)
{ {
struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx;
sim_debug (ctx->dbit, ctx->dptr, "_tape_cancel(unit=%d, top=%d)\n", uptr-ctx->dptr->units, ctx->io_top); if (ctx) {
pthread_mutex_lock (&ctx->io_lock); sim_debug (ctx->dbit, ctx->dptr, "_tape_cancel(unit=%d, top=%d)\n", uptr-ctx->dptr->units, ctx->io_top);
while (ctx->io_top != TOP_DONE) if (ctx->asynch_io) {
pthread_cond_wait (&ctx->io_done, &ctx->io_lock); pthread_mutex_lock (&ctx->io_lock);
pthread_mutex_unlock (&ctx->io_lock); while (ctx->io_top != TOP_DONE)
pthread_cond_wait (&ctx->io_done, &ctx->io_lock);
pthread_mutex_unlock (&ctx->io_lock);
}
}
} }
#else #else
#define AIO_CALLSETUP #define AIO_CALLSETUP