Open
Description
Implement a function:
void map(size_t pool_size, int (*func)(char *), char **paths, size_t npaths);
-
that will create and maintain thread pool and distribute the work to thread pool and will wait for completion of all jobs
- the idea is that
npaths
can be strictly bigger thanpool_size
- the work is calling the function (given by the pointer to function 'func') on given path
- test case: each thread will count the number of characters in the file
- the idea is that
-
hint: each worker thread will loop until it cannot get an item from the queue
- obviously, the queue access needs to be synchronized
-
overall progress (percentage computed from total number of files vs. number of files processed)
will be reported to stdout by the main thread (use '\r' to overwrite) -
variant: each worker will return whether or not it completed the processing of the item
-
make the workers randomly return error (i.e. do not complete the processing) in which case the job will be submitted again