Fixed compile and operational behaviors when running with SIM_ASYNCH_CLOCKS enabled
This commit is contained in:
parent
b30211c2a4
commit
f8da94e001
2 changed files with 71 additions and 10 deletions
53
sim_defs.h
53
sim_defs.h
|
@ -763,6 +763,57 @@ extern int32 sim_asynch_inst_latency;
|
||||||
else \
|
else \
|
||||||
(void)0
|
(void)0
|
||||||
#endif /* !defined(SIM_ASYNCH_MUX) && !defined(SIM_ASYNCH_CLOCKS) */
|
#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)
|
#if defined(SIM_ASYNCH_MUX) && !defined(SIM_ASYNCH_CLOCKS)
|
||||||
#define AIO_CANCEL(uptr) \
|
#define AIO_CANCEL(uptr) \
|
||||||
if ((uptr)->a_cancel) \
|
if ((uptr)->a_cancel) \
|
||||||
|
@ -832,6 +883,8 @@ extern int32 sim_asynch_inst_latency;
|
||||||
pthread_mutex_unlock (&sim_timer_lock); \
|
pthread_mutex_unlock (&sim_timer_lock); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#if defined(SIM_ASYNCH_CLOCKS)
|
||||||
#define AIO_RETURN_TIME(uptr) \
|
#define AIO_RETURN_TIME(uptr) \
|
||||||
if (1) { \
|
if (1) { \
|
||||||
pthread_mutex_lock (&sim_timer_lock); \
|
pthread_mutex_lock (&sim_timer_lock); \
|
||||||
|
|
12
sim_timer.c
12
sim_timer.c
|
@ -1427,8 +1427,8 @@ if (1) {
|
||||||
}
|
}
|
||||||
pthread_mutex_lock (&sim_timer_lock);
|
pthread_mutex_lock (&sim_timer_lock);
|
||||||
sim_wallclock_entry = uptr;
|
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_cond_signal (&sim_timer_wake); /* wake the timer thread to deal with it */
|
||||||
|
pthread_mutex_unlock (&sim_timer_lock);
|
||||||
return SCPE_OK;
|
return SCPE_OK;
|
||||||
#else
|
#else
|
||||||
return _sim_activate (uptr, inst_delay); /* queue it now */
|
return _sim_activate (uptr, inst_delay); /* queue it now */
|
||||||
|
@ -1451,18 +1451,26 @@ else
|
||||||
if (sim_asynch_enabled && sim_asynch_timer) {
|
if (sim_asynch_enabled && sim_asynch_timer) {
|
||||||
if (!sim_is_active (uptr)) { /* already active? */
|
if (!sim_is_active (uptr)) { /* already active? */
|
||||||
#if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_CLOCKS)
|
#if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_CLOCKS)
|
||||||
|
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));
|
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);
|
pthread_mutex_lock (&sim_timer_lock);
|
||||||
uptr->next = sim_clock_cosched_queue;
|
uptr->next = sim_clock_cosched_queue;
|
||||||
sim_clock_cosched_queue = uptr;
|
sim_clock_cosched_queue = uptr;
|
||||||
pthread_mutex_unlock (&sim_timer_lock);
|
pthread_mutex_unlock (&sim_timer_lock);
|
||||||
|
return SCPE_OK;
|
||||||
|
}
|
||||||
|
else {
|
||||||
#else
|
#else
|
||||||
|
if (1) {
|
||||||
|
#endif
|
||||||
int32 t;
|
int32 t;
|
||||||
|
|
||||||
t = sim_activate_time (sim_clock_unit);
|
t = sim_activate_time (sim_clock_unit);
|
||||||
return sim_activate (uptr, t? t - 1: interval);
|
return sim_activate (uptr, t? t - 1: interval);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
sim_debug (DBG_TIM, &sim_timer_dev, "sim_clock_coschedule() - %s is already active\n", sim_uname (uptr));
|
||||||
return SCPE_OK;
|
return SCPE_OK;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue