Pthreads - how to parallelize work

I need to parallelize a simple password cracker in order to use it on an n-processor system. My idea is to create n threads and feed them more and more work as they are completed.

What is the best way to find out when a thread is completed? Mutex? Is it worth checking this mutex constantly while other threads are working?

+3
source share
3 answers

You can have a simple queue structure - use whatever data structure you like, and then just use the mutex when you add / remove elements from it.

, , "", , .

, 1 1 , .

, ; , pthread_join.

+5

: -

→ ( ). → (, - , , !)

, , - , .

, MCP ( !) , .

, .

+1

" " , .

mutex, . Pthread (., , pthread_cond_create (...)).

+1

Source: https://habr.com/ru/post/1703384/


All Articles