From fadbf0a6f72540b025987a2b3df3f9edd4e3e411 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Tue, 20 Nov 2007 03:44:25 +0000 Subject: Make threads responsible for explicit cancellation of their own boosted status. Sleeping and timeouts will no longer cancel it. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15709 a1c6a512-1295-4272-9138-f99709370657 --- apps/buffering.c | 2 +- apps/debug_menu.c | 23 +++++++++++------------ apps/playback.c | 3 +++ apps/recorder/radio.c | 5 +++++ apps/tree.c | 1 + apps/voice_thread.c | 2 +- 6 files changed, 22 insertions(+), 14 deletions(-) (limited to 'apps') diff --git a/apps/buffering.c b/apps/buffering.c index d5ed4e2..18cdb99 100644 --- a/apps/buffering.c +++ b/apps/buffering.c @@ -563,7 +563,6 @@ static bool yield_codec(void) while (pcmbuf_is_lowdata() && !buffer_is_low()) { sleep(2); - trigger_cpu_boost(); if (!queue_empty(&buffering_queue)) return true; @@ -1267,6 +1266,7 @@ void buffering_thread(void) while (true) { + cancel_cpu_boost(); queue_wait_w_tmo(&buffering_queue, &ev, filling?5:HZ/2); switch (ev.id) diff --git a/apps/debug_menu.c b/apps/debug_menu.c index e3f576d..a8eb786 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -124,16 +124,14 @@ static char thread_status_char(unsigned status) static char* threads_getname(int selected_item, void * data, char *buffer) { (void)data; + struct thread_entry *thread; char name[32]; - struct thread_entry *thread = NULL; - unsigned status; - int usage; #if NUM_CORES > 1 if (selected_item < (int)NUM_CORES) { - usage = idle_stack_usage(selected_item); - snprintf(buffer, MAX_PATH, "Idle (%d): %2d%%", selected_item, usage); + snprintf(buffer, MAX_PATH, "Idle (%d): %2d%%", selected_item, + idle_stack_usage(selected_item)); return buffer; } @@ -141,25 +139,26 @@ static char* threads_getname(int selected_item, void * data, char *buffer) #endif thread = &threads[selected_item]; - status = thread_get_status(thread); - - if (status == STATE_KILLED) + + if (thread->state == STATE_KILLED) { snprintf(buffer, MAX_PATH, "%2d: ---", selected_item); return buffer; } thread_get_name(name, 32, thread); - usage = thread_stack_usage(thread); snprintf(buffer, MAX_PATH, "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d ") "%2d%% %s", selected_item, IF_COP(thread->core,) - (status == STATE_RUNNING) ? '*' : ' ', - thread_status_char(status), +#ifdef HAVE_SCHEDULER_BOOSTCTRL + (thread->boosted) ? '+' : +#endif + ((thread->state == STATE_RUNNING) ? '*' : ' '), + thread_status_char(thread->state), IF_PRIO(thread->priority,) - usage, name); + thread_stack_usage(thread), name); return buffer; } diff --git a/apps/playback.c b/apps/playback.c index 5b9f568..782c613 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -848,6 +848,7 @@ static bool codec_pcmbuf_insert_callback( while ((dest = pcmbuf_request_buffer(&out_count)) == NULL) { + cancel_cpu_boost(); sleep(1); if (ci.seek_time || ci.new_track || ci.stop_codec) return true; @@ -1277,6 +1278,7 @@ static void codec_thread(void) while (1) { status = 0; + cancel_cpu_boost(); queue_wait(&codec_queue, &ev); switch (ev.id) { @@ -2388,6 +2390,7 @@ static void audio_thread(void) while (1) { + cancel_cpu_boost(); queue_wait_w_tmo(&audio_queue, &ev, HZ/2); switch (ev.id) { diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index 7a45027..d576755 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c @@ -553,6 +553,11 @@ int radio_screen(void) trigger_cpu_boost(); } + if (!update_screen) + { + cancel_cpu_boost(); + } + #if CONFIG_CODEC != SWCODEC /* TODO: Can we timeout at HZ when recording since peaks aren't displayed? This should quiet recordings too. */ diff --git a/apps/tree.c b/apps/tree.c index 13b0756..5274733 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -1034,6 +1034,7 @@ bool create_playlist(void) add_dir(filename, sizeof(filename), fd); close(fd); + cancel_cpu_boost(); sleep(HZ); return true; diff --git a/apps/voice_thread.c b/apps/voice_thread.c index 9e74786..f7494f9 100644 --- a/apps/voice_thread.c +++ b/apps/voice_thread.c @@ -249,7 +249,7 @@ static void voice_message(struct voice_thread_data *td) } /* Cancel boost */ - sleep(0); + cancel_cpu_boost(); td->state = TSTATE_STOPPED; event_set_state(&voice_event, STATE_SIGNALED); -- cgit v1.1