Created
November 27, 2014 22:32
-
-
Save pawelsawicz/f72f54f6480538cf320b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <sys/types.h> | |
#include <sys/ipc.h> | |
#include <sys/shm.h> | |
struct PKW | |
{ | |
int PSL; | |
int PIS; | |
int PO; | |
int SLD; | |
int OKW_PSL[20]; | |
int OKW_PIS[20]; | |
int OKW_PO[20]; | |
int OKW_SLD[20]; | |
}; | |
struct PKW *shared; | |
void Voting(int committeId) | |
{ | |
int i = 0; | |
int tempValue = 0; | |
for (i; i < 5; i++) | |
{ | |
printf("Committe %d \n", committeId); | |
tempValue++; | |
} | |
//shared->PSL = tempValue; | |
printf("asddadsa"); | |
/*shared->PIS = 0; | |
shared->PO = 0; | |
shared->SLD = 0; | |
shared->OKW_PSL[committeId] = tempValue; | |
shared->OKW_PIS[committeId] = 0; | |
shared->OKW_PO[committeId] = 0; | |
shared->OKW_SLD[committeId] = 0;*/ | |
} | |
main() | |
{ | |
int Committe[20]; | |
int i = 0, shmid; | |
shmid = shmget(20133, sizeof(struct PKW), IPC_CREAT); | |
if (shmid < 0) | |
{ | |
perror("shmget"); | |
return(1); | |
} | |
shared = shmat(shmid, 0, 0); | |
if (shared == NULL) | |
{ | |
perror("shmat"); | |
return(1); | |
} | |
for(i;i<20;i++) | |
{ | |
Committe[i] = fork(); | |
if(Committe[i]==0) | |
{ | |
Voting(i); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment