Skip to content

Conversation

Mike-debug
Copy link

@Mike-debug Mike-debug commented May 30, 2025

It is easy to reproduce this deadlock problem using the original code DispatchQueue.cc.

void s1(int thread) {
    std::cout << "Thread " << thread << " is sleeping for 10 seconds..."
        << std::endl;
    std::this_thread::sleep_for(std::chrono::seconds(10));
    std::cout << "Thread " << thread << " finished sleeping." << std::endl;
};

void testMt() {
    auto dqSptr = std::make_shared<sta::DispatchQueue>(10);
    for (int i{0}; i < 15; ++i) {
        if (i == 3) {
            dqSptr->setThreadCount(4);
        } else {
            dqSptr->dispatch(s1);
        }
    }
    std::cout << "all the tasks is dispatch\n";
    // It's likely that this is not 0
    std::cout << dqSptr->getPendingTaskCnt() << '\n';
    dqSptr->finishTasks();
    // If dqSptr->getPendingTaskCnt() is not 0, the following line won't be executed
    std::cout << " dqSptr->finishTasks(); is finished\n";
}


// My execution result
/*
Thread 0 is sleeping for 10 seconds...Thread 
Thread 3 is sleeping for 10 seconds...
2 is sleeping for 10 seconds...
Thread 0 finished sleeping.
Thread 3 finished sleeping.
Thread 2 finished sleeping.
all the tasks is dispatch
11

*/

maliberty pushed a commit that referenced this pull request Jul 31, 2025
…the top module. (#270)

Like in OpenROAD.

Signed-off-by: Christian Costa <titan.costa@gmail.com>
maliberty pushed a commit that referenced this pull request Jul 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant