Skip to content

multithreaded map() #2

Open
Open
@vladak

Description

@vladak

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions