I got this issue, I could not explain how it happens.
I have a task includes 3 threads which access same queue variable in parallel as following:
task t;
int queue1[10][$];
int queue2[10][$];
fork
begin : thread1
forever begin
// Push value to queue1 in some conditions (time consuming)
// Example:
queue1[5].push_back(1);
queue1[5].push_back(2);
end
end
begin : thread2
forever begin
// Push value to queue2 in some conditions (time consuming)
// Example:
queue2[5].push_back(1);
queue2[5].push_back(2);
end
end
begin : thread3
for(int i = 0; i < 10; i++) begin
automatic int item = i;
forever begin
wait(queue1.size() > 0 && queue2.size() > 0);
// Pop value from queue1 and queue2
end
join_none
wait fork;
end
join_any
disable fork;
endtask
In thread3, the code will be block at “wait” statement until “queue1” and “queue2” have data.
But sometimes in my simulation, even the “queue1” and “queue2” have data, the “wait” doesn’t exit immediately to execute the next statement, it keeps blocking.
I don’t understand why.