From c79f8c60d98d65385e1b546c743b0c91cbe20149 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Wed, 28 Oct 2020 13:16:58 -0500 Subject: Make new branch --- P2/lib/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'P2') diff --git a/P2/lib/utils.c b/P2/lib/utils.c index f485b11..cef81b1 100644 --- a/P2/lib/utils.c +++ b/P2/lib/utils.c @@ -45,7 +45,7 @@ void sendChunkData(char *inputFile, int nMappers) { else cut off before that word and put back file */ // TODO! help message.msgType = map++; - //THIS IS DEBUG, NOT ACTUALLY FUNCTIONAL + //THIS IS DEBUG, NOT ACTUALLY FUNCTIONAL (like at all) msgsnd(msgid, &message, map, 0); if (map > nMappers) map = 1; -- cgit v1.2.3 From dd7ea113dfd6f10739d3b16858c0628ed69175f0 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Wed, 28 Oct 2020 14:47:22 -0500 Subject: Get rid of ACJK --- P2/lib/utils.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'P2') diff --git a/P2/lib/utils.c b/P2/lib/utils.c index cef81b1..c698005 100644 --- a/P2/lib/utils.c +++ b/P2/lib/utils.c @@ -19,8 +19,8 @@ char *getChunkData(int mapperID) { msgrcv(mid, &message, sizeof(message.msgText), mapperID, 0); /*IMPLEMENT END AND ACK SOON*/ if (strncmp("END", message.msgText, 3)) { - struct msgBuffer ACK = {mapperID, "ACK"}; - msgsnd(mid, &ACK, MSGSIZE, 0); + // struct msgBuffer ACK = {mapperID, "ACK"}; + // msgsnd(mid, &ACK, MSGSIZE, 0); return NULL; } char* value = message.msgText; @@ -81,8 +81,8 @@ int getInterData(char *Qkey, int reducerID) { Qkey = message.msgText; if (strncmp("END", message.msgText, 3)) { - struct msgBuffer ACK = {reducerID, "ACK"}; - msgsnd(id, &ACK, MSGSIZE, 0); + // struct msgBuffer ACK = {reducerID, "ACK"}; + // msgsnd(id, &ACK, MSGSIZE, 0); return 0; } else { return 1; -- cgit v1.2.3 From 90101b89ba87eb2008a75644290e9143b7132286 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Wed, 28 Oct 2020 14:51:18 -0500 Subject: I broke it again --- P2/lib/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'P2') diff --git a/P2/lib/utils.c b/P2/lib/utils.c index c698005..ede4931 100644 --- a/P2/lib/utils.c +++ b/P2/lib/utils.c @@ -56,7 +56,7 @@ void sendChunkData(char *inputFile, int nMappers) { msgsnd(msgid, &END, MSGSIZE, 0); // TODO! does this need to be in another loop or is blocking good enough? - msgrcv(msgid, &message, MSGSIZE, i, 0); + // msgrcv(msgid, &message, MSGSIZE, i, 0); } } -- cgit v1.2.3 From 989c6b2e91a7d304f68f9f5997e7dae0e5f53b6c Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Wed, 28 Oct 2020 17:46:47 -0500 Subject: Add closequeue --- P2/include/utils.h | 2 ++ P2/lib/utils.c | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'P2') diff --git a/P2/include/utils.h b/P2/include/utils.h index 050a0e3..6fa4fa8 100644 --- a/P2/include/utils.h +++ b/P2/include/utils.h @@ -23,7 +23,9 @@ struct msgBuffer { }; //Open Queue as a function because writing this once is probably better than four times. //Hopefully it works properly. + int openQueue(); +void closeQueue(); // mapper side int validChar(char c); diff --git a/P2/lib/utils.c b/P2/lib/utils.c index ede4931..8c27f4c 100644 --- a/P2/lib/utils.c +++ b/P2/lib/utils.c @@ -2,13 +2,20 @@ int openQueue() { int id = msgget(ftok("4061 Project 2 SS", 'S'), 0666 | IPC_CREAT); - if (id < 0) - { + if (id < 0) { perror("Cannot open queue.\n"); return -1; - }; + } return id; } +void closeQueue() { + int msgid = msgget(ftok("4061 Project 2 SS", 'S'), 0666); + if (msgid < 0) { + perror("Cannot open queue. It may already exist.\n"); + exit(-1); + } + msgctl(msgid, IPC_RMID, NULL); +} char *getChunkData(int mapperID) { printf("GETTING CHUNK DATA\n"); -- cgit v1.2.3 From e8ba6edc687cd4d198d93259f5889482723ac43b Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Wed, 28 Oct 2020 17:54:38 -0500 Subject: Add a close function --- P2/src/mapreduce.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'P2') diff --git a/P2/src/mapreduce.c b/P2/src/mapreduce.c index 962a9ca..7f87019 100644 --- a/P2/src/mapreduce.c +++ b/P2/src/mapreduce.c @@ -49,6 +49,7 @@ int main(int argc, char *argv[]) { pid_t pid = fork(); if(pid == 0){ //send chunks of data to the mappers in RR fashion + printf("TEST\n"); sendChunkData(inputFile, nMappers); exit(0); } @@ -77,5 +78,6 @@ int main(int argc, char *argv[]) { // wait for all children to complete execution while (wait(&status) > 0); + closeQueue(); return 0; } \ No newline at end of file -- cgit v1.2.3 From 6731bbbe1252568ff32d5fb9c1f2767d65b39633 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Wed, 28 Oct 2020 18:08:39 -0500 Subject: ? --- P2/lib/utils.c | 2 +- P2/src/mapreduce.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'P2') diff --git a/P2/lib/utils.c b/P2/lib/utils.c index 8c27f4c..82f7a70 100644 --- a/P2/lib/utils.c +++ b/P2/lib/utils.c @@ -46,7 +46,7 @@ void sendChunkData(char *inputFile, int nMappers) { // construct chunks of 1024 bytes memset(message.msgText, '\0', MSGSIZE); while(read(fd, message.msgText, chunkSize) != 0) { - printf("%s\n", message.msgText); + // printf("%s\n", message.msgText); /* Go to the end of the chunk, check if final character is a space if character is a space, do nothing else cut off before that word and put back file */ diff --git a/P2/src/mapreduce.c b/P2/src/mapreduce.c index 7f87019..290c1c5 100644 --- a/P2/src/mapreduce.c +++ b/P2/src/mapreduce.c @@ -49,7 +49,6 @@ int main(int argc, char *argv[]) { pid_t pid = fork(); if(pid == 0){ //send chunks of data to the mappers in RR fashion - printf("TEST\n"); sendChunkData(inputFile, nMappers); exit(0); } -- cgit v1.2.3