공유메모리 shm_open 질문

restday22의 이미지

타겟보드 arm-linux 2.4커널 /mnt/nfs 디렉토리에서 실행해봤습니다.

int fdShm
fdShm=shm_open("test", O_CREAT |O_RDWR, 0666);
if(fdShm<0){
printf("shm_open failed\n");
exit(1);
}

공유메모리 써서 해볼거라고 막짜서 돌려봤는데
시작부터 오류가 나네요 ;;
shm_open failed

제가 실수한거라도 있나요?

그리고 공유메모리는 posix, sysV 둘중에 어떤걸 많이쓰나요

bushi의 이미지

man shm_open wrote:

RETURN VALUE
On success, shm_open() returns a non-negative file descriptor. On
failure, shm_open() returns -1. shm_unlink() returns 0 on success, or
-1 on error.

ERRORS
On failure, errno is set to indicate the cause of the error.

man perror wrote:

[b]DESCRIPTION[b]
The routine perror() produces a message on the standard error output,
describing the last error encountered during a call to a system or
library function.

if(fdShm<0) {
  perror("shm_open(\"test\")");
  exit(1);
}