From 4822d0c99139389a93b41c1ccf573d8ebef1c787 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Mon, 26 Oct 2020 08:19:01 -0500 Subject: apparently void pointers aren't needes so I got rid of them --- P2/lib/utils.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'P2') diff --git a/P2/lib/utils.c b/P2/lib/utils.c index 507eb0b..e994a88 100644 --- a/P2/lib/utils.c +++ b/P2/lib/utils.c @@ -13,18 +13,18 @@ char *getChunkData(int mapperID) { perror("Cannot open queue.\n"); return NULL; } - msgrcv(mid, (void *) &message, MSGSIZE, mapperID, 0); + msgrcv(mid, &message, MSGSIZE, mapperID, 0); if (strcmp("END", message -> msgText)) { struct msgBuffer ACK = {mapperID, "ACK"}; - msgsnd(mid, (void *) &ACK, MSGSIZE, 0); + msgsnd(mid, &ACK, MSGSIZE, 0); } - msgctl(mid, IPC_RMID, 0); + // msgctl(mid, IPC_RMID, 0); return message -> msgText; } // sends chunks of size 1024 to the mappers in RR fashion void sendChunkData(char *inputFile, int nMappers) { - struct msgBuffer *message; + struct msgBuffer message; key_t key = 10; int msgid; @@ -34,24 +34,24 @@ void sendChunkData(char *inputFile, int nMappers) { FILE *fptr = fopen(inputFile, "r"); // construct chunks of 1024 bytes - while(fgets(message, chunkSize, fptr) != EOF) { + while(fgets(&message, chunkSize, fptr) != EOF) { /* 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 */ // TODO! help - msgsnd(msgid, &msgText, mapperID); + msgsnd(msgid, &message, mapperID); } - for (int i = 1; i < mapperID; i++) { - msgsnd(msgid, (void*)&END, MSGSIZE, i); + for (int i = 1; i < nMappers; i++) { + msgsnd(msgid, &END, MSGSIZE, i); // TODO! does this need to be in another loop or is blocking good enough? - msgrcv(msgid, (void*)&ACK, MSGSIZE, i); + msgrcv(msgid, &ACK, MSGSIZE, i); } - msgctl(msgid, IPC_RMID, 0); // close that bih + // msgctl(msgid, IPC_RMID, 0); // close that bih } // hash function to divide the list of word.txt files across reducers -- cgit v1.2.3