Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. #include <math.h>
  4. #include <fcntl.h>
  5. #include <sys/stat.h>
  6. #include <unistd.h>
  7. #include <cstdlib>
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10. #include <sys/ipc.h>
  11. #include <sys/shm.h>
  12.  
  13.  
  14.  
  15. using namespace std;
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22. void MM(int a[8], int b[4])
  23. {
  24. b[0]=a[0]*a[4]+a[1]*a[6];
  25. b[1]=a[0]*a[5]+a[1]*a[7];
  26. b[2]=a[2]*a[4]+a[3]*a[6];
  27. b[3]=a[2]*a[5]+a[3]*a[7];
  28. }
  29.  
  30.  
  31. struct kek
  32. {
  33. int a[8];
  34. int b[4];
  35. int flag;
  36. }*temp;
  37.  
  38. int main(int argc, char* argv[])
  39. {
  40. int descriptor=open("hh", O_CREAT | O_RDWR , S_IRWXU);
  41. int id,i,j; bool g=true; int b[4];
  42. key_t key=ftok("hh",1);
  43. id=shmget(key,sizeof(struct kek),IPC_CREAT| S_IRUSR | S_IWUSR);
  44.  
  45. temp=(kek*)shmat(id,0,0);
  46.  
  47. temp->flag=1;
  48. while(g)
  49. {
  50.  
  51. MM(temp->a,b);
  52. for (i=0;i<4;i++)
  53.  
  54. {
  55.  
  56. temp->b[4];
  57.  
  58. }
  59.  
  60.  
  61. temp->flag=1;
  62.  
  63. if(temp->flag==2)
  64.  
  65. {
  66.  
  67. g=false;
  68.  
  69. }
  70.  
  71. }
  72.  
  73. shmdt(temp);
  74.  
  75. shmctl(id,IPC_RMID,0);
  76.  
  77. close(descriptor);
  78.  
  79. return 0;
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement