spin_lock 테스트 중에 spin_lock_irqsave(), sin_unlock_irqrestore() 를 사용하면 실행 시에 segmentation fault 를 내며 죽습니다.
아래 소스 중에 spin_lock_irqsave() 대신 spin_lock() 을 사용하고, spin_unlock_irqrestore() 대신 spin_unlock()을 사용하면 잘 돌아갑니다.
spin_lock_irqsave() 나 spin_lock_irq() 를 사용하면 local CPU 의 interrupt를 중지시킨다고 하고, 그냥 spin_lock()은 cpu의 interrupt에 대해서는 아무 처리도 하지 않는다는데.... cpu 의 interrupt에 대해서 정확히 파악되지 않아 안전해 보이는 spin_lock_irqsave()를 사용하려고 합니다.
네트워크 카드를 두개 이상 쓰는 프로그램을 만들고자 합니다.
UDP 서버소켓을 생싱시 자신의 주소 정보를 sockaddr_in 구조체에 저장하고 bind를 하는데 하나인 경우에는
my_addr.sin_addr.s_addr = htonl(INADDR_ANY);
이런 식으로 하면 되는데...
네트워크 카드가 두개인 경우 각 네트워크 카드에 하나씩 UDP 서버 소켓을 생성 시켜야 함으로
my_addr.sin_addr.s_addr = inet_addr("210.115.43.181");
이런 식으로야 되는데 이렇게 할경우
sem_init initializes the semaphore object pointed to by sem. The count
associated with the semaphore is set initially to value. The pshared
argument indicates whether the semaphore is local to the current process (
pshared is zero) or is to be shared between several processes ( pshared is
not zero). LinuxThreads currently does not support process-shared
semaphores, thus sem_init always returns with error ENOSYS if pshared is
not zero.
프로젝트를 뛰다보면 여러 프로세스가 한 데이타에 접근해야 할 경우가 많은것이 대부분입니다.
보통 message queue나 shared memory를 많이 사용하는 편인데요..
(FIFO나 다른 IPC method들은 아직 실제 프로젝트에 적용한 경험은 없어서.. 여기서는 질문에 포함 안했습니다..)
그냥 일반적으로 가지고 있는 지식만 가지고서는 효율성을 따지기 힘들더군요.
(그냥 대략 알고있기로 shared memory가 message queue보다 속도면에서는 빠르고, message queue는 동기화 시켜줄 필요가 없어서 사용하기는 편하다고만 느끼고 있었습니다만..)