Handle (continued)

Source: Internet
Author: User

Recently, I have a new understanding of the handle, so that I can learn it later.

Some time ago I wrote in my blog what is a handle (see what is a handle) but it does not explain why the handle should be introduced in the window system, as most people know, the handle is used in the window operating system to identify a resource. Obtaining the handle is the address of the resource. In this sentence, we can know two knowledge points:

1. The handle is unique to the Windows operating system. It is not used in Linux.

2. A handle is used to identify a resource and obtain the resource address.

Now, I want to ask a question? Since C ++ has pointers, why should I use a handle? Can't the pointer Save the resource address?

I will explain this question now.

Anyone who has learned operating system principles knows that an applicationProgramNot allCodeThey are all put into the memory. Even if they are put into the memory, it is impossible to stay in the memory throughout the runtime. After all, the memory is still a precious resource. Therefore, for a certain resource, the physical address may be different at different times, but in the kernel object table, the handle is actually an index. Based on this index, we can quickly find the physical address of the resource at this time. The handle is relatively stable, so the window operating system introduces the handle concept.

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.