From 27cf67733936abd75fcb1f8da765977cd75906ee Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Tue, 25 Mar 2008 02:34:12 +0000 Subject: Add a complete priority inheritance implementation to the scheduler (all mutex ownership and queue_send calls are inheritable). Priorities are differential so that dispatch depends on the runnable range of priorities. Codec priority can therefore be raised in small steps (pcmbuf updated to enable). Simplify the kernel functions to ease implementation and use the same kernel.c for both sim and target (I'm tired of maintaining two ;_). 1) Not sure if a minor audio break at first buffering issue will exist on large-sector disks (the main mutex speed issue was genuinely resolved earlier). At this point it's best dealt with at the buffering level. It seems a larger filechunk could be used again. 2) Perhaps 64-bit sims will have some minor issues (finicky) but a backroll of the code of concern there is a 5-minute job. All kernel objects become incompatible so a full rebuild and update is needed. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16791 a1c6a512-1295-4272-9138-f99709370657 --- apps/pcmbuf.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'apps/pcmbuf.c') diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c index 8153118715..8f16c90523 100644 --- a/apps/pcmbuf.c +++ b/apps/pcmbuf.c @@ -116,7 +116,7 @@ static bool low_latency_mode = false; static bool pcmbuf_flush; #ifdef HAVE_PRIORITY_SCHEDULING -static int codec_thread_priority = 0; +static int codec_thread_priority = PRIORITY_PLAYBACK; #endif extern struct thread_entry *codec_thread_p; @@ -256,18 +256,21 @@ static void boost_codec_thread(bool boost) * will starve if the codec thread's priority is boosted. */ if (boost) { - if (codec_thread_priority == 0) + int priority = (PRIORITY_PLAYBACK - PRIORITY_PLAYBACK_MAX)*pcmbuf_unplayed_bytes + / (2*NATIVE_FREQUENCY) + PRIORITY_PLAYBACK_MAX; + + if (priority != codec_thread_priority) { - codec_thread_priority = thread_set_priority( - codec_thread_p, PRIORITY_REALTIME); - voice_thread_set_priority(PRIORITY_REALTIME); + codec_thread_priority = priority; + thread_set_priority(codec_thread_p, priority); + voice_thread_set_priority(priority); } } - else if (codec_thread_priority != 0) + else if (codec_thread_priority != PRIORITY_PLAYBACK) { - thread_set_priority(codec_thread_p, codec_thread_priority); - voice_thread_set_priority(codec_thread_priority); - codec_thread_priority = 0; + thread_set_priority(codec_thread_p, PRIORITY_PLAYBACK); + voice_thread_set_priority(PRIORITY_PLAYBACK); + codec_thread_priority = PRIORITY_PLAYBACK; } } #endif /* HAVE_PRIORITY_SCHEDULING */ @@ -818,7 +821,7 @@ static bool prepare_insert(size_t length) if (low_latency_mode) { /* 1/4s latency. */ - if (pcmbuf_unplayed_bytes > NATIVE_FREQUENCY * 4 / 4 + if (pcmbuf_unplayed_bytes > NATIVE_FREQUENCY * 4 / 2 && pcm_is_playing()) return false; } -- cgit v1.2.3