@@ -482,12 +482,19 @@ int TaskGroup::start_foreground(TaskGroup** pg,
482482 } else {
483483 // NOSIGNAL affects current task, not the new task.
484484 RemainedFn fn = NULL ;
485- if (g->current_task ()->about_to_quit ) {
485+ auto & cur_attr = g->_cur_meta ->attr ;
486+ if (cur_attr.flags & BTHREAD_GLOBAL_PRIORITY) {
487+ fn = priority_to_run;
488+ } else if (g->current_task ()->about_to_quit ) {
486489 fn = ready_to_run_in_worker_ignoresignal;
487490 } else {
488491 fn = ready_to_run_in_worker;
489492 }
490- ReadyToRunArgs args = { g->_cur_meta , (bool )(using_attr.flags & BTHREAD_NOSIGNAL) };
493+ ReadyToRunArgs args = {
494+ g->tag (),
495+ g->_cur_meta ,
496+ (bool )(using_attr.flags & BTHREAD_NOSIGNAL)
497+ };
491498 g->set_remained (fn, &args);
492499 TaskGroup::sched_to (pg, m->tid );
493500 }
@@ -861,6 +868,11 @@ void TaskGroup::ready_to_run_in_worker_ignoresignal(void* args_in) {
861868 return tls_task_group->push_rq (args->meta ->tid );
862869}
863870
871+ void TaskGroup::priority_to_run (void * args_in) {
872+ ReadyToRunArgs* args = static_cast <ReadyToRunArgs*>(args_in);
873+ return tls_task_group->control ()->push_priority_queue (args->tag , args->meta ->tid );
874+ }
875+
864876struct SleepArgs {
865877 uint64_t timeout_us;
866878 bthread_t tid;
@@ -1035,7 +1047,7 @@ int TaskGroup::interrupt(bthread_t tid, TaskControl* c, bthread_tag_t tag) {
10351047
10361048void TaskGroup::yield (TaskGroup** pg) {
10371049 TaskGroup* g = *pg;
1038- ReadyToRunArgs args = { g->_cur_meta , false };
1050+ ReadyToRunArgs args = { g-> tag (), g->_cur_meta , false };
10391051 g->set_remained (ready_to_run_in_worker, &args);
10401052 sched (pg);
10411053}
0 commit comments