mmap() 사용시 리턴값에 대한 질문입니다.
글쓴이: ksjsc / 작성시간: 수, 2005/08/03 - 1:00오후
안녕하세요..
mmap()을 사용하여 코딩하고 있는데요..
다음과 같은 부분에서 에러가 발생해서 질문합니다.
...
pthread_mutex_t *mutex
...
mutex = (pthread_mutex_t *)mmap(0, sizeof(pthread_mutex_t), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 8192);
...
위와 같이 할 경우 에러가 발생했습니다.
그러나,
...
pthread_mutex_t *mutex
void *addr;
...
addr = (pthread_mutex_t *)mmap(0, sizeof(pthread_mutex_t), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 8192);
mutex = (pthread_mutex_t *)addr;
...
위와 같이 했을 경우에는 에러가 발생하지 않았습니다.
왜 그런것일까요...?
답변 부탁드립니다.
Forums:
궁금해서...
질문하신 부분에 대해서는 잘모르겠습니다...^^:;
소스보구 궁금해서 그런데요.
위에서 처럼 mmap을 쓰신 이유가 궁금합니다.
혹시 위처럼 쓰신 앞뒤 문맥을 알려주시면
혹시라도 도움이 될 수도 있지 않을까 싶네요..
전 다른 목적으로 상용 프로그램에서 mmap을 써왔는데,
OS마다 특성이 달라서 문제가 많이 생기더라구요.
그래서 몇년 지난 뒤에는 결국 전부 빼버렸습니당.
권위를 의심할 것,어긋남을 존경할 것,자리잡기를 거부할 것,항상 자신을 재창조할 것 - MIT 미디어랩 -
댓글 달기