Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- #include <math.h>
- #include <fcntl.h>
- #include <sys/stat.h>
- #include <unistd.h>
- #include <cstdlib>
- #include <stdlib.h>
- #include <stdio.h>
- #include <sys/ipc.h>
- #include <sys/shm.h>
- using namespace std;
- void MM(int a[8], int b[4])
- {
- b[0]=a[0]*a[4]+a[1]*a[6];
- b[1]=a[0]*a[5]+a[1]*a[7];
- b[2]=a[2]*a[4]+a[3]*a[6];
- b[3]=a[2]*a[5]+a[3]*a[7];
- }
- struct kek
- {
- int a[8];
- int b[4];
- int flag;
- }*temp;
- int main(int argc, char* argv[])
- {
- int descriptor=open("hh", O_CREAT | O_RDWR , S_IRWXU);
- int id,i,j; bool g=true; int b[4];
- key_t key=ftok("hh",1);
- id=shmget(key,sizeof(struct kek),IPC_CREAT| S_IRUSR | S_IWUSR);
- temp=(kek*)shmat(id,0,0);
- temp->flag=1;
- while(g)
- {
- MM(temp->a,b);
- for (i=0;i<4;i++)
- {
- temp->b[4];
- }
- temp->flag=1;
- if(temp->flag==2)
- {
- g=false;
- }
- }
- shmdt(temp);
- shmctl(id,IPC_RMID,0);
- close(descriptor);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement