[ECOS] FreeBSD-stack ping is unresponsive upon low priority thread spending 100% CPU

Øyvind Harboe oyvind.harboe@zylin.com
Thu Oct 9 15:43:00 GMT 2008


On Thu, Oct 9, 2008 at 5:37 PM, Nick Garnett <nickg@ecoscentric.com> wrote:
> "Øyvind Harboe" <oyvind.harboe@zylin.com> writes:
>
>> The low priority thread is holding a mutex while it's eating all the CPU.
>>
>> When I remove this mutex eating all the CPU no longer blocks ping.
>>
>> This mutex is essentially used to single thread a web server thread
>> (athttpd) and the application so it is held for *long* periods of time.
>> There is a shared tcl interpreter between the ahttpd web server and
>> application.
>>
>> I can easily believe that priority inversion code is messing things up here,
>> but I'll have to read up some more to figure out a better way to
>> achieve the single threading.
>
> That sounds familiar. We've seen problems like that before.
>
> Mutexes are really intended to be held for short periods of mutual
> exclusion. Longer durations should be handled by using condition
> variables, which don't participate in priority inversion protection.
>
> You could implement the exclusion you need with a mutex, a condition
> variable and a mutex-protected boolean. However, this is essentially
> just a binary semaphore, so the simplest thing to do is to replace
> your mutex with a semaphore.

Yup.

For now setting default priority inversion protocol to NONE fixes the
problem. I'll revisit it later.

cdl_option CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT {
    user_value NONE
};



-- 
Øyvind Harboe
http://www.zylin.com/zy1000.html
ARM7 ARM9 XScale Cortex
JTAG debugger and flash programmer

Free eCos workshop in Oslo October 21!
http://www.zylin.com/workshop.html

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list