SCP: Add FLUSH_INTERVAL register to override the default 30 second buffer flush

As indirectly discussed for debug output to a file in #957
This commit is contained in:
Mark Pizzolato 2020-11-15 14:28:25 -08:00
parent ba5e18e963
commit b0ac93294e

15
scp.c
View file

@ -708,7 +708,6 @@ static const char *sim_int_expect_description (DEVICE *dptr)
return "Expect facility"; return "Expect facility";
} }
#define FLUSH_INTERVAL 30*1000000 /* Flush I/O buffers every 30 seconds */
static UNIT sim_expect_unit = { UDATA (&expect_svc, 0, 0) }; static UNIT sim_expect_unit = { UDATA (&expect_svc, 0, 0) };
DEVICE sim_expect_dev = { DEVICE sim_expect_dev = {
"INT-EXPECT", &sim_expect_unit, NULL, NULL, "INT-EXPECT", &sim_expect_unit, NULL, NULL,
@ -720,12 +719,18 @@ DEVICE sim_expect_dev = {
static const char *sim_int_flush_description (DEVICE *dptr) static const char *sim_int_flush_description (DEVICE *dptr)
{ {
return "Flush facility"; return "Open File Flush facility";
} }
static uint32 sim_flush_interval = 30; /* Flush I/O buffers every 30 seconds */
static REG sim_flush_reg[] = {
{ DRDATAD(FLUSH_INTERVAL, sim_flush_interval, 32, "Periodic Buffer Flush Interval (seconds)") },
{ NULL}
};
static UNIT sim_flush_unit = { UDATA (&flush_svc, UNIT_IDLE, 0) }; static UNIT sim_flush_unit = { UDATA (&flush_svc, UNIT_IDLE, 0) };
DEVICE sim_flush_dev = { DEVICE sim_flush_dev = {
"INT-FLUSH", &sim_flush_unit, NULL, NULL, "INT-FLUSH", &sim_flush_unit, sim_flush_reg, NULL,
1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, DEV_NOSAVE, 0, NULL, DEV_NOSAVE, 0,
@ -8560,7 +8565,7 @@ tmxr_flush_log_files ();
t_stat t_stat
flush_svc (UNIT *uptr) flush_svc (UNIT *uptr)
{ {
sim_activate_after (uptr, FLUSH_INTERVAL); sim_activate_after (uptr, sim_flush_interval * 1000000);
sim_flush_buffered_files (); sim_flush_buffered_files ();
return SCPE_OK; return SCPE_OK;
} }
@ -8757,7 +8762,7 @@ if (signal (SIGTERM, int_handler) == SIG_ERR) { /* set WRU */
} }
if (sim_step) /* set step timer */ if (sim_step) /* set step timer */
sim_sched_step (); sim_sched_step ();
sim_activate_after (&sim_flush_unit, FLUSH_INTERVAL); /* Enable periodic buffer flushing */ sim_activate_after (&sim_flush_unit, sim_flush_interval * 1000000);/* Enable periodic buffer flushing */
stop_cpu = FALSE; stop_cpu = FALSE;
sim_is_running = TRUE; /* flag running */ sim_is_running = TRUE; /* flag running */
fflush(stdout); /* flush stdout */ fflush(stdout); /* flush stdout */