|
News,
Internal,
Projects,
Home Software, Support, Documentation |
On Mon, May 17, 2004 at 03:22:15PM +0900, Seung-joo Lee wrote:
> > ....
> > sem_t *mutex;
> > /* mutex = sem_open (SEM_NAME, O_CREAT | O_EXCL, FILE_MODE, 1); */
> > /* mutex = sem_open (SEM_NAME, O_CREAT | O_EXCL); */
> > mutex = sem_open (SEM_NAME, O_CREAT);
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > POSIX sem_open(3)을 살펴보세요.
> > O_CREAT Create the semaphore if it does not already exist.
> > The third argument to the call to sem_open() must be of type
> > mode_t and specifies the mode for the semaphore. Only the
> > S_IWUSR, S_IWGRP, and S_IWOTH bits are examined; it is not pos-
> > sible to grant only ``read'' permission on a semaphore. The
> > mode is modified according to the process's file creation mask;
> > see umask(2).
> > The fourth argument must be an unsigned int and specifies the
> > initial value for the semaphore, and must be no greater than
> > SEM_VALUE_MAX.
> > if ( mutex == SEM_FAILED )
> > ....
> 네, 제가 미처 그 부분을 읽지를 못했습니다.
> 그런데 그렇게 변경을 하고 해봐도 결과는 같게 나오더군요.
> ( mutex = sem_open ("/tmp/mysem", O_CREAT, S_IWUSR, 1); )
> 혹시 위 소스를 컴파일 해 보신 다른 분들은 되시나요?
#include <fcntl.h>
#include <semaphore.h>
#include <stdio.h>
#include <errno.h>
int
main(void)
{
sem_t *s;
int val;
s = sem_open("/sem_test", O_CREAT, 0777, 5);
if (s == SEM_FAILED){
printf("%s\n", strerror(errno));
return (1);
}
sem_getvalue(s, &val);
printf("val = %d\n", val);
sem_close(s);
return (0);
}
커널에 'options P1003_1B_SEMAPHORES'가 없다면 sem(4)을 커널
모듈로 load하면 됩니다.
#cd /usr/src/sys/modules/sem
#make && make install && make load
--
Pyun YongHyeon <http://www.kr.freebsd.org/~yongari>
_______________________________________________
한국 FreeBSD 사용자 그룹(KFUG) questions 메일링 리스트
questions at kr.FreeBSD.org
http://www.kr.FreeBSD.org/mailman/listinfo/questions
|
Copyright © 1998-2005 Korea FreeBSD Users Group. All rights reserved. webmaster at kr.FreeBSD.org $Date: 2004/05/19 16:24:13 $ |
|