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()
|
2019-10-23 11:53:07 +02:00
|
|
|
|
void shared_memory_init(){
|
|
|
|
|
memory_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()
|
2019-10-23 11:53:07 +02:00
|
|
|
|
void delet_shared_memory(){
|
|
|
|
|
int shmctl(memory_id, IPC_RMID, 0);
|
2019-10-20 20:38:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Shared-Memory-Segment an einen Prozess anbinden (attach) – shmat()
|
2019-10-23 11:53:07 +02:00
|
|
|
|
void attach_process(char *myProcess){
|
|
|
|
|
if(( myProcess = shmat( memmory_id, (char *)0, 0 )) < (char *)0 ){
|
2019-10-20 20:38:12 +02:00
|
|
|
|
perror("Fehler beim Ankoppeln des gemeinsamen Speicher Segments");
|
|
|
|
|
exit(-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Ein Shared-Memory-Segment loslösen – shmdt()
|
2019-10-23 11:53:07 +02:00
|
|
|
|
void release_memory(){
|
2019-10-20 20:38:12 +02:00
|
|
|
|
int shmdt(void *myProcess);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|