summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2009-12-24 02:52:17 +0000
committer Aaron Giles <aaron@aarongiles.com>2009-12-24 02:52:17 +0000
commit67bef66987ee5adc1f035b4559896bbdf315ad22 (patch)
tree4275310411441bec3e654eadaee67d5bf4c5b16d
parent83175680b7372abd962583f800ea42fd6fbe6f80 (diff)
Changed behavior of -watchdog option to act like a real watchdog. It now
specifies the number of seconds after the last video update that will cause auto-termination of MAME. Also modified it to output a message when the watchdog triggers the exit. Updated windows.txt to reflect this option and the debugger_font options which were never previously documented.
-rw-r--r--docs/windows.txt24
-rw-r--r--src/osd/windows/video.c3
-rw-r--r--src/osd/windows/winmain.c50
-rw-r--r--src/osd/windows/winmain.h3
4 files changed, 73 insertions, 7 deletions
diff --git a/docs/windows.txt b/docs/windows.txt
index 6ea0351f698..9fd62312188 100644
--- a/docs/windows.txt
+++ b/docs/windows.txt
@@ -25,6 +25,25 @@ Windows debugging options
the same time as -log to output the log data to both targets as well.
Default is OFF (-nooslog).
+-watchdog <duration> / -wdog <duration>
+
+ Enables an internal watchdog timer that will automatically kill the MAME
+ process if more than <duration> seconds passes without a frame update.
+ Keep in mind that some games sit for a while during load time without
+ updating the screen, so <duration> should be long enough to cover that.
+ 10-30 seconds on a modern system should be plenty in general. By default
+ there is no watchdog.
+
+-debugger_font <fontname> / -dfont <fontname>
+
+ Specifies the name of the font to use for debugger windows. By default,
+ the font is Lucida Console.
+
+-debugger_font_size <points> / -dfontsize <points>
+
+ Specifies the size of the font to use for debugger windows, in points.
+ By default, this is set to 9pt.
+
Windows performance options
@@ -44,7 +63,7 @@ Windows performance options
which can improve performance on hyperthreaded and multicore systems.
The default is OFF (-nomultithreading).
--numprocessors <auto|value>
+-numprocessors <auto|value> / -np <auto|value>
Specify the number of processors to use for work queues. Specifying
"auto" will use the value reported by the system or environment
variable OSDPROCESSORS. To avoid abuse, this value is internally limited
@@ -52,6 +71,7 @@ Windows performance options
The default is "auto".
+
Windows video options
---------------------
@@ -79,7 +99,7 @@ Windows video options
physical monitor, aspect ratio, resolution, and view, which can be
set using the options below. The default is 1.
--[no]window
+-[no]window / -[no]w
Run MAME in either a window or full screen. The default is OFF
(-nowindow).
diff --git a/src/osd/windows/video.c b/src/osd/windows/video.c
index 7c7019f6c72..30ce7c4e978 100644
--- a/src/osd/windows/video.c
+++ b/src/osd/windows/video.c
@@ -226,6 +226,9 @@ win_monitor_info *winvideo_monitor_from_handle(HMONITOR hmonitor)
void osd_update(running_machine *machine, int skip_redraw)
{
win_window_info *window;
+
+ // ping the watchdog on each update
+ winmain_watchdog_ping();
// if we're not skipping this redraw, update all windows
if (!skip_redraw)
diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c
index 9384b589067..52d0b975188 100644
--- a/src/osd/windows/winmain.c
+++ b/src/osd/windows/winmain.c
@@ -111,6 +111,7 @@ static av_revert_mm_thread_characteristics_ptr av_revert_mm_thread_characteristi
static char mapfile_name[MAX_PATH];
static LPTOP_LEVEL_EXCEPTION_FILTER pass_thru_filter;
+static HANDLE watchdog_reset_event;
static HANDLE watchdog_exit_event;
static HANDLE watchdog_thread;
@@ -359,8 +360,10 @@ void osd_init(running_machine *machine)
// if a watchdog thread is requested, create one
if (watchdog != 0)
{
+ watchdog_reset_event = CreateEvent(NULL, FALSE, FALSE, NULL);
+ assert_always(watchdog_reset_event != NULL, "Failed to create watchdog reset event");
watchdog_exit_event = CreateEvent(NULL, TRUE, FALSE, NULL);
- assert_always(watchdog_exit_event != NULL, "Failed to create watchdog event");
+ assert_always(watchdog_exit_event != NULL, "Failed to create watchdog exit event");
watchdog_thread = CreateThread(NULL, 0, watchdog_thread_entry, (LPVOID)watchdog, 0, NULL);
assert_always(watchdog_thread != NULL, "Failed to create watchdog thread");
}
@@ -378,6 +381,10 @@ static void osd_exit(running_machine *machine)
{
SetEvent(watchdog_exit_event);
WaitForSingleObject(watchdog_thread, INFINITE);
+ CloseHandle(watchdog_reset_event);
+ CloseHandle(watchdog_exit_event);
+ CloseHandle(watchdog_thread);
+ watchdog_reset_event = NULL;
watchdog_exit_event = NULL;
watchdog_thread = NULL;
}
@@ -449,16 +456,49 @@ static int is_double_click_start(int argc)
static DWORD WINAPI watchdog_thread_entry(LPVOID lpParameter)
{
DWORD timeout = (int)(FPTR)lpParameter * 1000;
- DWORD wait_result;
- wait_result = WaitForSingleObject(watchdog_exit_event, timeout);
- if (wait_result == WAIT_TIMEOUT)
- TerminateProcess(GetCurrentProcess(), -1);
+ while (TRUE)
+ {
+ HANDLE handle_list[2];
+ DWORD wait_result;
+
+ // wait for either a reset or an exit, or a timeout
+ handle_list[0] = watchdog_reset_event;
+ handle_list[1] = watchdog_exit_event;
+ wait_result = WaitForMultipleObjects(2, handle_list, FALSE, timeout);
+
+ // on a reset, just loop around and re-wait
+ if (wait_result == WAIT_OBJECT_0 + 0)
+ continue;
+
+ // on an exit, break out
+ if (wait_result == WAIT_OBJECT_0 + 1)
+ break;
+
+ // on a timeout, kill the process
+ if (wait_result == WAIT_TIMEOUT)
+ {
+ fprintf(stderr, "Terminating due to watchdog timeout\n");
+ TerminateProcess(GetCurrentProcess(), -1);
+ }
+ }
return 0;
}
//============================================================
+// winmain_watchdog_ping
+//============================================================
+
+void winmain_watchdog_ping(void)
+{
+ // if we have a watchdog, reset it
+ if (watchdog_reset_event != NULL)
+ SetEvent(watchdog_reset_event);
+}
+
+
+//============================================================
// exception_filter
//============================================================
diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h
index 9f788ac93b8..4142c4b5fa7 100644
--- a/src/osd/windows/winmain.h
+++ b/src/osd/windows/winmain.h
@@ -142,3 +142,6 @@ extern int osd_num_processors;
// use if you want to print something with the verbose flag
void CLIB_DECL mame_printf_verbose(const char *text, ...) ATTR_PRINTF(1,2);
+
+// use this to ping the watchdog
+void winmain_watchdog_ping(void);