From 8ee6c8d3dfe2bffced4aed4dd2cd17512e2a0f06 Mon Sep 17 00:00:00 2001 From: Andrea Smith Date: Sat, 24 Oct 2020 17:50:59 -0500 Subject: Check TODO's --- P2/lib/utils.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/P2/lib/utils.c b/P2/lib/utils.c index dffade8..c8f6f72 100644 --- a/P2/lib/utils.c +++ b/P2/lib/utils.c @@ -5,8 +5,8 @@ char *getChunkData(int mapperID) { // sends chunks of size 1024 to the mappers in RR fashion void sendChunkData(char *inputFile, int nMappers) { - msgBuffer message; - key_t key; + struct msgBuffer message; + key_t key = 10; int msgid; // open message queue @@ -16,8 +16,23 @@ void sendChunkData(char *inputFile, int nMappers) { // construct chunks of 1024 bytes 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); + } + + for (int i = 1; i < mapperID; i++) { + msgsnd(msgid, (void*)&END, MSGSIZE, i); + + // TODO! does this need to be in another loop or is blocking good enough? + msgrcv(msgid, (void*)&ACK, MSGSIZE, i); } + + msgctl(msgid, IPC_RMID, 0); // close that bih } // hash function to divide the list of word.txt files across reducers -- cgit v1.2.3