Subj : Re: mutex&threads To : comp.programming.threads From : Valerio Bardelli Date : Tue Mar 22 2005 08:21 pm Hi Steve, >Steve Watt wrote: > In article , > Valerio Bardelli wrote: >>I've a big problem with a porting of linux on a mips board (based on IDT >>R4K). The problem is about mutex, threads and scheduling. > > Actually, your problem is about real-time operating systems, or current > lack thereof. I know, I know... but, what I have on my disposition, at the moment, is a normal Linux kernel, and I cannot apply any realtime patches in my kernel because this is already patched by IDT (the R4K CPU builder)... this is what IDT experts say me... If I don't use any mutex in my thread attached to the interrupt via device driver I have no problem even if I have an interrupt each 2.5ms... What interest me here is to know the behaviour of linux scheduler with my threads when I have a mutex... What I see is very strange and, it seems, unpredictable behaviour... > [ snip ] > >>I've monitored the duration of my routine at priority 99 (A) (attached to >>the interrupt via device driver) and I'm very surpriesed to see that, >>sometimes, but often, my routine duration is about 20ms. Normally my >>routine duration is about 100us (micro sec). > > You basically have two choices: > 1) Upgrade to a more current Linux that has kernel preemption support, or Do you intend a 2.6 kernel? But, what about device drivers in 2.6 kernel? I know that they are very different from device drivers in 2.4... > 2) Upgrade to a real RTOS. Yes. Normally we use ThreadX. But I have ethernet ports on my board, and TCPIP support for ThreadX is expensive, for Linux is free... :-)) > If you have a hard scheduling requirement that is in the hundred > microsecond range, I know a "normal" Linux won't get there. A Linux > kernel with preemption will usually get there. If you require 100% > guarantees, you need a real-time operating system. I know LynxOS has > a Linux binary emulation that I understand works quite well, and it's > also reasonably source-compatable. Other RTOSes may be able to > help, as well, depending on how much you're willing to modify your > application. Ok Steve. But what about the behaviour of linux scheduler with my threads when I use a mutex? Isn't it very strange? Why I see, sometimes and often, a delay of 20ms? Thanks a lot for your interest on my problem. Ciao, Valerio. .