12.29

    no deadlock

    initial: a = 1, b = 1, c = 1

    thread 1 thread 2
    P(a) P(c)
    P(b) P(b)
    V(b) V(b)
    P(c) V(c)
    V(c) ——
    V(a) ——

    thread 2 doesn’t manipulate mutex a and initial a is 1, so P(a), V(a) don’t affect deadlock status.

    thread 1 thread 2
    P(b) P(c)
    V(b) P(b)
    P(c) V(b)
    V(c) V(c)
    1. +
    2. |
    3. |
    4. + +----------+
    5. V(c)| | |
    6. | | |
    7. + | |
    8. | | |
    9. | | |
    10. + +----------+ | |
    11. V(b)| | | | |
    12. | | | | |
    13. + | | | |
    14. | | | | |
    15. | | | | |
    16. + +----------+ | |
    17. P(b)| | |
    18. | | |
    19. + | |
    20. | | |
    21. | | |
    22. + +----------+
    23. P(c)|
    24. |
    25. +
    26. |
    27. |
    28. +----+----+----+----+----+----+----+----+----+ thread 1
    29. P(b) V(b) P(c) V(c)