Linux-0.12 Kernel sleep_on function analysis

Source: Internet
Author: User

SLEEP_ON for process hibernation, the prototype is as follows:

void sleep_on (struct task_struct **p)

When a process accesses a mutex, the current process needs to hibernate if the resource is consumed by another process.

Suppose the structure of the resource is as follows:

struct RES

{

....

struct Task_struct *wait;
}

In fact, we refer to the file System I node will find that I node is also a resource, its structure has a variable i_wait. Then we'll use an I-node example. If the process accesses an I node and discovers that the I node is locked, the current process needs to sleep: sleep_on (&i_wait), so that the current process is sleeping on the I-node i_wait queue, so how does the I_wait sleep queue form? Use the picture below to describe it.

Note: P and current are global variables, TMP is process private, in the process stack. I_wait=null, and i_lock=1, represent that the inode is locked and inaccessible.


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.