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.
This commit is contained in:
Aaron Giles 2009-12-24 02:52:17 +00:00
parent 83175680b7
commit 67bef66987
4 changed files with 73 additions and 7 deletions

View File

@ -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).

View File

@ -227,6 +227,9 @@ 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)
for (window = win_window_list; window != NULL; window = window->next)

View File

@ -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,15 +456,48 @@ static int is_double_click_start(int argc)
static DWORD WINAPI watchdog_thread_entry(LPVOID lpParameter)
{
DWORD timeout = (int)(FPTR)lpParameter * 1000;
while (TRUE)
{
HANDLE handle_list[2];
DWORD wait_result;
wait_result = WaitForSingleObject(watchdog_exit_event, timeout);
// 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
//============================================================

View File

@ -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);