Fixed compile and operational behaviors when running with SIM_ASYNCH_CLOCKS enabled

This commit is contained in:
Mark Pizzolato 2013-05-04 12:22:50 -07:00
parent b30211c2a4
commit f8da94e001
2 changed files with 71 additions and 10 deletions

View file

@ -763,6 +763,57 @@ extern int32 sim_asynch_inst_latency;
else \
(void)0
#endif /* !defined(SIM_ASYNCH_MUX) && !defined(SIM_ASYNCH_CLOCKS) */
#if !defined(SIM_ASYNCH_MUX) && defined(SIM_ASYNCH_CLOCKS)
#define AIO_CANCEL(uptr) \
if ((uptr)->a_cancel) \
(uptr)->a_cancel (uptr); \
else { \
if (AIO_IS_ACTIVE (uptr)) { \
UNIT *cptr, *nptr; \
AIO_UPDATE_QUEUE; \
pthread_mutex_lock (&sim_timer_lock); \
nptr = QUEUE_LIST_END; \
if ((uptr) == sim_wallclock_queue) { \
sim_wallclock_queue = (uptr)->next; \
(uptr)->next = NULL; \
} \
else \
for (cptr = sim_wallclock_queue; \
(cptr != QUEUE_LIST_END); \
cptr = cptr->next) \
if (cptr->next == (uptr)) { \
cptr->next = (uptr)->next; \
nptr = cptr; \
(uptr)->next = NULL; \
break; \
} \
if (nptr == QUEUE_LIST_END) { \
sim_timer_event_canceled = TRUE; \
pthread_cond_signal (&sim_timer_wake); \
} \
if ((uptr)->next == NULL) \
(uptr)->a_due_time = (uptr)->a_usec_delay = 0; \
else { \
nptr = QUEUE_LIST_END; \
if ((uptr) == sim_clock_cosched_queue) { \
sim_clock_cosched_queue = (uptr)->next; \
(uptr)->next = NULL; \
} \
else \
for (cptr = sim_clock_cosched_queue; \
(cptr != QUEUE_LIST_END); \
cptr = cptr->next) \
if (cptr->next == (uptr)) { \
cptr->next = (uptr)->next; \
nptr = cptr; \
(uptr)->next = NULL; \
break; \
} \
} \
pthread_mutex_unlock (&sim_timer_lock); \
} \
}
#endif
#if defined(SIM_ASYNCH_MUX) && !defined(SIM_ASYNCH_CLOCKS)
#define AIO_CANCEL(uptr) \
if ((uptr)->a_cancel) \
@ -832,6 +883,8 @@ extern int32 sim_asynch_inst_latency;
pthread_mutex_unlock (&sim_timer_lock); \
} \
}
#endif
#if defined(SIM_ASYNCH_CLOCKS)
#define AIO_RETURN_TIME(uptr) \
if (1) { \
pthread_mutex_lock (&sim_timer_lock); \

View file

@ -1427,8 +1427,8 @@ if (1) {
}
pthread_mutex_lock (&sim_timer_lock);
sim_wallclock_entry = uptr;
pthread_mutex_unlock (&sim_timer_lock);
pthread_cond_signal (&sim_timer_wake); /* wake the timer thread to deal with it */
pthread_mutex_unlock (&sim_timer_lock);
return SCPE_OK;
#else
return _sim_activate (uptr, inst_delay); /* queue it now */
@ -1451,18 +1451,26 @@ else
if (sim_asynch_enabled && sim_asynch_timer) {
if (!sim_is_active (uptr)) { /* already active? */
#if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_CLOCKS)
sim_debug (DBG_TIM, &sim_timer_dev, "sim_clock_coschedule() - queueing %s for clock co-schedule\n", sim_uname (uptr));
pthread_mutex_lock (&sim_timer_lock);
uptr->next = sim_clock_cosched_queue;
sim_clock_cosched_queue = uptr;
pthread_mutex_unlock (&sim_timer_lock);
if ((sim_calb_tmr != -1) &&
(rtc_elapsed[sim_calb_tmr ] >= sim_idle_stable)) {
sim_debug (DBG_TIM, &sim_timer_dev, "sim_clock_coschedule() - queueing %s for clock co-schedule\n", sim_uname (uptr));
pthread_mutex_lock (&sim_timer_lock);
uptr->next = sim_clock_cosched_queue;
sim_clock_cosched_queue = uptr;
pthread_mutex_unlock (&sim_timer_lock);
return SCPE_OK;
}
else {
#else
int32 t;
t = sim_activate_time (sim_clock_unit);
return sim_activate (uptr, t? t - 1: interval);
if (1) {
#endif
int32 t;
t = sim_activate_time (sim_clock_unit);
return sim_activate (uptr, t? t - 1: interval);
}
}
sim_debug (DBG_TIM, &sim_timer_dev, "sim_clock_coschedule() - %s is already active\n", sim_uname (uptr));
return SCPE_OK;
}
else {