Several threads executing a root task or a continuation task.

Several threads executing a root task or a continuation task.

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:

2 Thread 0xb7ed1b70 (LWP 8537)  0x0012d422 in __kernel_vsyscall ()

* 1 Thread 0xb7fd27a0 (LWP 8534)  MyRoot::execute (this=0xb7fb3aa0) at ../src/src/MyRoot.cpp:44

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.

publicaciones de 7 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

"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?

I thought that execute could be splitted in more than one thread.

As used by TBB, execute() may of course create child tasks, and those could well be executed by other threads.

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!

Best Reply

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

Thanks!!! It's clear now!!!

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya