Note that there are some explanatory texts on larger screens.

plurals
  1. POPthread_create error 11 with only 5 simultaneous thread
    primarykey
    data
    text
    <p>I have a problem in a multi threaded program. My program has 4 threads that are always here. We will name these thread from 1 to 4.</p> <p>The goal for my program is to communicate on a socket with a peripheral. Thread number 4 is used to send the messages to the peripheral.</p> <p>Each time a message is sent to the peripheral, I use : </p> <p><code>pthread_create(&amp;m_hThreadMsgReader, NULL, &amp;ThreadMsgReader, (void*) &amp;argStruct);</code></p> <p>This will create a thread to listen to the response on the socket, this thread will return when the socket doesn't contain anymore message : ie if<code>iRet = recv(m_iSocket, pcRecBuf, DEFAULT_READ_DATA_LEN, 0);</code> makes iRet take the value 0.</p> <p>So with the current implementation, a data pooling is made (every minute) on the peripheral (aside from other command sent via user input).</p> <p>The problem here is that after a few hours, pthread create will crash with an error 11. I've seen on stack overflow that it means that the system might not have enough resources or too many threads.</p> <p>But I don't understand as in QtCreator debug, i can only see the thread from 1 to 4. I know I might have created like 300 threads, but the list of thread only contains 4, which means all other threads were terminated.</p> <p>So I don't really understand if the maximum number of thread creation is during the whole lifetime of the process or the number of thread present at the same time.</p> <p>Should I just find a way to have a single thread for the listening even if it will listen on a empty socket ? Is my implementation a bad pattern ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload