forked from len0rd/rockbox
Simulator: get rid of SDL_mutex* parameter to sim_do_exit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26338 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
8ea056db4b
commit
6ce5279ff3
3 changed files with 22 additions and 14 deletions
|
|
@ -144,14 +144,11 @@ static int sdl_event_thread(void * param)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sim_do_exit(SDL_mutex *m)
|
void sim_do_exit(void)
|
||||||
{
|
{
|
||||||
/* wait for event thread to finish */
|
/* wait for event thread to finish */
|
||||||
SDL_WaitThread(evt_thread, NULL);
|
SDL_WaitThread(evt_thread, NULL);
|
||||||
|
|
||||||
/* cleanup */
|
|
||||||
SDL_DestroyMutex(m);
|
|
||||||
|
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
while(1);
|
while(1);
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ void sim_kernel_shutdown(void);
|
||||||
void sys_poweroff(void);
|
void sys_poweroff(void);
|
||||||
void sys_handle_argv(int argc, char *argv[]);
|
void sys_handle_argv(int argc, char *argv[]);
|
||||||
bool gui_message_loop(void);
|
bool gui_message_loop(void);
|
||||||
|
void sim_do_exit(void);
|
||||||
|
|
||||||
extern bool background; /* True if the background image is enabled */
|
extern bool background; /* True if the background image is enabled */
|
||||||
extern bool showremote;
|
extern bool showremote;
|
||||||
|
|
|
||||||
|
|
@ -60,12 +60,13 @@ static jmp_buf thread_jmpbufs[MAXTHREADS];
|
||||||
* that enables us to simulate a cooperative environment even if
|
* that enables us to simulate a cooperative environment even if
|
||||||
* the host is preemptive */
|
* the host is preemptive */
|
||||||
static SDL_mutex *m;
|
static SDL_mutex *m;
|
||||||
static volatile bool threads_exit = false;
|
#define THREADS_RUN 0
|
||||||
|
#define THREADS_EXIT 1
|
||||||
|
#define THREADS_EXIT_COMMAND_DONE 2
|
||||||
|
static volatile int threads_status = THREADS_RUN;
|
||||||
|
|
||||||
extern long start_tick;
|
extern long start_tick;
|
||||||
|
|
||||||
void sim_do_exit(SDL_mutex *m);
|
|
||||||
|
|
||||||
void sim_thread_shutdown(void)
|
void sim_thread_shutdown(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -79,7 +80,7 @@ void sim_thread_shutdown(void)
|
||||||
on each unlock but that is safe. */
|
on each unlock but that is safe. */
|
||||||
|
|
||||||
/* Do this before trying to acquire lock */
|
/* Do this before trying to acquire lock */
|
||||||
threads_exit = true;
|
threads_status = THREADS_EXIT;
|
||||||
|
|
||||||
/* Take control */
|
/* Take control */
|
||||||
SDL_LockMutex(m);
|
SDL_LockMutex(m);
|
||||||
|
|
@ -122,6 +123,9 @@ void sim_thread_shutdown(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UnlockMutex(m);
|
SDL_UnlockMutex(m);
|
||||||
|
|
||||||
|
/* Signal completion of operation */
|
||||||
|
threads_status = THREADS_EXIT_COMMAND_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void new_thread_id(unsigned int slot_num,
|
static void new_thread_id(unsigned int slot_num,
|
||||||
|
|
@ -210,8 +214,14 @@ void init_threads(void)
|
||||||
|
|
||||||
SDL_UnlockMutex(m);
|
SDL_UnlockMutex(m);
|
||||||
|
|
||||||
/* doesn't return */
|
/* Set to 'COMMAND_DONE' when other rockbox threads have exited. */
|
||||||
sim_do_exit(m);
|
while (threads_status < THREADS_EXIT_COMMAND_DONE)
|
||||||
|
SDL_Delay(10);
|
||||||
|
|
||||||
|
SDL_DestroyMutex(m);
|
||||||
|
|
||||||
|
/* We're the main thead - perform exit - doesn't return. */
|
||||||
|
sim_do_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sim_thread_exception_wait(void)
|
void sim_thread_exception_wait(void)
|
||||||
|
|
@ -219,7 +229,7 @@ void sim_thread_exception_wait(void)
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
SDL_Delay(HZ/10);
|
SDL_Delay(HZ/10);
|
||||||
if (threads_exit)
|
if (threads_status != THREADS_RUN)
|
||||||
thread_exit();
|
thread_exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -230,7 +240,7 @@ void sim_thread_lock(void *me)
|
||||||
SDL_LockMutex(m);
|
SDL_LockMutex(m);
|
||||||
cores[CURRENT_CORE].running = (struct thread_entry *)me;
|
cores[CURRENT_CORE].running = (struct thread_entry *)me;
|
||||||
|
|
||||||
if (threads_exit)
|
if (threads_status != THREADS_RUN)
|
||||||
thread_exit();
|
thread_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -371,7 +381,7 @@ void switch_thread(void)
|
||||||
|
|
||||||
cores[CURRENT_CORE].running = current;
|
cores[CURRENT_CORE].running = current;
|
||||||
|
|
||||||
if (threads_exit)
|
if (threads_status != THREADS_RUN)
|
||||||
thread_exit();
|
thread_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -474,7 +484,7 @@ int runthread(void *data)
|
||||||
cores[CURRENT_CORE].running = current;
|
cores[CURRENT_CORE].running = current;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!threads_exit)
|
if (threads_status == THREADS_RUN)
|
||||||
{
|
{
|
||||||
current->context.start();
|
current->context.start();
|
||||||
THREAD_SDL_DEBUGF("Thread Done: %d (%s)\n",
|
THREAD_SDL_DEBUGF("Thread Done: %d (%s)\n",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue