From: Guillermo J. Rozas Date: Sat, 4 Sep 1993 07:08:54 +0000 (+0000) Subject: Add a catatonia timer. X-Git-Tag: 20090517-FFI~7896 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=de17aa9c7cc4f5604a848096e029159a6da21d52;p=mit-scheme.git Add a catatonia timer. --- diff --git a/v7/src/microcode/ntgui.c b/v7/src/microcode/ntgui.c index 8cdb4ff83..a9542e9a3 100644 --- a/v7/src/microcode/ntgui.c +++ b/v7/src/microcode/ntgui.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ntgui.c,v 1.8 1993/09/03 17:56:44 gjr Exp $ +$Id: ntgui.c,v 1.9 1993/09/04 07:03:43 gjr Exp $ Copyright (c) 1993 Massachusetts Institute of Technology @@ -32,15 +32,15 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ +#include +#include #include "scheme.h" #include "prims.h" -#include "nt.h" #include "os.h" +#include "nt.h" +#include "ntdialog.h" #include "ntgui.h" #include "ntscreen.h" -#include "ntdialog.h" -#include -#include extern /*static*/ HANDLE ghInstance = 0; @@ -189,21 +189,35 @@ DEFUN_VOID (nt_gui_default_poll) } extern HANDLE master_tty_window; +extern void catatonia_trigger (void); + +void +catatonia_trigger (void) +{ + if ((MessageBox (master_tty_window, + "Scheme appears to have become catatonic.\n" + "OK to kill it?", + "MIT Scheme", + (MB_ICONSTOP | MB_OKCANCEL))) + == IDOK) + { + extern void termination_normal (int); + termination_normal (0); + } + else + { + Registers[REGBLOCK_CATATONIA_COUNTER] = 0; + return; + } +} static void nt_gui_high_priority_poll (void) { MSG close_msg; - if (PeekMessage (&close_msg, - master_tty_window, -#if 0 - WM_HOTKEY, - (WM_HOTKEY + 1), -#else - WM_CLOSE, - (WM_CLOSE + 1), -#endif + if (PeekMessage (&close_msg, master_tty_window, + WM_CATATONIC, (WM_CATATONIC + 1), PM_REMOVE)) { MIT_TranslateMessage (&close_msg); @@ -211,7 +225,7 @@ nt_gui_high_priority_poll (void) } return; } - + DEFINE_PRIMITIVE ("MICROCODE-POLL-INTERRUPT-HANDLER", Prim_microcode_poll_interrupt_handler, 2, 2, "NT High-priority timer interrupt handler for Windows I/O.") @@ -228,6 +242,7 @@ DEFINE_PRIMITIVE ("MICROCODE-POLL-INTERRUPT-HANDLER", } else { + Registers[REGBLOCK_CATATONIA_COUNTER] = 0; nt_gui_default_poll (); #ifndef USE_WM_TIMER low_level_timer_tick (); @@ -247,6 +262,8 @@ DEFINE_PRIMITIVE ("NT-DEFAULT-POLL-GUI", Prim_nt_default_poll_gui, 2, 2, } } +extern void EXFUN (NT_gui_init, (void)); + void DEFUN_VOID (NT_gui_init) { diff --git a/v7/src/microcode/ntgui.h b/v7/src/microcode/ntgui.h index 1b2566ae5..4608e7f17 100644 --- a/v7/src/microcode/ntgui.h +++ b/v7/src/microcode/ntgui.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ntgui.h,v 1.3 1993/06/24 02:14:39 gjr Exp $ +$Id: ntgui.h,v 1.4 1993/09/04 07:04:23 gjr Exp $ Copyright (c) 1993 Massachusetts Institute of Technology @@ -35,8 +35,6 @@ MIT in each case. */ #ifndef SCM_NTGUI_H #define SCM_NTGUI_H -void EXFUN (NT_gui_init, (void)); - #define IDM_NEW 100 #define IDM_OPEN 101 #define IDM_SAVE 102 @@ -56,4 +54,12 @@ void EXFUN (NT_gui_init, (void)); #define IDM_ABOUT 303 #define IDM_EMERGENCYKILL 400 +#ifndef REGBLOCK_CATATONIA_COUNTER +/* They must be contiguous, with counter being lower. */ +# define REGBLOCK_CATATONIA_COUNTER REGBLOCK_MINIMUM_LENGTH +# define REGBLOCK_CATATONIA_LIMIT (REGBLOCK_MINIMUM_LENGTH + 1) +#endif + +#define WM_CATATONIC (WM_USER) + #endif /* SCM_NTGUI_H */ diff --git a/v7/src/microcode/ntscmlib.h b/v7/src/microcode/ntscmlib.h index 5cf2fdced..9ca34d25f 100644 --- a/v7/src/microcode/ntscmlib.h +++ b/v7/src/microcode/ntscmlib.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ntscmlib.h,v 1.2 1993/08/21 03:38:52 gjr Exp $ +$Id: ntscmlib.h,v 1.3 1993/09/04 07:01:36 gjr Exp $ Copyright (c) 1993 Massachusetts Institute of Technology @@ -70,12 +70,16 @@ extern void unsigned long); /* size */ extern UINT - win32_install_async_timer (unsigned long *, /* regs */ + win32_install_async_timer (void **, /* timer state */ + unsigned long *, /* regs */ unsigned long, /* memtop off */ unsigned long, /* int_code off */ unsigned long, /* int_mask off */ unsigned long, /* mask */ - void **); /* timer state */ + unsigned long, /* ctr_off */ + unsigned long, /* message */ + HWND); /* window */ + extern void win32_flush_async_timer (void *); @@ -136,12 +140,15 @@ struct ntw32lib_vulock_s #define NTW32LIB_INSTALL_TIMER 3 struct ntw32lib_itimer_s { + SCM_ULONG handle; /* ->32 */ SCM_ULPTR base; /* ->16 */ SCM_ULONG memtop_off; /* ->16 */ SCM_ULONG int_code_off; /* ->16 */ SCM_ULONG int_mask_off; /* ->16 */ SCM_ULONG bit_mask; /* ->16 */ - SCM_ULONG handle; /* ->32 */ + SCM_ULONG ctr_off; /* ->16 */ + SCM_ULONG message; /* ->16 */ + SCM_ULONG window; /* ->16 */ }; #define NTW32LIB_FLUSH_TIMER 4 diff --git a/v7/src/microcode/ntscreen.c b/v7/src/microcode/ntscreen.c index eaa9c4870..0ca478280 100644 --- a/v7/src/microcode/ntscreen.c +++ b/v7/src/microcode/ntscreen.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ntscreen.c,v 1.14 1993/09/03 18:01:28 gjr Exp $ +$Id: ntscreen.c,v 1.15 1993/09/04 07:06:52 gjr Exp $ Copyright (c) 1993 Massachusetts Institute of Technology @@ -34,6 +34,7 @@ MIT in each case. */ #include #include "ntscreen.h" +#include "ntgui.h" //#include "screen.rh" /* Allow conditionalization for underlying OS. */ extern BOOL win32_under_win32s_p (void); @@ -629,6 +630,13 @@ ScreenWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) DestroyScreenInfo (hWnd); break ; + case WM_CATATONIC: + { + extern void catatonia_trigger (void); + catatonia_trigger (); + break; + } + case WM_CLOSE: { extern HANDLE master_tty_window; diff --git a/v7/src/microcode/ntscreen.h b/v7/src/microcode/ntscreen.h index fd3a005cc..dd2222de0 100644 --- a/v7/src/microcode/ntscreen.h +++ b/v7/src/microcode/ntscreen.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ntscreen.h,v 1.7 1993/09/03 17:57:40 gjr Exp $ +$Id: ntscreen.h,v 1.8 1993/09/04 07:06:11 gjr Exp $ Copyright (c) 1993 Massachusetts Institute of Technology @@ -166,7 +166,7 @@ BOOL Screen_PeekEvent (HANDLE, SCREEN_EVENT *); //--------------------------------------------------------------------------- #ifndef SCREEN_COMMAND_FIRST -#define SCREEN_COMMAND_FIRST WM_USER +#define SCREEN_COMMAND_FIRST (WM_USER + 10) #endif #define SCREEN_WRITE (SCREEN_COMMAND_FIRST+0) diff --git a/v7/src/microcode/ntsig.c b/v7/src/microcode/ntsig.c index 93f98c385..b4cd1c0bc 100644 --- a/v7/src/microcode/ntsig.c +++ b/v7/src/microcode/ntsig.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ntsig.c,v 1.9 1993/09/03 18:02:29 gjr Exp $ +$Id: ntsig.c,v 1.10 1993/09/04 07:08:22 gjr Exp $ Copyright (c) 1992-1993 Massachusetts Institute of Technology @@ -38,17 +38,18 @@ MIT in each case. */ */ #include "scheme.h" -#include "nt.h" -#include +#include "critsec.h" #include "ossig.h" #include "osctty.h" #include "ostty.h" -#include "critsec.h" -#include "ntsys.h" +#include "nt.h" +#include "ntgui.h" #include "ntio.h" -#include "extern.h" -#include "ntscreen.h" #include "ntscmlib.h" +#include "ntscreen.h" +#include "ntsys.h" + +extern HANDLE master_tty_window; /* Signal mask manipulation */ @@ -156,7 +157,6 @@ master_tty_interrupt (HWND tty, WORD command) static void DEFUN_VOID (update_interrupt_characters) { - extern HANDLE master_tty_window; int i; for (i = 0; i < KB_INT_TABLE_SIZE; i++) @@ -402,29 +402,32 @@ DEFUN_VOID (OS_restartable_exit) return; } -/* Timer interrupt */ +/* System-level timer interrupt */ -/* Why does this raise INT_Timer as well? - We could request an synchronous Windows timer that would trigger - the timer interrupt bit. -- This does not seem to work! - - INT_Global_GC: High-priority Windows polling interrupt. +/* INT_Global_GC: High-priority Windows polling interrupt. INT_Global_1: Windows polling interrupt. - INT_Timer: Thread-switch timer interrupt. */ +#define CATATONIA_PERIOD 60000 /* msec */ +#define ASYNC_TIMER_PERIOD 50 /* msec */ + static void * timer_state = ((void *) NULL); static char * DEFUN_VOID (install_timer) { - switch (win32_install_async_timer (&Registers[0], + Registers[REGBLOCK_CATATONIA_COUNTER] = 0; + Registers[REGBLOCK_CATATONIA_LIMIT] + = (CATATONIA_PERIOD / ASYNC_TIMER_PERIOD); + switch (win32_install_async_timer (&timer_state, + &Registers[0], REGBLOCK_MEMTOP, REGBLOCK_INT_CODE, REGBLOCK_INT_MASK, - (INT_Global_GC - | INT_Global_1), - &timer_state)) + (INT_Global_GC | INT_Global_1), + REGBLOCK_CATATONIA_COUNTER, + WM_CATATONIC, + master_tty_window)) { case WIN32_ASYNC_TIMER_OK: return (NULL); diff --git a/v7/src/microcode/nttop.c b/v7/src/microcode/nttop.c index e7e1e9f2a..c2f198056 100644 --- a/v7/src/microcode/nttop.c +++ b/v7/src/microcode/nttop.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: nttop.c,v 1.9 1993/09/03 18:04:32 gjr Exp $ +$Id: nttop.c,v 1.10 1993/09/04 07:08:54 gjr Exp $ Copyright (c) 1993 Massachusetts Institute of Technology @@ -33,7 +33,6 @@ promotional, or sales literature without prior written consent from MIT in each case. */ #include "nt.h" -#include "ntgui.h" #include "nttop.h" #include "osctty.h" #include "prims.h" @@ -43,6 +42,7 @@ MIT in each case. */ extern void EXFUN (execute_reload_cleanups, (void)); +extern void EXFUN (NT_gui_init, (void)); extern void EXFUN (NT_initialize_channels, (void)); extern void EXFUN (NT_initialize_directory_reader, (void)); extern void EXFUN (NT_initialize_signals, (void)); diff --git a/v7/src/microcode/ntutl/makefile b/v7/src/microcode/ntutl/makefile index cedc91619..c9c12ae8c 100644 --- a/v7/src/microcode/ntutl/makefile +++ b/v7/src/microcode/ntutl/makefile @@ -1,6 +1,6 @@ ### -*- Fundamental -*- ### -### $Id: makefile,v 1.11 1993/09/03 17:50:09 gjr Exp $ +### $Id: makefile,v 1.12 1993/09/04 06:59:05 gjr Exp $ ### ### Copyright (c) 1992-1993 Massachusetts Institute of Technology ### @@ -413,16 +413,17 @@ NT_DEPENDENCIES = oscond.h ansidecl.h posixtyp.h intext.h \ ntenv.obj : scheme.tch osenv.h ntscreen.h $(NT_DEPENDENCIES) ntfile.obj : osfile.h osio.h ntio.h $(NT_DEPENDENCIES) ntfs.obj : osfs.h $(NT_DEPENDENCIES) -ntio.obj : osio.h ntio.h $(NT_DEPENDENCIES) +ntio.obj : osio.h ntio.h ntscreen.h $(NT_DEPENDENCIES) nttop.obj : ostop.h nttop.h osctty.h errors.h option.h $(NT_DEPENDENCIES) nttty.obj : ostty.h osenv.h osio.h ntio.h osterm.h ntterm.h $(NT_DEPENDENCIES) -ntsig.obj : ossig.h osctty.h ostty.h critsec.h $(NT_DEPENDENCIES) ntscmlib.h +ntsig.obj : ossig.h osctty.h ostty.h critsec.h \ + $(NT_DEPENDENCIES) ntgui.h ntio.h ntscmlib.h ntscreen.h nttrap.obj: nttrap.h ntscmlib.h $(GC_HEAD_FILES) $(NT_DEPENDENCIES) ntsys.obj: ntsys.h -ntgui.obj : ntgui.c ntdialog.h ntscreen.h $(NT_DEPENDENCIES) scheme.tch +ntgui.obj : ntgui.c ntdialog.h ntgui.h ntscreen.h $(NT_DEPENDENCIES) scheme.tch ntasutl.obj : ntasutl.asm ntkbutl.obj : ntkbutl.asm -ntscreen.obj : ntscreen.c ntscreen.h +ntscreen.obj : ntscreen.c ntgui.h ntscreen.h prntenv.obj : $(NT_DEPENDENCIES) prntfs.obj : $(NT_DEPENDENCIES) scheme.tch prims.h osfs.h prntio.obj : $(NT_DEPENDENCIES) scheme.tch prims.h ntio.h osio.h syscall.h diff --git a/v7/src/microcode/ntutl/scheme16.c b/v7/src/microcode/ntutl/scheme16.c index 72520e442..264d5757f 100644 --- a/v7/src/microcode/ntutl/scheme16.c +++ b/v7/src/microcode/ntutl/scheme16.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: scheme16.c,v 1.4 1993/08/24 04:53:32 gjr Exp $ +$Id: scheme16.c,v 1.5 1993/09/04 06:59:59 gjr Exp $ Copyright (c) 1993 Massachusetts Institute of Technology @@ -305,18 +305,20 @@ MK_FP (unsigned short seg, unsigned short off) static WORD htimer = 0; static unsigned long timer_index = 0; - static WORD (FAR PASCAL * KillSystemTimer) (WORD htimer); static struct ntw16lib_itimer_s { struct ntw16lib_itimer_s FAR * next; + unsigned long index; unsigned long FAR * base; unsigned long memtop_off; unsigned long int_code_off; unsigned long int_mask_off; unsigned long bit_mask; - unsigned long index; + unsigned long ctr_off; + UINT message; + HWND window; UINT selector; HGLOBAL ghan; } FAR * async_timers = ((struct ntw16lib_itimer_s FAR *) NULL); @@ -333,17 +335,28 @@ scheme_asynctimer (void) & scm_timer->bit_mask) != 0) scm_timer->base[scm_timer->memtop_off] = ((unsigned long) -1L); + scm_timer->base[scm_timer->ctr_off] += 1L; + if ((scm_timer->base[scm_timer->ctr_off] + > scm_timer->base[scm_timer->ctr_off + 1]) + && (scm_timer->base[scm_timer->ctr_off + 1] != 0)) + { + PostMessage (scm_timer->window, + scm_timer->message, + ((WPARAM) 0), + ((LPARAM) 0)); + scm_timer->base[scm_timer->ctr_off] = 0L; + } scm_timer = scm_timer->next; } return; } - + static void scheme_asynctimer_end (void) { return; } - + static void possibly_uninstall_async_handler (void) { @@ -475,14 +488,17 @@ win16_install_timer (struct ntw32lib_itimer_s FAR * buf) return (WIN32_ASYNC_TIMER_NOLDT); } - scm_timer->ghan = ghan; + scm_timer->next = async_timers; + scm_timer->index = timer_index++; scm_timer->base = (MK_FP (scm_timer->selector, (FP_OFF (buf->base)))); scm_timer->memtop_off = buf->memtop_off; scm_timer->int_code_off = buf->int_code_off; scm_timer->int_mask_off = buf->int_mask_off; scm_timer->bit_mask = buf->bit_mask; - scm_timer->index = timer_index++; - scm_timer->next = async_timers; + scm_timer->ctr_off = buf->ctr_off; + scm_timer->message = ((UINT) buf->message); + scm_timer->window = ((HWND) buf->window); + scm_timer->ghan = ghan; buf->handle = scm_timer->index; async_timers = scm_timer; diff --git a/v7/src/microcode/ntutl/scheme31.c b/v7/src/microcode/ntutl/scheme31.c index 882abb523..2ef62daec 100644 --- a/v7/src/microcode/ntutl/scheme31.c +++ b/v7/src/microcode/ntutl/scheme31.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: scheme31.c,v 1.3 1993/08/24 04:51:20 gjr Exp $ +$Id: scheme31.c,v 1.4 1993/09/04 07:00:37 gjr Exp $ Copyright (c) 1993 Massachusetts Institute of Technology @@ -167,12 +167,15 @@ win32_unlock_memory_area (LPVOID area, unsigned long size) } UINT -win32_install_async_timer (unsigned long * base, +win32_install_async_timer (void ** state_ptr, + unsigned long * base, unsigned long memtop_off, unsigned long int_code_off, unsigned long int_mask_off, unsigned long bit_mask, - void ** state_ptr) + unsigned long ctr_off, + unsigned long message, + HWND window) { struct ntw32lib_itimer_s param; LPVOID translation[2]; @@ -183,6 +186,9 @@ win32_install_async_timer (unsigned long * base, param.int_code_off = ((SCM_ULONG) int_code_off); param.int_mask_off = ((SCM_ULONG) int_mask_off); param.bit_mask = ((SCM_ULONG) bit_mask); + param.ctr_off = ((SCM_ULONG) ctr_off); + param.message = ((SCM_ULONG) message); + param.window = ((SCM_ULONG) window); translation[0] = ((LPVOID) & param.base); translation[1] = ((LPVOID) NULL); diff --git a/v7/src/microcode/ntutl/scheme32.c b/v7/src/microcode/ntutl/scheme32.c index 357017d15..650598ede 100644 --- a/v7/src/microcode/ntutl/scheme32.c +++ b/v7/src/microcode/ntutl/scheme32.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: scheme32.c,v 1.4 1993/09/03 17:50:59 gjr Exp $ +$Id: scheme32.c,v 1.5 1993/09/04 07:01:12 gjr Exp $ Copyright (c) 1993 Massachusetts Institute of Technology @@ -90,6 +90,9 @@ struct win32_timer_closure_s unsigned long int_code_off; unsigned long int_mask_off; unsigned long bit_mask; + unsigned long ctr_off; + unsigned long message; + HWND window; }; static void _stdcall @@ -103,6 +106,17 @@ win32_nt_timer_tick (UINT wID, UINT wMsg, DWORD dwUser, DWORD dw1, DWORD dw2) & timer_closure->bit_mask) != 0) timer_closure->block[timer_closure->memtop_off] = ((unsigned long) -1); + timer_closure->block[timer_closure->ctr_off] += 1; + if ((timer_closure->block[timer_closure->ctr_off] + > timer_closure->block[timer_closure->ctr_off + 1]) + && (timer_closure->block[timer_closure->ctr_off + 1] != 0)) + { + PostMessage (timer_closure->window, + timer_closure->message, + ((WPARAM) 0), + ((LPARAM) 0)); + timer_closure->block[timer_closure->ctr_off] = 0; + } return; } @@ -126,12 +140,15 @@ win32_flush_async_timer (void * state) } UINT -win32_install_async_timer (unsigned long * block, +win32_install_async_timer (void ** state_ptr, + unsigned long * block, unsigned long memtop_off, unsigned long int_code_off, unsigned long int_mask_off, unsigned long bit_mask, - void ** state_ptr) + unsigned long ctr_off, + unsigned long message, + HWND window) { TIMECAPS tc; UINT wTimerRes; @@ -152,12 +169,15 @@ win32_install_async_timer (unsigned long * block, if (timer_closure == ((struct win32_timer_closure_s *) NULL)) return (WIN32_ASYNC_TIMER_NOMEM); + timer_closure->timer_id = 0; timer_closure->block = block; timer_closure->memtop_off = memtop_off; timer_closure->int_code_off = int_code_off; timer_closure->int_mask_off = int_mask_off; timer_closure->bit_mask = bit_mask; - timer_closure->timer_id = 0; + timer_closure->ctr_off = ctr_off; + timer_closure->message = message; + timer_closure->window = window; if ((! (VirtualLock (((void *) timer_closure), (sizeof (struct win32_timer_closure_s)))))