summaryrefslogtreecommitdiff
path: root/uisimulator/common/io.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-09-10 03:49:12 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-09-10 03:49:12 +0000
commitc4a7631eb9235f72de569f5e578620c6e2bc6818 (patch)
tree1e67525787351b2637fab8a4fe0ae140398c9219 /uisimulator/common/io.c
parent2e305c6381c72aaabc6d0f92459b32d8939691fb (diff)
downloadrockbox-c4a7631eb9235f72de569f5e578620c6e2bc6818.tar.gz
rockbox-c4a7631eb9235f72de569f5e578620c6e2bc6818.zip
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
Diffstat (limited to 'uisimulator/common/io.c')
-rw-r--r--uisimulator/common/io.c19
1 files changed, 13 insertions, 6 deletions
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)
233 (void)data; 233 (void)data;
234} 234}
235 235
236void sim_io_init(void) 236bool sim_io_init(void)
237{ 237{
238 mutex_init(&io.sim_mutex);
239
240 io.ready = 0; 238 io.ready = 0;
241 239
242 io.m = SDL_CreateMutex(); 240 io.m = SDL_CreateMutex();
243 if (io.m == NULL) 241 if (io.m == NULL)
244 { 242 {
245 fprintf(stderr, "Failed to create IO mutex\n"); 243 fprintf(stderr, "Failed to create IO mutex\n");
246 exit(-1); 244 return false;
247 } 245 }
248 246
249 io.c = SDL_CreateCond(); 247 io.c = SDL_CreateCond();
250 if (io.c == NULL) 248 if (io.c == NULL)
251 { 249 {
252 fprintf(stderr, "Failed to create IO cond\n"); 250 fprintf(stderr, "Failed to create IO cond\n");
253 exit(-1); 251 return false;
254 } 252 }
255 253
256 io.t = SDL_CreateThread(io_thread, NULL); 254 io.t = SDL_CreateThread(io_thread, NULL);
257 if (io.t == NULL) 255 if (io.t == NULL)
258 { 256 {
259 fprintf(stderr, "Failed to create IO thread\n"); 257 fprintf(stderr, "Failed to create IO thread\n");
260 exit(-1); 258 return false;
261 } 259 }
262 260
263 /* Wait for IO thread to lock mutex */ 261 /* Wait for IO thread to lock mutex */
@@ -268,6 +266,15 @@ void sim_io_init(void)
268 SDL_LockMutex(io.m); 266 SDL_LockMutex(io.m);
269 /* Free it for another thread */ 267 /* Free it for another thread */
270 SDL_UnlockMutex(io.m); 268 SDL_UnlockMutex(io.m);
269
270 return true;
271}
272
273int ata_init(void)
274{
275 /* Initialize the rockbox kernel objects on a rockbox thread */
276 mutex_init(&io.sim_mutex);
277 return 1;
271} 278}
272 279
273void sim_io_shutdown(void) 280void sim_io_shutdown(void)