Commit 39869c13 authored by gejun's avatar gejun

r35335: Fix bthread_yield nosignal, if the system is idle, the yielded thread…

r35335: Fix bthread_yield nosignal, if the system is idle, the yielded thread may be forever blocked
parent c52b0fda
......@@ -866,8 +866,8 @@ int TaskGroup::stop_usleep(bthread_t tid) {
void TaskGroup::yield(TaskGroup** pg) {
TaskGroup* g = *pg;
ReadyToRunArgs args = { g->current_tid(), true };
g->set_remained(ready_to_run_in_worker_ignoresignal, &args);
ReadyToRunArgs args = { g->current_tid(), false };
g->set_remained(ready_to_run_in_worker, &args);
sched(pg);
}
......
......@@ -513,3 +513,14 @@ int main(int argc, char** argv) {
GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
return RUN_ALL_TESTS();
}
void* yield_thread(void*) {
bthread_yield();
return NULL;
}
TEST_F(test_bthread_suite, yield_single_thread) {
bthread_t tid;
ASSERT_EQ(0, bthread_start_background(&tid, NULL, yield_thread, NULL));
ASSERT_EQ(0, bthread_join(tid, NULL));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment