CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
69 lines
1.7 KiB
C++
69 lines
1.7 KiB
C++
#include <condition_variable>
|
|
#include <iostream>
|
|
#include <mutex>
|
|
#include <thread>
|
|
|
|
std::mutex mtx;
|
|
std::condition_variable cv;
|
|
int ready_thread_id = 0;
|
|
int signal_main_thread = 0;
|
|
|
|
void worker(int id) {
|
|
std::cout << "Worker " << id << " executing..." << std::endl;
|
|
|
|
// lldb test should change signal_main_thread to true to break the loop.
|
|
while (!signal_main_thread) {
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
}
|
|
|
|
// Signal the main thread to continue main thread
|
|
{
|
|
std::lock_guard<std::mutex> lock(mtx);
|
|
ready_thread_id = id; // break worker thread here
|
|
}
|
|
cv.notify_one();
|
|
|
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
|
std::cout << "Worker " << id << " finished." << std::endl;
|
|
}
|
|
|
|
void deadlock_func(std::unique_lock<std::mutex> &lock) {
|
|
int i = 10;
|
|
++i; // Set interrupt breakpoint here
|
|
printf("%d", i); // Finish step-over from inner breakpoint
|
|
auto func = [] { return ready_thread_id == 1; };
|
|
cv.wait(lock, func);
|
|
}
|
|
|
|
int simulate_thread() {
|
|
std::thread t1(worker, 1);
|
|
|
|
std::unique_lock<std::mutex> lock(mtx);
|
|
deadlock_func(lock); // Set breakpoint1 here
|
|
|
|
std::thread t2(worker, 2); // Finish step-over from breakpoint1
|
|
|
|
cv.wait(lock, [] { return ready_thread_id == 2; });
|
|
|
|
t1.join();
|
|
t2.join();
|
|
|
|
std::cout << "Main thread continues..." << std::endl;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int bar() { return 54; }
|
|
|
|
int foo(const std::string p1, int extra) { return p1.size() + extra; }
|
|
|
|
int main(int argc, char *argv[]) {
|
|
std::string ss = "this is a string for testing",
|
|
ls = "this is a long string for testing";
|
|
foo(ss.size() % 2 == 0 ? ss : ls, bar()); // Set breakpoint2 here
|
|
|
|
simulate_thread(); // Finish step-over from breakpoint2
|
|
|
|
return 0;
|
|
}
|