[mythtv] Crash of MythMusic

Gerhard Gappmeier gerhard.gappmeier at ascolab.com
Thu Mar 22 10:59:04 UTC 2007


Stuart Morgan schrieb:
> On Thursday 22 March 2007 09:24:24 Gerhard Gappmeier wrote:
>   
>> sorry for my late answer, but your mail was in my spam folder...
>> I attached my backtrace already in my last mail.
>> It was version 0.20 (revsision 12172) on Gentoo.
>> I already checked out HEAD from subversion and compiled it,
>> but I had no time to test for now.
>> I also use MythTV for recording via DVB-T.
>> So I can test if I see deadlocks with the patch.
>> But first I will test the current version without the patch
>> to see if the problem still happens.
>> I think so, because the list still isn't lock.
>>     
>
> The problem does occur in Head. I've discovered a way to reproduce it easily 
> so I won't need another backtrace after all.
>
> I think I'll try and fix this at the weekend. Now I'm able to reproduce the 
> problem it should be a little easier. The locks may be the correct solution, 
> it certainly shouldn't have been written without locks at least, but I'd like 
> to work out the exact mechanism behind the problem. It would seem that some 
> cleanup may be needed when we switch decoders.
>   
sounds good.

If the time for locking is too long, and blocks other threads,
a ReadWrite-Lock could maybe enhance the behavior.

So you can read (and iterate) over the list without blocking other readers.
Only writing (modifying) the list should use a Write-Lock, which prevents
other threads from reading at the same time.

Qt has already an implementation for that.
http://doc.trolltech.com/4.2/qreadwritelock.html

You can also implement such a thing yourself with a QSemaphore
in Qt3.

E.g.
#define MAX_READERS 10
QSemaphore sem(MAX_READERS); // 10 parallel readers

void Sample::readLock()
{
  sem.acquire(1);
}
void Sample::readUnlock()
{
  sem.release(1);
}
void Sample::writeLock()
{
  /* calling acquire(1) in a loop is better than sem.acquire(MAX_READERS),
      because otherwise you have no good chance to acquire a write lock */
  for (i=0; i<MAX_READERS; i++)
  {
    sem.acquire(1);
  }
}
void Sample::writeUnlock()
{
  sem.release(MAX_READERS);
}

regards,
Gerhard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mythtv.org/pipermail/mythtv-dev/attachments/20070322/9f37c0af/attachment.htm 


More information about the mythtv-dev mailing list