Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

Pausing the Task Scheduler

robert_jay_gould
Beginner
332 Views
Not sure why I never thought/encountered this before, but is there a way to pause the task_scheduler without canceling pending jobs?

Any suggestions that doesn't requiring jamming a big lock within all my tasks?

Thanks!
0 Kudos
3 Replies
Bartlomiej
New Contributor I
332 Views
What about the tasks that are currently being executed? Are they supposed to be finished or suspended like the pending ones?

A quick thought is making the scheduler a separate process and using the SIGSTOP/SIGCONT signals, but that's definitely a dirty solution.
Maybe a condvar in the scheduler-observer? Just thinking in loud.

0 Kudos
robert_jay_gould
Beginner
332 Views
Quoting - Bartlomiej
What about the tasks that are currently being executed? Are they supposed to be finished or suspended like the pending ones?

A quick thought is making the scheduler a separate process and using the SIGSTOP/SIGCONT signals, but that's definitely a dirty solution.
Maybe a condvar in the scheduler-observer? Just thinking in loud.


What I was thinking was that the scheduler finish the tasks it is currently running on each thread (no need to preempt that), but once it finishes these tasks that it won't keep on processing the rest of the leftover tasks in the task tree.

Basically the reason is that an application is processing tasks full time, most of the time, but that at times there are other things it has to do concurrently that are of a higher priority, so I'd like to pause the scheduler until the higher priority tasks finish, so the high priority work can hog all the CPUs.

Also for self-inspection purposes there is a situation in which I'd like to stop the scheduler and check how things are going (the application needs to continue running, but the tasks on the scheduler should be paused).

My current quick solution is to place a hand-brake in the scheduler that allows me to jam it. But I think this sort of thing would probably be better off as an actual library feature.

0 Kudos
jimdempseyatthecove
Honored Contributor III
332 Views

Robert,

Your hand-break might be the simplest means to accomplish the goal. You did not give a complete description of your hand-break but youcan implement it in the following way

You can determine the size of the TBB thread pool. The hand-break code when free running can keep track of the number of active threads in the TBB thread pool. The break can now be variable to perform if(numberOfActiveThreads > numberOfPermittedThreads) yieldToOtherThreadPool();

I.e. your break need not be totaly on/off but to varying degrees.

You also did not indicate if the other tasks were inside of the instance of your TBB thread pool, or run from a seperate TBB thread pool in same app, or run with OpenMP (or other) thread pool in same app, or run from different process.

Jim Dempsey
0 Kudos
Reply