[parisc-linux] missing barrier in _raw_spin_lock?

John David Anglin dave at hiauly1.hia.nrc.ca
Sat Jan 24 14:15:44 MST 2004


> >> static int x;
> >> static spinlock_t lock;
> >>
> >> void test(void)
> >> {
> >>         if (x) {
> >>                 spin_lock(&lock);
> >>                 if (!x)
> >>                         x = 0x1234;
> >>                 spin_unlock(&lock);
> >>         }
> >> }

The test is wrong.  Static variables are initialized to 0.  So, the first
`if' is never true and the code will optimize to a return instruction.

Dave
-- 
J. David Anglin                                  dave.anglin at nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)


More information about the parisc-linux mailing list