Here's my problem, I am getting a bad access on a shared memory line on my producer/consumer program:
Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0xffffffff 0x00001db0 in main () at Project3.c:120 120 memset(buf, 0, BUFFER_SIZE);
int BUFFER_SIZE = 200; int *buf; [I]Some code[/I]...... int ShmID=shmget(IPC_PRIVATE, (sizeof(int)*200), 0666 | IPC_CREAT); buf = shmat(ShmID, 0, 0666); memset(buf, 0, BUFFER_SIZE); union semun valsem; valsem.val = BUFFER_SIZE; pid_t childpid; int SemID; int waiter;
With regular allocaiton, it works well, but with shared memory alocation, it fails.
What could be the problem? Please and thank you!
Edited by Kirielson: n/a