7 std::mutex t1_mutex
, t2_mutex
;
18 constexpr test_data filler
= {
21 .st0
= {{0x1f, 0x2f, 0x3f, 0x4f, 0x5f, 0x6f, 0x7f, 0x8f, 0x80, 0x40}},
24 void t_func(std::mutex
&t_mutex
) {
25 std::lock_guard
<std::mutex
> t_lock(t_mutex
);
26 test_data out
= filler
;
33 : "+a"(out
.eax
), "+b"(out
.ebx
)
38 printf("eax = 0x%08" PRIx32
"\n", out
.eax
);
39 printf("ebx = 0x%08" PRIx32
"\n", out
.ebx
);
41 for (int i
= 0; i
< sizeof(out
.st0
.data
); ++i
)
42 printf("0x%02" PRIx8
" ", out
.st0
.data
[i
]);
47 // block both threads from proceeding
48 std::unique_lock
<std::mutex
> m1_lock(t1_mutex
);
49 std::unique_lock
<std::mutex
> m2_lock(t2_mutex
);
52 std::thread
t1(t_func
, std::ref(t1_mutex
));
53 std::thread
t2(t_func
, std::ref(t2_mutex
));
55 // release lock on thread 1 to make it interrupt the program
57 // wait for thread 1 to finish
60 // release lock on thread 2
62 // wait for thread 2 to finish