aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Strapp <strap012@umn.edu>2020-10-26 08:26:54 -0500
committerMatt Strapp <strap012@umn.edu>2020-10-26 08:26:54 -0500
commit9be59436af0ddf0eb76a6ecc23883a975851d5b1 (patch)
tree0d5071bd1d3e3a2f17563c2ff5b5016e8e26b153
parentapparently void pointers aren't needes so I got rid of them (diff)
downloadcsci4061-9be59436af0ddf0eb76a6ecc23883a975851d5b1.tar
csci4061-9be59436af0ddf0eb76a6ecc23883a975851d5b1.tar.gz
csci4061-9be59436af0ddf0eb76a6ecc23883a975851d5b1.tar.bz2
csci4061-9be59436af0ddf0eb76a6ecc23883a975851d5b1.tar.lz
csci4061-9be59436af0ddf0eb76a6ecc23883a975851d5b1.tar.xz
csci4061-9be59436af0ddf0eb76a6ecc23883a975851d5b1.tar.zst
csci4061-9be59436af0ddf0eb76a6ecc23883a975851d5b1.zip
Fix smol things
Diffstat (limited to '')
-rw-r--r--P2/lib/utils.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/P2/lib/utils.c b/P2/lib/utils.c
index e994a88..5a5a09d 100644
--- a/P2/lib/utils.c
+++ b/P2/lib/utils.c
@@ -3,7 +3,7 @@
//Receive from send and return the chonk
char *getChunkData(int mapperID) {
//Message
- struct msgBuffer* message;
+ struct msgBuffer message;
//Queue ID, not sure what it actually does
int mid;
//Queue Key
@@ -14,12 +14,12 @@ char *getChunkData(int mapperID) {
return NULL;
}
msgrcv(mid, &message, MSGSIZE, mapperID, 0);
- if (strcmp("END", message -> msgText)) {
+ if (strcmp("END", message.msgText)) {
struct msgBuffer ACK = {mapperID, "ACK"};
msgsnd(mid, &ACK, MSGSIZE, 0);
}
// msgctl(mid, IPC_RMID, 0);
- return message -> msgText;
+ return message.msgText;
}
// sends chunks of size 1024 to the mappers in RR fashion
@@ -30,7 +30,7 @@ void sendChunkData(char *inputFile, int nMappers) {
// open message queue
msgid = msgget(key, 0666 | IPC_CREAT);
- message -> msgText = 1;
+ // message.msgText = 1;
FILE *fptr = fopen(inputFile, "r");
// construct chunks of 1024 bytes
@@ -44,11 +44,12 @@ void sendChunkData(char *inputFile, int nMappers) {
msgsnd(msgid, &message, mapperID);
}
- for (int i = 1; i < nMappers; i++) {
- msgsnd(msgid, &END, MSGSIZE, i);
+ for (long i = 1; i < nMappers; i++) {
+ struct msgBuffer END = {i, "END"};
+ msgsnd(msgid, &END, MSGSIZE, 0);
// TODO! does this need to be in another loop or is blocking good enough?
- msgrcv(msgid, &ACK, MSGSIZE, i);
+ msgrcv(msgid, &message, MSGSIZE, i, 0);
}
// msgctl(msgid, IPC_RMID, 0); // close that bih