Community
cancel
Showing results for 
Search instead for 
Did you mean: 
robert_jay_gould
Beginner
68 Views

Pausing the Task Scheduler

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
68 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.

robert_jay_gould
Beginner
68 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.

jimdempseyatthecove
Black Belt
68 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
Reply