aboutsummaryrefslogtreecommitdiffstats
path: root/P1/src
diff options
context:
space:
mode:
authorMatt Strapp <strap012@umn.edu>2020-10-04 12:36:33 -0500
committerMatt Strapp <strap012@umn.edu>2020-10-04 12:36:33 -0500
commitb25b5329e6bbb65703be7837dc734b874cfdef5c (patch)
tree6d9b26e0bb67a55cdac660ff11cac16dae4f8116 /P1/src
parentI forgot to add the 1 (diff)
downloadcsci4061-b25b5329e6bbb65703be7837dc734b874cfdef5c.tar
csci4061-b25b5329e6bbb65703be7837dc734b874cfdef5c.tar.gz
csci4061-b25b5329e6bbb65703be7837dc734b874cfdef5c.tar.bz2
csci4061-b25b5329e6bbb65703be7837dc734b874cfdef5c.tar.lz
csci4061-b25b5329e6bbb65703be7837dc734b874cfdef5c.tar.xz
csci4061-b25b5329e6bbb65703be7837dc734b874cfdef5c.tar.zst
csci4061-b25b5329e6bbb65703be7837dc734b874cfdef5c.zip
Fix mapper, finally
Diffstat (limited to '')
-rw-r--r--P1/src/mapreduce.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/P1/src/mapreduce.c b/P1/src/mapreduce.c
index 50ca5ca..ed44e9e 100644
--- a/P1/src/mapreduce.c
+++ b/P1/src/mapreduce.c
@@ -27,13 +27,14 @@ int main(int argc, char *argv[]) {
pid_t mapperPid;
- for (int i = 1; i < nMappers; i++) {
+ for (int i = 1; i <= nMappers; i++) {
mapperPid = fork();
- if (mapperPid > 0) {
+ if (mapperPid == 0) {
//TODO: exec here
- char num[10];
- sprintf(num, "%d", i);
- execl("./mapper", "./mapper", &num, NULL);
+ char numMap[10];
+ sprintf(numMap, "%d", i);
+ execl("./mapper", "./mapper", &numMap, NULL);
+ exit(0);
}
}
@@ -46,30 +47,29 @@ int main(int argc, char *argv[]) {
// ###### DO NOT REMOVE ######
// shuffle sends the word.txt files generated by mapper
// to reducer based on a hash function
- pid = fork();
- if(pid == 0){
- shuffle(nMappers, nReducers);
- exit(0);
- }
- sleep(1);
+ // pid = fork();
+ // if(pid == 0){
+ // shuffle(nMappers, nReducers);
+ // exit(0);
+ // }
+ // sleep(1);
- pid_t reducerPid;
- for (int i = 0; i < nReducers; i++) {
- reducerPid = fork();
- if (reducerPid > 0) {
- //TODO: exec here
- char num[10];
- sprintf(num, "%d", i);
- execl("./reducer", "./reducer", &num, NULL);
- }
- }
+ // pid_t reducerPid;
+ // for (int i = 1; i <= nReducers; i++) {
+ // reducerPid = fork();
+ // if (reducerPid == 0) {
+ // char numRed[10];
+ // sprintf(numRed, "%d", i);
+ // execl("./reducer", "./reducer", &numRed, NULL);
+ // }
+ // }
- for (int i = 0; i <= nReducers; i++) {
- //Maybe this works too?
- wait(NULL);
- }
+ // for (int i = 1; i <= nReducers; i++) {
+ // //Maybe this works too?
+ // wait(NULL);
+ // }
return 0;
} \ No newline at end of file