Community
cancel
Showing results for 
Search instead for 
Did you mean: 
kio_marv
Beginner
122 Views

Several threads executing a root task or a continuation task.

Jump to solution
Hi,
I have a test program with root, child and continuation tasks. Using gdb, I put breakpoints at the execute functions of the root task and the continuation task. When reaching them, I used info threads to see how many threads were running:
[plain]2 Thread 0xb7ed1b70 (LWP 8537)  0x0012d422 in __kernel_vsyscall ()

* 1 Thread 0xb7fd27a0 (LWP 8534)  MyRoot::execute (this=0xb7fb3aa0) at ../src/src/MyRoot.cpp:44
[/plain]
The same output goes for the continuation task.
So my question is if a root task or a continuation task could be executed by more than one thread.

Thanks.

PS: I have a 2 core machine.
0 Kudos
1 Solution
RafSchietekat
Black Belt
122 Views
"So, if in execute() I don't create more child tasks or recycle the task, execute() will be run entirely in one thread, isn't it?"
If you don't create child tasks directly or indirectly, e.g., through parallel_for(), that execute() call will run entirely in one thread. If you recycle the task, execute() may run in a different thread, but not concurrently.

View solution in original post

6 Replies
RafSchietekat
Black Belt
122 Views
"So my question is if a root task or a continuation task could be executed by more than one thread."
Not concurrently, but the program could have them recycled. What do you have in mind?
kio_marv
Beginner
122 Views
I thought that execute could be splitted in more than one thread.
RafSchietekat
Black Belt
122 Views
As used by TBB, execute() may of course create child tasks, and those could well be executed by other threads.
kio_marv
Beginner
122 Views
Ok!
So, if in execute() I don't create more child tasks or recycle the task, execute() will be run entirely in one thread, isn't it?.

Thanks!
RafSchietekat
Black Belt
123 Views
"So, if in execute() I don't create more child tasks or recycle the task, execute() will be run entirely in one thread, isn't it?"
If you don't create child tasks directly or indirectly, e.g., through parallel_for(), that execute() call will run entirely in one thread. If you recycle the task, execute() may run in a different thread, but not concurrently.

View solution in original post

kio_marv
Beginner
122 Views
Thanks!!! It's clear now!!!
Reply