From c4a7631eb9235f72de569f5e578620c6e2bc6818 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Mon, 10 Sep 2007 03:49:12 +0000 Subject: UISIMULATOR: Do a graceful shutdown of all threads and avoid (mostly lockup) problems caused by not worrying about states. Have rockbox objects initialized only by rockbox threads save for the main 'gui' thread which is a needed exception. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14660 a1c6a512-1295-4272-9138-f99709370657 --- uisimulator/common/io.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'uisimulator/common/io.c') diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c index 463bbc68d9..3ad93dc382 100644 --- a/uisimulator/common/io.c +++ b/uisimulator/common/io.c @@ -233,31 +233,29 @@ static int io_thread(void *data) (void)data; } -void sim_io_init(void) +bool sim_io_init(void) { - mutex_init(&io.sim_mutex); - io.ready = 0; io.m = SDL_CreateMutex(); if (io.m == NULL) { fprintf(stderr, "Failed to create IO mutex\n"); - exit(-1); + return false; } io.c = SDL_CreateCond(); if (io.c == NULL) { fprintf(stderr, "Failed to create IO cond\n"); - exit(-1); + return false; } io.t = SDL_CreateThread(io_thread, NULL); if (io.t == NULL) { fprintf(stderr, "Failed to create IO thread\n"); - exit(-1); + return false; } /* Wait for IO thread to lock mutex */ @@ -268,6 +266,15 @@ void sim_io_init(void) SDL_LockMutex(io.m); /* Free it for another thread */ SDL_UnlockMutex(io.m); + + return true; +} + +int ata_init(void) +{ + /* Initialize the rockbox kernel objects on a rockbox thread */ + mutex_init(&io.sim_mutex); + return 1; } void sim_io_shutdown(void) -- cgit v1.2.3