I'm USB in Linux, I'm a USB flash drive (22) Legend of the other side (1)

Source: Internet
Author: User

 

Flowers are sad memories.

 

A long time ago, the edge of the city was filled with a large film of manzhusha. Its floral fragrance had a magic power to remind people of their past lives. The guardian of manzhu shanhua is two fairy spirits, one is manzhu, the other is Sha Hua. They waited for thousands of years, but they never met each other, because there were no leaves and no flowers when they were blooming. They miss each other frantically and are suffering from this kind of pain. One day, they decided to secretly meet God's rules. In that year, the red and colorful flowers in manjusha were highlighted in green, and they were exceptionally enchanting and beautiful.

 

Manzhu and Sha hua were punished and transferred to the reincarnation. They were cursed and could never be together. From then on, manzhu shahua is also called another shore flower, which means the flowers that are open to heaven. The flowers are in the shape of a palm that is only praying to heaven, but it never appeared in this city again. She will be on the huangquan road during the cross-shore Autumn period (three days before and after the spring equinox and three days before and after the autumn equinox, every reincarnation of manzhu and Sha Hua on the huangquan road smells the fragrance of the other side of the flower, you can think of yourself in the past, and swear not to separate, but only at this moment, because they will fall into the curse of the reincarnation, the soul through the guidance of flowers, to the Nether.

 

The Linux kernel introduces a daemon, which corresponds to this legend. A daemon is also called a kernel genie. If you are an antitheistic, you can call it a kernel thread. Let's look at the specific code.

 

Row 3 calls the kthread_create () function, kthread_create (usb_stor_control_thread, us, "usb-storage"). If you were not familiar with the kernel, then this function will make you feel a little headache. This function will create a kernel thread, and the function usb_stor_control_thread () will be executed. us will be the parameter passed to it. If you are not familiar with the Linux kernel, you can think of kthread_create as a function similar to fork.

 

In fact, to put it simply, when kthread_create () is executed, there will be two processes: one is the parent process and the other is the child process. The child process will execute usb_stor_control_thread (), while us serves as the parameter (real parameter) of the usb_stor_control_thread function, after executing usb_stor_control_thread (), the sub-process ends and it will call the exit () function to exit. The parent process continues to follow the usb_stor_acquire_resources () function. For the parent process, the kthread_create () function returns the task_struct struct pointer of the child process, and the second line calls IS_ERR (th) determine whether the returned pointer is an error code. If IS_ERR (th) is true, call PTR_ERR (th) to read the actual error code.

 

Therefore, we must continue to track the Parent and Child processes separately. First look at the parent process, line 1:

 

811 wake_up_process (th );

 

To wake up a sub-process, you need to wake up the sub-process because it will not be executed immediately after you create a sub-process using kthread_create (). It will not be executed until you wake up, therefore, this function is equivalent to the voice of the referee in the track and field. The athlete will not start running until the referee sends an order. Let's look at the sub-process, that is, the usb_stor_control_thread () function, which is defined in drivers/usb/storage/usb. c.

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.