Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From ce9be33ea7a29a73b958a78e1975e3e2e8fdbe49 Mon Sep 17 00:00:00 2001
- From: Thomas Jarosch <tomj@simonv.com>
- Date: Mon, 27 Dec 2010 07:48:53 -0500
- Subject: [PATCH] Fix deadlock on shutdown. Thanks to kugel
- ---
- firmware/target/hosted/sdl/kernel-sdl.c | 24 ++++++++++++++++--------
- 1 files changed, 16 insertions(+), 8 deletions(-)
- diff --git a/firmware/target/hosted/sdl/kernel-sdl.c b/firmware/target/hosted/sdl/kernel-sdl.c
- index b4a7c0e..04082fb 100644
- --- a/firmware/target/hosted/sdl/kernel-sdl.c
- +++ b/firmware/target/hosted/sdl/kernel-sdl.c
- @@ -134,14 +134,14 @@ static bool sim_kernel_init(void)
- void sim_kernel_shutdown(void)
- {
- - disable_irq();
- SDL_RemoveTimer(tick_timer_id);
- - SDL_DestroyMutex(sim_irq_mtx);
- - SDL_DestroyCond(sim_thread_cond);
- #ifndef HAVE_SDL_THREADS
- do_exit = true;
- SDL_CondSignal(wfi_cond);
- #endif
- + disable_irq();
- + SDL_DestroyMutex(sim_irq_mtx);
- + SDL_DestroyCond(sim_thread_cond);
- }
- Uint32 tick_timer(Uint32 interval, void *param)
- @@ -150,10 +150,10 @@ Uint32 tick_timer(Uint32 interval, void *param)
- (void) interval;
- (void) param;
- -
- +
- new_tick = (SDL_GetTicks() - start_tick) / (1000/HZ);
- -
- - while(new_tick != current_tick)
- +
- + while(new_tick != current_tick && !do_exit)
- {
- sim_enter_irq_handler();
- @@ -197,6 +197,14 @@ void wait_for_interrupt(void)
- if (interrupt_level != 0)
- printf("PANIC: Interrupts are disabled!!!\n");
- + if (UNLIKELY(do_exit))
- + {
- + SDL_DestroyCond(wfi_cond);
- + SDL_UnlockMutex(wfi_mutex);
- + SDL_DestroyMutex(wfi_mutex);
- + sim_do_exit();
- + }
- +
- SDL_CondWait(wfi_cond, wfi_mutex);
- if (UNLIKELY(do_exit))
- --
- 1.7.2.3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement