Srivatsa S. Bhat <srivatsa.b...@linux.vnet.ibm.com> wrote:

> We can use global rwlocks as shown below safely, without fear of deadlocks:
> 
> Readers:
> 
>          CPU 0                                CPU 1
>          ------                               ------
> 
> 1.    spin_lock(&random_lock);             read_lock(&my_rwlock);
> 
> 
> 2.    read_lock(&my_rwlock);               spin_lock(&random_lock);

The lock order on CPU 0 is unsafe if CPU2 can do:

        write_lock(&my_rwlock);
        spin_lock(&random_lock);

and on CPU 1 if CPU2 can do:

        spin_lock(&random_lock);
        write_lock(&my_rwlock);

I presume you were specifically excluding these situations?

David
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Reply via email to