#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <string.h>
#include <assert.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <semaphore.h>

typedef struct
{
  sem_t message_ready;
  sem_t buffer_ready;
  size_t size;
  char contents[];
} SharedMemory;




int main()
{
  int fd = shm_open("/my_example_shared_memory",O_CREAT | O_RDWR,0644);
  assert(fd != -1);
  SharedMemory* shm = mmap(0,15ull*1024ull*1024ull*1024ull,PROT_READ | PROT_WRITE, MAP_SHARED,fd,0);
  while (1) {
    printf("will wait\n");
    sem_wait(&(shm->message_ready));
    printf("read: %s",shm->contents);
    sem_post(&(shm->buffer_ready));
  }
  return -1;
}