Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multithreaded map() #2

Open
vladak opened this issue Jan 5, 2019 · 0 comments
Open

multithreaded map() #2

vladak opened this issue Jan 5, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@vladak
Copy link
Member

vladak commented Jan 5, 2019

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 than pool_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
  • 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

@vladak vladak added the enhancement New feature or request label Jan 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant