I'm starting a project using SDL2 to display the result of the Dining philosophers problem. I was creating 7 threads for my "philosophers" using pthread_create but I've noticed always 5 more threads than necessary using ps -M.
Example (with 7 of my voluntarily created threads [confirmed with some text output]):
achedeuzot 56774 s000 0.9 U 46T 0:00.04 0:00.06 ./philo
56774 0.0 S 46T 0:00.00 0:00.00
56774 0.0 S 46T 0:00.00 0:00.00
56774 0.0 S 46T 0:00.00 0:00.00
56774 0.0 S 46T 0:00.00 0:00.00
56774 0.0 S 46T 0:00.00 0:00.00
56774 0.0 S 46T 0:00.00 0:00.00
56774 0.0 S 46T 0:00.00 0:00.00
56774 0.0 S 46T 0:00.00 0:00.00
56774 0.0 S 48T 0:00.00 0:00.00
56774 0.0 S 46T 0:00.00 0:00.00
56774 0.0 S 46T 0:00.00 0:00.00
56774 0.0 S 46T 0:00.00 0:00.00
When I disable the code that generates threads but keep displaying a window, there are still 5 threads remaining:
achedeuzot 57751 s000 0.9 U 46T 0:00.04 0:00.06 ./philo
57751 0.0 S 46T 0:00.00 0:00.00
57751 0.0 S 48T 0:00.00 0:00.00
57751 0.0 S 0T 0:00.00 0:00.00
57751 0.0 S 46T 0:00.00 0:00.00
57751 0.0 S 46T 0:00.00 0:00.00
So it seems that SDL2 is creating 5 threads on it's own. I'm using SDL_RENDERER_ACCELERATED for SDL_CreateRenderer().
I have searched for other people mentioning this but couldn't find anything about it (or my keywords were not OK).
Where are these 5 extra threads coming from ? Is it something specific to my computer ? Is it from the GPU acceleration ? Is it from the ps command ? Is it SDL2 or some sub-routine of SDL2 ?
Thank you for helping me see more clearly what is happening here !
Additional info: I'm not using SDL_CreateThread(). I'm on a Mac, OS 10.9.3.