This commit is contained in:
@Nurullah.Damla 2019-10-23 21:39:09 +02:00
parent e787cbe355
commit e565c06550
4 changed files with 11 additions and 7 deletions

View File

@ -1,5 +1,6 @@
#include "../src/SharedMemory.h"
int main() {
return test();
shared_memory_init();
//return main();
}

View File

@ -1,3 +1,5 @@
#include <cstdlib>
#include <cstdio>
#include "SharedMemory.h"
//Shared-Memory-Segment erstellen oder öffnen shmget()
@ -7,12 +9,12 @@ void shared_memory_init(){
//Ein Shared-Memory-Segment abfragen, ändern oder löschen shmctl()
void delet_shared_memory(){
int shmctl(memory_id, IPC_RMID, 0);
memory_id = shmctl(memory_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 ){
void attach_process(void *myProcess){
if(( myProcess = shmat( memory_id, (char *)0, 0 )) < (char *)0 ){
perror("Fehler beim Ankoppeln des gemeinsamen Speicher Segments");
exit(-1);
}

View File

@ -6,7 +6,7 @@
#include <sys/shm.h>
//ID-Speicherbereich
#define int memory_id
extern int memory_id;
//Größe des Speicherbereichs hier 8MB (8000)
#define SHMMAXSIZE 8000
@ -18,7 +18,7 @@ void shared_memory_init();
void delet_shared_memory();
//Shared-Memory-Segment an einen Prozess anbinden (attach) shmat()
void attach_process(char *myProcess);
void attach_process(void *myProcess);
//Ein Shared-Memory-Segment loslösen shmdt()
void release_memory();

View File

@ -3,4 +3,5 @@
TEST_CASE("Demo test") {
REQUIRE(test() == 42);
}
}