2019-10-19 17:12:14 +02:00
|
|
|
|
#include "SharedMemory.h"
|
|
|
|
|
|
2019-10-19 19:18:34 +02:00
|
|
|
|
//Shared-Memory-Segment erstellen oder öffnen – shmget()
|
|
|
|
|
void shared-memory-init(){
|
|
|
|
|
memmory-id = shmget(IPC_PRIVATE, SHMMAXSIZE, IPC_CREAT | IPC_EXCL);
|
2019-10-19 17:12:14 +02:00
|
|
|
|
}
|
2019-10-19 19:18:34 +02:00
|
|
|
|
|
2019-10-20 20:38:12 +02:00
|
|
|
|
//Ein Shared-Memory-Segment abfragen, ändern oder löschen – shmctl()
|
|
|
|
|
void delet-shared-memory(){
|
|
|
|
|
int shmctl(memmory-id, IPC_RMID, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Shared-Memory-Segment an einen Prozess anbinden (attach) – shmat()
|
|
|
|
|
void attach-process(char *myProcess){
|
|
|
|
|
if(( myProcess = shmat( memmory-id, (char *)0, 0 )) < (char *)0 ){
|
|
|
|
|
perror("Fehler beim Ankoppeln des gemeinsamen Speicher Segments");
|
|
|
|
|
exit(-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Ein Shared-Memory-Segment loslösen – shmdt()
|
|
|
|
|
void release-memory‚(){
|
|
|
|
|
int shmdt(void *myProcess);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|