Skip to content

debug_DispatchQueue_ThreadPool_DeadLock#270

Open
Mike-debug wants to merge 1 commit intoThe-OpenROAD-Project:masterfrom
Mike-debug:master
Open

debug_DispatchQueue_ThreadPool_DeadLock#270
Mike-debug wants to merge 1 commit intoThe-OpenROAD-Project:masterfrom
Mike-debug:master

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
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Mike-debug
Copy link
Author

Mike-debug commented Feb 25, 2026 via email

@dsengupta0628
Copy link
Contributor

@Mike-debug Can you please add the C++ test along with the code change too to increase coverage of our testing?

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.

3 participants