//gcc write.c -o write -g #include #include #include "mm.h" struct shm{ int a; char b; float c; }*pt; int main() { size_t size_mem; MM* p_mm; size_mem = 1024; p_mm = mm_create(size_mem,"../mm"); if(p_mm == NULL) { perror("error"); return 0; } mm_reset(p_mm); pt = (struct shm*)p_mm; printf("addr_p_mm =%x\n",p_mm); printf("addr_pt =%x\n",pt); while(1) { mm_lock(p_mm,MM_LOCK_RW); pt->a = 1; pt->b = 2; pt->c = 3; mm_unlock(p_mm); sleep(4); } mm_destroy(p_mm); return 0; }