-
Notifications
You must be signed in to change notification settings - Fork 0
andreiionut1411/Tema1-APD
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
/* Ionescu Andrei Ionut */ Readme Tema 1 For the mappers I used an algorithm similar to the algorithm used for searching the square root of a number optimally, using binary search. We take a low and a high, and we calculate the middle of the interval, if the middle raised to the searched power is the searhced number, then it means the number is a perfect power. If not, we search in the lower half or the greater half of the interval for the next middle. Each mapper receives a pointer to the file that contains the name of the files that need to be read. We also have an index that tells how many files are still left to process. Each mapper, when it doesn't have work, tries to read the next file, and take it for itself to process. We use a mutex to lock the part where the thread decrements the number of files left and takes for itself the new file. This way, a file will not be processed by 2 mappers, and also, we won't have a racing condition when we decrement the counter. For the reducers, to synchronize them to start after the mappers, at the end of the mapper threads, and at the start of the reducers, we use a barrier. This way, the reducers start at the same time with the mappers, but they start processing just after they've finished. For the algorithm, I used an unordered set (that has a hashmap implementation behind the scenes), to add up all the different numbers in the lists that the reducers reeceived. If a number was already in the set, it will not be added again. We don't need synchronization tools because every reducer works for a different power, so they work on totally different data. Exit codes: 0 - The program finished successfully 1 - There were given an unsufficient number of parameters to the program 2 - There was a porblem at opening the files, or at finding them 3 - There was a problem with allocating the mempry
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published