title: How does Intel TBB concurrent_queue work? Does it achieve fine-grained parallelism?
body: <p>I am new to Intel TBB. I am using concurrent_queue in order to achieve fine-grained parallelism in my project. I got few doubts. This is how i am implementing.</p>
  
  <pre><code>   thread_fun(arguments) {
        while(concurrent_queue.try_pop(v))
            operation on v;  //each thread executes its own operation(seperate v for each thread)
     }
     main() {
        for(..)
           concurrent_queue.push(); //fill the queue
        _beginthreadex(..); //create 8 win32 threads and pass concurrent_queue as an argument
     }
  </code></pre>
  
  <ol>
  <li><p>I am explicitly mentioning the number of threads. I read that TBB will create threads based on the processor core count. How can i achieve that? So that i don't need to create threads explicitly with _beginthreadex function?</p></li>
  <li><p>Am i achieving fine-grained parallelism by using the concurrent_queue?</p></li>
  <li><p>What do you mean by task level parallelism? How do you achieve task level parallelism with intel tbb? I am popping element from the queue. Does pop operation considered as a task? That means, all pop operations are considered as different tasks. I am popping 8 elements at a time with 8 threads. That means, i am achieving task level parallelism. Am i correct?</p></li>
  <li><p>If i increase the number of threads to 32 on a quad-core processor(support 8 threads), how does the concurrent_queue work? Does only 8 threads concurrently executed on the queue or total 32 threads are executed concurrently?</p></li>
  </ol>
  
  <p>Please help me.</p>