Chapter 3 kernel objects

Source: Internet
Author: User

1. All functions used to create kernel objects must be very careful when checking their return values. For example:

Handle hmutex = createmutex (...);
If (hmutex = invalid_handle_value)
{
// The code here will not be executed because null is returned when createmutex fails.
}

Handle hfile = createfile (..);
If (hfile = NULL)
{
// The code here will not be executed because invalid_handle_value (-1) is returned when createfile fails)
}

 

2. No matter how the kernel object is created, we need to call closehandle to show the system that we have ended using the object.

Bool closehandle (handle hobject)

If the handle is valid, the system will obtain the address of the data structure of the kernel object and decrease the "use count" member in the structure. If the technology changes to 0, the kernel object will be destroyed, and removed from the memory.

3. When a process is aborted, the system will ensure that our process does not leave anything and will close the object for us.

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.