Make last changes...
Co-authored-by: Juan Barmasch <jbarmasch@itba.edu.ar> Co-authored-by: Ezequiel Bellver <ebellver@itba.edu.ar>
This commit is contained in:
parent
cf60bc8824
commit
4b0cff4e85
23
master.c
23
master.c
|
@ -32,20 +32,16 @@ int main(int argc, char *argv[]) {
|
||||||
slaveNum = (slaveNum == 0 ? 1 : slaveNum);
|
slaveNum = (slaveNum == 0 ? 1 : slaveNum);
|
||||||
slaveNum = (slaveNum < MAX_SLAVES ? slaveNum : MAX_SLAVES);
|
slaveNum = (slaveNum < MAX_SLAVES ? slaveNum : MAX_SLAVES);
|
||||||
|
|
||||||
FILE * outputFile;
|
|
||||||
if ((outputFile = fopen(OUTPUT_NAME, "w")) == NULL)
|
|
||||||
printSystemError("fopen() -- ERROR");
|
|
||||||
|
|
||||||
char * shmPointer, * shmStart;
|
|
||||||
int totalSize = (argc - 1) * MAX_OUTPUT_SIZE;
|
|
||||||
int shmFd;
|
|
||||||
|
|
||||||
printf("%d\n%d\n", argc - 1, getpid());
|
printf("%d\n%d\n", argc - 1, getpid());
|
||||||
|
|
||||||
addSignalHandler(changeViewFlag);
|
addSignalHandler(changeViewFlag);
|
||||||
sleep(5);
|
sleep(5);
|
||||||
blockSignal();
|
blockSignal();
|
||||||
|
|
||||||
|
char * shmPointer, * shmStart;
|
||||||
|
int totalSize = (argc - 1) * MAX_OUTPUT_SIZE;
|
||||||
|
int shmFd;
|
||||||
|
|
||||||
if (viewLinked) {
|
if (viewLinked) {
|
||||||
shmFd = createShm(totalSize);
|
shmFd = createShm(totalSize);
|
||||||
mapShm(&shmPointer, totalSize, shmFd);
|
mapShm(&shmPointer, totalSize, shmFd);
|
||||||
|
@ -60,6 +56,10 @@ int main(int argc, char *argv[]) {
|
||||||
sendTask(argv[tasks], pipesInput, j++);
|
sendTask(argv[tasks], pipesInput, j++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FILE * outputFile;
|
||||||
|
if ((outputFile = fopen(OUTPUT_NAME, "w")) == NULL)
|
||||||
|
printSystemError("fopen() -- ERROR");
|
||||||
|
|
||||||
fd_set pipesOutputSet;
|
fd_set pipesOutputSet;
|
||||||
FD_ZERO(&pipesOutputSet);
|
FD_ZERO(&pipesOutputSet);
|
||||||
|
|
||||||
|
@ -170,6 +170,13 @@ void createPipesAndSlaves(int pipesOutput[slaveNum][2], int pipesInput[slaveNum]
|
||||||
if (close(pipesInput[i][0]) < 0)
|
if (close(pipesInput[i][0]) < 0)
|
||||||
printSystemError("close() -- ERROR");
|
printSystemError("close() -- ERROR");
|
||||||
|
|
||||||
|
for (int j = 0; j < i; j++) {
|
||||||
|
if (close(pipesInput[j][1]) < 0)
|
||||||
|
printSystemError("close() -- ERROR");
|
||||||
|
if (close(pipesOutput[j][0]) < 0)
|
||||||
|
printSystemError("close() -- ERROR");
|
||||||
|
}
|
||||||
|
|
||||||
char * params[] = {"slave.o", NULL};
|
char * params[] = {"slave.o", NULL};
|
||||||
if (execv("slave.o", params) < 0)
|
if (execv("slave.o", params) < 0)
|
||||||
printSystemError("execv() -- ERROR");
|
printSystemError("execv() -- ERROR");
|
||||||
|
|
1
siglib.c
1
siglib.c
|
@ -8,7 +8,6 @@ PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
void addSignalHandler(void (*changeViewFlag)()) {
|
void addSignalHandler(void (*changeViewFlag)()) {
|
||||||
struct sigaction sigAct = {{0}};
|
struct sigaction sigAct = {{0}};
|
||||||
|
|
Loading…
Reference in New Issue