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.