libstdc++/5198: 3.0.3 linux x m68k build fail: invalid opcodes in c++locale.cc

Aaron J. Grier aaron@frye.com
Mon Feb 4 14:56:00 GMT 2002


On Mon, Feb 04, 2002 at 11:27:53AM +0100, Werner Tuchan wrote:
> I think the solution for the 68000, 68010, cpu32 & 5400 CPUs useing
> the TAS instruction is really dangerous since it may easily deadlock.
> A low priority thread can enter the critical section and may be
> preempted by a high priorty thread which enters the TAS loop and stays
> there forever consuming all CPU cycles so that the low priorty thread
> has no chance to release the lock.

D'oh!  classical priority inversion.  it's been too long since my
introduction to operating systems class.  :)

we have no way to perform a generic yield() in the busyloop, so there
would seem to be no easy way out of this.

> Therefore spinlock implementations usually disable preemption before
> trying to acquire the lock. Actually busy loop spinlocks are only
> usefull on SMP machines anyway. I would recommend that we disable
> interrupts for the latter CPUs in addition to the TAS instruction.

if we are turning off interrupts for the whole operation, and nobody
else can get into __exchange_and_add without turning off interrupts,
then why bother with the TAS at all?

there's got to be an elegant solution somewhere.  :)

-- 
  Aaron J. Grier  |   Frye Electronics, Tigard, OR   |  aaron@frye.com
     "In a few thousand years people will be scratching their heads
       wondering how on earth the first computer was invented and
          bootstrapped without a prior computer to do it with."
                    --  Chris Malcolm, on comp.arch



More information about the Gcc-bugs mailing list