Skip to content

question about homework in chapter30 threads-cv #67

@tangxibomb

Description

@tangxibomb

homework 4, run ./main-two-cvs-while -p 1 -c 3 -m 1 -C 0,0,0,1,0,0,0:0,0,0,1,0,0,0:0,0,0,1,0,0,0 -l 10 -v -t

the output is

NF         P0 C0 C1 C2 
  0 [*--- ] p0
  0 [*--- ]    c0
  0 [*--- ]       c0
  0 [*--- ]          c0
  0 [*--- ]       c1
  0 [*--- ]       c2
  0 [*--- ]    c1
  0 [*--- ]    c2
.....

It seems that thread c1 execute Mutex_lock(&m);while (num_full == 0) {,so thread c1 get the lock.

Then the CPU run thread c0,want to execute the same code.when he run Mutex_lock(&m); ,the lock is owned by c1.So he won't return from this routine.But the output shows that thread c0 has executed the Mutex_lock(&m);while (num_full == 0) {.

WHY?
I have a poor english.I 'll be appreciated if someone can answer me!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions