From f3eb70b2e2d739179741215b65ab303bf7d8d3f6 Mon Sep 17 00:00:00 2001 From: Andrea Smith Date: Sat, 24 Oct 2020 12:16:30 -0500 Subject: Add sendChunkData branch --- P2/lib/utils.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'P2') diff --git a/P2/lib/utils.c b/P2/lib/utils.c index 79b309e..dffade8 100644 --- a/P2/lib/utils.c +++ b/P2/lib/utils.c @@ -5,6 +5,19 @@ 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; + int msgid; + + // open message queue + msgid = msgget(key, 0666 | IPC_CREAT); + message -> msgText = 1; + FILE *fptr = fopen(inputFile, "r"); + + // construct chunks of 1024 bytes + while(fgets(message, chunkSize, fptr) != EOF) { + + } } // hash function to divide the list of word.txt files across reducers -- cgit v1.2.3 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(-) (limited to 'P2') 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