Port-macppc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: macppc ksem problem



On Mon, Mar 11, 2019 at 18:39:33 +0300, Valery Ushakov wrote:

> Some time ago I ran into a problem with semaphores on macppc.  Few
> days ago I stumbled into a workaround that is rather weird, but might
> help narrow down the search space, so I thought I might post about the
> issue.

I finally had time to look at this, so for the sake of closure...  The
problem was (obviously) something completely different.  libpthread
uses the low bits of pthread_t poiner for rwlock flags, like kernel
rwlocks do.  The kernel uses 4 bits, libpthread needs only three, but
reserves the forth bit anyway.  This is not really a problem since our
malloc always returns memory aligned to 16 bytes, so we do have those
bits in a pointer for us to abuse.  Except inferno comes with its own
allocator.  You probably already see where it's going...
pthread_create needs to grab an rwlock and bit-fiddling magic is
confused by only an 8-bytes aligned pointer.

Never underestimate luck as a factor in software development.

-uwe


Home | Main Index | Thread Index | Old Index