Something you don't understand about down_interruptible

Source: Internet
Author: User
For more information about down_interruptible-general Linux technology-Linux programming and kernel, see the following. Recently, I was looking at the rt73 chip wireless NIC Driver, which contains several lines of code.
While (down_interruptible (& pAd-> mlme_semaphore) = 0)
{
If (! Netif_running (pAd-> net_dev ))
Continue;


/* Lock the device pointers, need to check if required */
If (down_interruptible (& (pAd-> usbdev_semaphore )))
Break;


// Always call Bulk routine, even reset bulk.
// The protectioon of rest bulk shocould be in BulkOut routine
RTUSBKickBulkOut (pAd );
RTUSBDequeueRxPackets (pAd); // to be continued ......
MlmeHandler (pAd );

/* Unlock the device pointers */
Up (& (pAd-> usbdev_semaphore ));
}
For down_interruptible, it can be interrupted by a signal. Therefore, this function has a return value to identify whether it is normal or interrupted by a signal. If 0 is returned, it indicates that the semaphore is returned normally. If the signal is interrupted, return-EINTR
In my understanding, if there is no signal interruption, once up (& pAd-> mlme_semaphore) is executed, it will pass down_interruptible (& pAd-> mlme_semaphore) = 0, re-enter the while loop and execute it sequentially until it stops at the while (down_interruptible (& pAd-> mlme_semaphore) = 0) again.
What I don't understand is,
1. How does mlme thread stop at down_interruptible (& pAd-> mlme_semaphore. Is it through sleep?
2. once it is up, the kernel Immediately checks whether the resources released by the signal have been applied by other threads, and finds the while (down_interruptible (& pAd-> mlme_semaphore) = 0) here, zero is returned, and then the while LOOP body?

I have just started learning. I don't know much about it. Please give me more advice. : 0) 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.