An object management method and device based on a handle structure

By extracting free description items in the handle description table and generating handles, combining the comparison mechanism between handles and description items, the misuse of objects during handle multiplexing in the traditional handle method is solved, and the accuracy of handle multiplexing and system operation optimization is achieved.

CN113626212BActive Publication Date: 2025-05-30GUANGZHOU ZHIYUAN ELECTRONICS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110786879.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-12
Publication Date
2025-05-30
Estimated Expiration
2041-07-12

AI Technical Summary

Technical Problem

Traditional handle management methods cannot guarantee the uniqueness of handles, which leads to the problem of misuse of objects during handle reuse, affecting system operation.

Method used

By extracting the description items in the idle state from the preset handle description table, creating an object in the system memory and associating it with the description items, generating the associated handle based on the description items, and when accessing the object with the handle, comparing the handle with the corresponding description items in the handle description table, and determining whether the handle and the description items match to ensure the accuracy of handle multiplexing.

Benefits of technology

Ensure the accuracy of handle reuse, avoid access to wrong objects during handle reuse, solve the problem of object misuse during handle reuse, and optimize system memory management and program operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113626212B_ABST
    Figure CN113626212B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose an object management method and device based on a handle structure. The technical solution provided by the embodiments of the present application extracts description items in an idle state from a preset handle description table, creates an object in the system memory and associates it with the description item, and generates an associated handle based on the description item; when accessing an object using a handle, compares the handle with the corresponding description item in the handle description table to determine whether the handle matches the corresponding description item; determines that the handle matches the corresponding description item, locks the object associated with the description item, and performs an object access operation; determines that the handle does not match the corresponding description item, and ends the current object access process. By adopting the above technical means, it is ensured that the handle reuse is accurate, the situation of accessing the wrong object during handle reuse is avoided, the problem of object misuse during handle reuse is solved, and the system memory management and program operation are optimized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the technical field of system object management, and in particular to an object management method and device based on a handle structure. Background Art

[0002] When traditional operating systems perform object management, they generally directly allocate a block of memory in the system heap for application programs, and the application programs directly reference the original pointers of the memory to operate on objects. This method is extremely dependent on the memory management unit and is prone to memory object access exceptions and program crashes.

[0003] For this reason, there is a method of using handles to control memory objects. The application program holds an object handle, which points to a certain descriptor in the handle descriptor table, and then indirectly points to the real object in the memory through the descriptor. This can eliminate the dependence of the system memory on the memory management unit and avoid abnormal situations caused by direct memory allocation.

[0004] However, using the traditional handle method to manage objects cannot guarantee the uniqueness of the handle. When a handle is released and then reused by another user, the handle values of the two are the same, but the actual pointed content is different, which is prone to the situation of misusing objects, resulting in program operation errors and affecting system operation. Summary of the Invention

[0005] The embodiments of the present application provide an object management method and device based on a handle structure, which can solve the problem of object misuse when handles are reused, ensure accurate handle reuse, and optimize system operation.

[0006] In a first aspect, the embodiments of the present application provide an object management method based on a handle structure, including:

[0007] Extract the free descriptors from a preset handle descriptor table, create an object in the system memory and associate it with the descriptor, and generate an associated handle based on the descriptor;

[0008] When accessing an object using the handle, compare the handle with the corresponding descriptor in the handle descriptor table to determine whether the handle matches the corresponding descriptor;

[0009] Determine that the handle matches the corresponding descriptor, lock the object associated with the descriptor, and perform an object access operation;

[0010] Determine that the handle does not match the corresponding descriptor, and end the current object access process.

[0011] Further, generating an associated handle based on the descriptor includes:

[0012] Generate a unique identifier for the description item, and generate a handle associated with the description item based on the unique identifier;

[0013] Correspondingly, the determining whether the handle matches the corresponding description item includes:

[0014] Based on the comparison result of the unique identifier, it is determined whether the handle matches the corresponding description item.

[0015] Further, generating a handle associated with the description item based on the unique identifier includes:

[0016] An index number of the description item in the handle description table is determined, and the index number and the unique identifier are combined into a handle associated with the description item.

[0017] Furthermore, after extracting the description item in the idle state from the preset handle description table, the method further includes:

[0018] The handle state type of the description item is switched from an idle state to an associated state.

[0019] Furthermore, after extracting the description item in the idle state from the preset handle description table, the method further includes:

[0020] Clearing a reference count of the description item, where the reference count is used to count the number of locks of an object associated with the description item;

[0021] Correspondingly, locking the object associated with the description item further includes:

[0022] The reference count is updated according to the locking and unlocking operations of the object associated with the description item.

[0023] Further, after updating the reference count according to the locking and unlocking operations of the object associated with the description item, the method further includes:

[0024] When the reference count is zero, the handle state type of the description item is set to an idle state, and the association relationship between the description item and the corresponding handle is released.

[0025] Furthermore, after setting the handle state type of the description item to an idle state, the method further includes:

[0026] An object associated with the description item is determined, and a memory defragmentation operation is performed on the object associated with the description item.

[0027] In a second aspect, an embodiment of the present application provides an object management device based on a handle structure, including:

[0028] A creation module, configured to extract the description items in the idle state from a preset handle description table, create an object in the system memory and associate it with the description item, and generate an associated handle based on the description item;

[0029] A comparison module, configured to compare the handle with the corresponding description item in the handle description table when accessing an object using the handle, and determine whether the handle matches the corresponding description item;

[0030] An access module, configured to determine that the handle matches the corresponding description item, lock the object associated with the description item, and perform an object access operation; determine that the handle does not match the corresponding description item, and end the current object access process.

[0031] In a third aspect, an embodiment of the present application provides an electronic device, including:

[0032] A memory and one or more processors;

[0033] The memory is configured to store one or more programs;

[0034] When the one or more programs are executed by the one or more processors, the one or more processors implement the object management method based on the handle structure as described in the first aspect.

[0035] In a fourth aspect, an embodiment of the present application provides a storage medium containing computer-executable instructions, and the computer-executable instructions are used to execute the object management method based on the handle structure as described in the first aspect when executed by a computer processor.

[0036] In the embodiments of the present application, by extracting the description items in the idle state from a preset handle description table, creating an object in the system memory and associating it with the description item, and generating an associated handle based on the description item; when accessing an object using the handle, comparing the handle with the corresponding description item in the handle description table to determine whether the handle matches the corresponding description item; determining that the handle matches the corresponding description item, locking the object associated with the description item, and performing an object access operation; determining that the handle does not match the corresponding description item, and ending the current object access process. By adopting the above technical means, it is ensured that the handle reuse is accurate, the situation of accessing the wrong object when reusing the handle is avoided, the problem of misusing the object when reusing the handle is solved, and the system memory management and program operation are optimized. Description of the Drawings

[0037] Figure 1 is a flowchart of an object management method based on a handle structure provided in Embodiment 1 of the present application;

[0038] Figure 2 is a schematic diagram of the description item structure in Embodiment 1 of the present application;

[0039] Figure 3 It is a schematic diagram of the handle structure in the first embodiment of the present application;

[0040] Figure 4 It is a schematic diagram of object association in the first embodiment of the present application;

[0041] Figure 5 It is a flowchart of handle construction in the first embodiment of the present application;

[0042] Figure 6 It is a flowchart of object access in the first embodiment of the present application;

[0043] Figure 7 It is a flowchart of handle release in the first embodiment of the present application;

[0044] Figure 8 It is a schematic diagram of the structure of an object management device based on a handle structure provided in the second embodiment of the present application;

[0045] Figure 9 It is a schematic diagram of the structure of an electronic device provided in the third embodiment of the present application. Detailed implementation manners

[0046] In order to make the objectives, technical solutions, and advantages of the present application clearer, the following further describes the specific embodiments of the present application in detail with reference to the accompanying drawings. It can be understood that the specific embodiments described herein are only used to explain the present application, rather than limiting the present application. Additionally, it should be noted that for the sake of convenience of description, only parts related to the present application are shown in the accompanying drawings, rather than all the content. Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the operations (or steps) as sequential processes, many of the operations can be implemented in parallel, concurrently, or simultaneously. In addition, the order of the operations can be rearranged. When the operations are completed, the process can be terminated, but there can also be additional steps not included in the drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.

[0047] The object management method based on a handle structure provided by the present application aims to avoid the problem of incorrect object access during handle reuse by matching the description items in the handle description table with the handle. Compared with the traditional object management method, generally, a block of memory is directly allocated for the application program in the system heap, and the application program directly references the original pointer of the memory to operate on the object. This method is simple and direct, but has the following several defects:

[0048] 1. On a system without a memory management unit, once memory is allocated, its position cannot be dynamically adjusted. After the system runs for a long time, a large number of memory fragments may occur, resulting in a low memory utilization rate and affecting the availability of the system.

[0049] 2. On a system with a memory management unit, the operating system can manage the mapping between virtual memory and physical memory, and use indirect addressing through the memory management unit to alleviate the memory fragmentation problem. However, the system will overly rely on the memory management unit of the processor.

[0050] 3. Using a raw pointer cannot determine the validity of the object or memory it points to. In a multi-threaded program with callback functions or complex structures, the object held or passed in the code may be released during a certain intermediate process. The holder continues to use the object without knowing it, which may lead to memory access exceptions and program crashes.

[0051] Another way to manage memory objects using handles mainly involves the application program holding the object handle, using the handle to point to a certain descriptor in the handle descriptor table, and then indirectly pointing to the real object in memory through the descriptor to implement operations such as object access. Common examples such as Linux file descriptors and Windows kernel objects adopt the above-mentioned method of managing memory objects using handles. Although this object management method can solve the defects of direct memory allocation, the traditional method usually directly uses the index (i.e., serial number) of the handle descriptor table as the value of the handle. For example, for Linux file descriptors, although the descriptor can identify the validity of the handle, in the case of a reused released handle, it is easily misused. For the handle held or passed in the code, it may be released during a certain intermediate process, and then the handle descriptor is immediately reused by a new object. The handle holder continues to use the object without knowing it, which may lead to program operation errors or even very hidden exceptions. Moreover, these handle management mechanisms are all bound to a specific system, dedicated to managing the files and kernel objects of the operating system, not universal, with complex implementation methods or non-disclosed implementation details, and cannot be transplanted to other projects, resulting in low flexibility. Based on this, an object management method based on a handle structure according to the embodiments of the present application is provided to solve the problem of object misuse during handle reuse in the existing object management methods.

[0052] Embodiment 1:

[0053] Figure 1The flowchart of an object management method based on a handle structure provided in the first embodiment of the present application is given. The object management method based on the handle structure provided in this embodiment can be executed by an object management device based on the handle structure. The object management device based on the handle structure can be implemented in a software and / or hardware manner. The object management device based on the handle structure can be composed of two or more physical entities or one physical entity. Generally speaking, the object management device based on the handle structure can be a computing device such as a computer, a server, a processor, or a controller.

[0054] The following takes the object management device based on the handle structure as the main body for executing the object management method based on the handle structure as an example for description. Refer to Figure 1 , the object management method based on the handle structure specifically includes:

[0055] S110. Extract the description items in the idle state from the preset handle description table, create an object in the system memory and associate it with the description item, and generate an associated handle based on the description item.

[0056] In order to avoid the situation that when the handle description item is reused, the handle originally associated with the handle description item continues to access the object linked by the handle description item, resulting in incorrect access to the object. By constructing the uniqueness of the association between the handle and the description item, the validity judgment when the handle is reused is carried out to ensure the accurate reuse of the handle.

[0057] Exemplarily, refer to Figures 2 - 3 , a schematic structural diagram of the description item and the handle of the present application is provided. As Figure 2 shown, in the embodiment of the present application, a 64-bit data is used to represent the description item corresponding to a handle, where 8-bit data records the reference counter (ref) of the description item; 8-bit data is used to record the status type (tag) of the description item. When the status type is tag = 0xFF, it represents the idle state, and other values are freely defined by the user; 16-bit data is used to record the unique identifier (UID) of the description item; 32-bit data is used to record the real object pointer (void*) bound to the description item. In the system memory, the object can be a piece of memory, an image, etc. On the other hand, as Figure 3 shown, 32-bit data is used to represent a handle, where 16-bit data records the index (i.e., the handle number) of the handle in the handle description table; 16-bit data is used to record the unique identifier (UID) of the handle. The unique identifier (UID) of the handle is used to make a verification with the corresponding unique identifier (UID) in the description item to determine whether the handle is valid. In the embodiment of the present application, when the value of the handle = 0xFFFFFFFF, it represents that the current handle is invalid.

[0058] In addition, in the embodiments of the present application, multiple description items are compactly arranged to form a handle description table. As Figure 4 shown, the handle management program can manage all handles through the handle description table, including handle application (i.e., handle construction), release, lock, and unlock, etc. The handle description items are used to respectively associate the corresponding handles and objects, so as to realize the binding of the handle and the object, facilitating subsequent access to the object. The handle index in the embodiments of the present application includes 16-bit data, so the maximum number of items supported by this handle description table is 65,535.

[0059] Specifically, during system initialization, all description items in the handle description table are set to the idle state. In the idle state, the description item is not associated with the corresponding handle and object, and its unique identifier is empty. Subsequently, according to the objects actually required to be accessed by the system, handle application and object locking are performed. Among them, when constructing a handle, an idle description item is extracted from the handle description table. It can be understood that the description item uses 8-bit data to record its state type (tag). If the tag of the description item = 0xFF, it means that the current description item is in the idle state. In the embodiments of the present application, an idle description item is extracted from the handle description table accordingly. Further, based on the extracted description item, a unique identifier of the description item is generated, and a handle associated with the description item is generated based on the unique identifier. To facilitate subsequent matching of the handle and the description item and determine the uniqueness of their association. Therefore, in the embodiments of the present application, the value of the handle is generated according to the unique identifier of the description item, and the generated handle should contain this unique identifier.

[0060] In addition, in the embodiments of the present application, the index number of the description item in the handle description table is determined, and the index number and the unique identifier are combined into the handle associated with the description item. It can be understood that, to facilitate finding the corresponding description item in the handle description table, the index number of the corresponding descriptor needs to be added when constructing the handle, that is, the arrangement serial number of the description item in the handle description table. Based on this index number, the handle can conveniently find the corresponding description item in the handle description table, and then access the object based on the description item.

[0061] Refer to Figure 5, when constructing a handle, each time a new handle is applied for, an item is drawn from the description items in the handle description table that are in the idle state, and a unique identifier (UID) of the description item is generated. Furthermore, the handle class status type (tag) of the description item is set, and the handle status type of the description item is switched from the idle state to the associated state. The reference count of the description item is cleared, and the reference count is used to count the number of locks of the object associated with the description item, so as to facilitate determining the object that the current description item can be linked to. Further, a real object is created in the system memory and linked to the description item, thereby completing the association between the description item and the system memory object. On the other hand, the unique identifier (UID) of the description item and the index number of the description item are combined into a handle value and returned to the handle management program, thereby completing the construction of a handle and obtaining the association relationship between the handle and the description item. Among them, the unique identifier (UID) can be generated by an algorithm. Each time a new handle is applied for, the global counter of the unique identifier (UID) is incremented by 1, so as to ensure the uniqueness of the generated unique identifier.

[0062] After completing the handle construction required for object access in the above manner, the association relationship between the handle and the object as shown in Figure 4 is obtained. When the handle management program needs to access a certain object, it matches the handle with the description item, and after the matching is completed, it uses the association relationship between the description item and the object to access the object.

[0063] S120. When accessing an object using the handle, compare the handle with the corresponding description item in the handle description table, and determine whether the handle matches the corresponding description item;

[0064] S130. Determine that the handle matches the corresponding description item, lock the object associated with the description item, and perform the object access operation; determine that the handle does not match the corresponding description item, and end the current object access process.

[0065] Furthermore, based on the pre-constructed handle, when it is necessary to access an object in the system memory using the handle, it is determined whether they match through the comparison and verification between the handle and the description table, and when it is determined that they match, the object is locked and accessed.

[0066] Specifically, when the present application determines whether the handle matches the corresponding description item, it includes:

[0067] Determine whether the handle matches the corresponding description item based on the comparison result of the unique identifier.

[0068] Exemplarily, as Figure 6As shown, when accessing the object associated with the handle, the object should be locked first, and then the object should be accessed based on the corresponding descriptor after locking the object. When locking the object, the handle is compared with the corresponding descriptor to verify whether the unique identifier (UID) in the handle matches the unique identifier (UID) of the descriptor. If they match, the object is successfully locked; if not, the object locking fails. It can be understood that the handle contains the index number of the corresponding descriptor, and the descriptor associated with the handle can be found according to the index number. Then, it is determined whether they match by comparing and matching the unique identifiers (UIDs) of the two. Whether to lock the object is judged according to the matching result. When it is determined to lock the object, the object associated with the current descriptor can be accessed, and the corresponding operation on the system object can be executed. When it is determined that the two do not match, in order to avoid program exceptions caused by incorrect access to the object, the object access process ends at this time.

[0069] In addition, the embodiment of the present application also updates the reference count according to the locking and unlocking operations of the object associated with the descriptor. Each time an object is locked, the reference count of the descriptor is incremented by 1 to record the object associated with the corresponding descriptor. When the corresponding object is no longer used, the object needs to be unlocked. Each time an object is unlocked, the reference count of the corresponding descriptor is decremented by 1. The system can lock and unlock multiple times and supports nesting.

[0070] Furthermore, according to the above object locking and unlocking operations, after all the objects associated with the descriptor are unlocked, the handle release operation is performed. As Figure 7 shown, when the reference count is zero, the handle status type of the descriptor is set to the idle state, and the association between the descriptor and the corresponding handle is released. Only when the reference count = 0 can the handle be released. When releasing the handle, the descriptor is set to the idle state, the real object associated with the handle is destroyed, and the association between the descriptor and the corresponding handle is released. After the association is released, the unique identifiers of the descriptor and the handle are cleared to avoid incorrect reference to subsequent objects. The idle descriptor can be reused when a new handle is applied for next time. It can be understood that the present application solves the problem of validity judgment when the descriptor is reused by mutually verifying the unique identifier (UID) on the handle and the unique identifier (UID) in the descriptor. Since the unique identifier (UID) of each newly applied handle is different, even if a certain descriptor is released and then immediately reused, although the serial numbers of the old handle and the new handle are the same, the unique identifier (UID) is different, so as to avoid incorrect access to the object when the descriptor is reused. Since the handle holder needs to lock the object before use and compare and match the handle with the descriptor, if the unique identifier (UID) does not match, the locking will be determined to fail, thus avoiding errors.

[0071] Optionally, in the embodiments of the present application, the object associated with the description item is also determined, and a memory fragmentation operation is performed on the object associated with the description item. By using handles to indirectly access objects and the locking and unlocking mechanism, when the handle holder needs to access the real memory of the object, the object needs to be locked first and unlocked after use. For all objects with a reference count of 0, the memory of the object can be moved to the specified storage space, thereby realizing the fragmentation function.

[0072] As described above, by extracting the description items in the idle state from the preset handle description table, creating an object in the system memory and associating it with the description item, and generating an associated handle based on the description item; when accessing the object using the handle, comparing the handle with the corresponding description item in the handle description table to determine whether the handle matches the corresponding description item; determining that the handle matches the corresponding description item, locking the object associated with the description item, and performing the object access operation; determining that the handle does not match the corresponding description item, and ending the current object access process. By adopting the above technical means, it is ensured that the handle reuse is accurate, avoiding the situation of accessing the wrong object when reusing the handle, solving the problem of misusing the object when reusing the handle, and optimizing the system memory management and program operation.

[0073] In addition, the handle and handle description table structure adopted in the present application is simple and compact, the process is simple and clear, and the memory consumption is small, with strong versatility and portability. It can be used in resource management of embedded systems, GUI object management and other application scenarios.

[0074] Embodiment 2:

[0075] Based on the above embodiment, Figure 8 is a schematic structural diagram of an object management device based on a handle structure provided by the second embodiment of the present application. Referring to Figure 8 , the object management device based on the handle structure provided in this embodiment specifically includes: a creation module 21, a comparison module 22, and an access module 23.

[0076] Among them, the creation module 21 is used to extract the description items in the idle state from the preset handle description table, create an object in the system memory and associate it with the description item, and generate an associated handle based on the description item;

[0077] The comparison module 22 is used to compare the handle with the corresponding description item in the handle description table when accessing the object using the handle, and determine whether the handle matches the corresponding description item;

[0078] The access module 23 is used to determine that the handle matches the corresponding description item, lock the object associated with the description item, and perform the object access operation; determine that the handle does not match the corresponding description item, and end the current object access process.

[0079] Specifically, the creation module 21 includes:

[0080] A generation unit, configured to generate a unique identifier for the description item, and generate a handle associated with the description item based on the unique identifier;

[0081] Correspondingly, the comparison module 22 includes:

[0082] A matching unit, configured to determine whether the handle matches the corresponding description item based on the comparison result of the unique identifier.

[0083] Specifically, the generation unit is configured to determine the index number of the description item in the handle description table, and combine the index number and the unique identifier into a handle associated with the description item.

[0084] Specifically, the creation module 21 includes:

[0085] A switching unit, configured to switch the handle status type of the description item from the idle state to the associated state.

[0086] A counting unit, configured to clear the reference count of the description item, where the reference count is used to count the number of locked objects associated with the description item; update the reference count according to the lock and unlock operations of the objects associated with the description item.

[0087] A release unit, configured to set the handle status type of the description item to the idle state and release the association relationship between the description item and the corresponding handle when the reference count is zero.

[0088] A cleaning unit, configured to determine the objects associated with the description item, and perform a memory fragmentation sorting operation on the objects associated with the description item.

[0089] In the above, by extracting the description items in the idle state from the preset handle description table, creating objects in the system memory and associating them with the description items, generating associated handles based on the description items; when accessing an object using a handle, comparing the handle with the corresponding description item in the handle description table to determine whether the handle matches the corresponding description item; determining that the handle matches the corresponding description item, locking the object associated with the description item, and performing an object access operation; determining that the handle does not match the corresponding description item, ending the current object access process. By adopting the above technical means, it is ensured that the handle reuse is accurate, avoiding the situation of accessing the wrong object when reusing the handle, solving the problem of misusing objects when reusing the handle, and optimizing the system memory management and program operation.

[0090] The object management device based on the handle structure provided in the second embodiment of the present application can be used to execute the object management method based on the handle structure provided in the first embodiment, and has the corresponding functions and beneficial effects.

[0091] Embodiment 3:

[0092] Embodiment 3 of the present application provides an electronic device. Referring to Figure 9 , the electronic device includes: a processor 31, a memory 32, a communication module 33, an input device 34, and an output device 35. The number of processors in the electronic device may be one or more, and the number of memories in the electronic device may be one or more. The processor, memory, communication module, input device, and output device of the electronic device may be connected through a bus or other means.

[0093] The memory 32, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as program instructions / modules corresponding to the object management method based on the handle structure described in any embodiment of the present application (for example, the creation module, comparison module, and access module in the object management device based on the handle structure). The memory mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system and application programs required for at least one function; the data storage area can store data created according to the use of the device, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some instances, the memory may further include a memory remotely set relative to the processor, and these remote memories can be connected to the device through a network. Examples of the above network include, but are not limited to, the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.

[0094] The communication module 33 is used for data transmission.

[0095] The processor 31 executes by running software programs, instructions, and modules stored in the memory. The input device 34 can be used to receive input digital or character information, and generate key signal inputs related to the user settings and function control of the device. The output device 35 may include a display device such as a display screen.

[0096] The above-provided electronic device can be used to execute the object management method based on the handle structure provided in Embodiment 1 above, and has corresponding functions and beneficial effects.

[0097] Embodiment 4:

[0098] The embodiment of the present application further provides a storage medium containing computer-executable instructions, and the computer-executable instructions are used to execute an object management method based on a handle structure when executed by a computer processor. The object management method based on the handle structure includes: extracting a description item in an idle state from a preset handle description table, creating an object in the system memory and associating it with the description item, and generating an associated handle based on the description item; when accessing an object using the handle, comparing the handle with the corresponding description item in the handle description table to determine whether the handle matches the corresponding description item; determining that the handle matches the corresponding description item, locking the object associated with the description item, and performing an object access operation; determining that the handle does not match the corresponding description item, and ending the current object access process.

[0099] Storage medium - Any of various types of memory devices or storage devices. The term "storage medium" is intended to include: installation media such as CD-ROM, floppy disk or magnetic tape devices; computer system memory or random access memory such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory such as flash memory, magnetic media (such as hard disks or optical storage); registers or other similar types of memory elements, etc. The storage medium may also include other types of memory or combinations thereof. Additionally, the storage medium may be located in a first computer system in which the program is executed, or may be located in a different second computer system that is connected to the first computer system through a network (such as the Internet). The second computer system may provide program instructions to the first computer for execution. The term "storage medium" may include two or more storage media residing in different locations (such as in different computer systems connected through a network). The storage medium may store program instructions (such as specifically implemented as a computer program) executable by one or more processors.

[0100] Of course, for a storage medium containing computer-executable instructions provided by the embodiment of the present application, the computer-executable instructions are not limited to the object management method based on the handle structure as described above, and can also execute related operations in the object management method based on the handle structure provided by any embodiment of the present application.

[0101] The object management device, storage medium, and electronic device provided in the above embodiments can execute the object management method provided by any embodiment of the present application. For technical details not described in detail in the above embodiments, reference can be made to the object management method provided by any embodiment of the present application.

[0102] The above is only the preferred embodiment of the present application and the technical principles applied. The present application is not limited to the specific embodiments described herein. Various obvious changes, re-adjustments, and substitutions that can be made by those skilled in the art will not depart from the protection scope of the present application. Therefore, although the present application has been described in more detail through the above embodiments, the present application is not limited to the above embodiments. Without departing from the concept of the present application, more other equivalent embodiments can be included, and the scope of the present application is determined by the scope of the claims.

Claims

1. An object management method based on handle structure, It is characterized in that include: Extracting a description item in an idle state from a preset handle description table, creating an object in a system memory and associating it with the description item, and generating an associated handle based on the description item, including: generating a unique identifier for the description item, and generating a handle associated with the description item based on the unique identifier; When the handle is used to access the object, the handle is compared with the corresponding description item in the handle description table to determine whether the handle matches the corresponding description item, which includes: determining whether the handle matches the corresponding description item based on the comparison result of the unique identifier; Determining that the handle matches the corresponding description item, locking an object associated with the description item, and performing an object access operation; Determining that the handle does not match the corresponding description item, and ending the current object access process; after extracting the description item in the idle state from the preset handle description table, further comprising: Clearing a reference count of the description item, where the reference count is used to count the number of locks of an object associated with the description item; Correspondingly, locking the object associated with the description item further includes: updating the reference count according to the locking and unlocking operations of the object associated with the description item, wherein the reference count is incremented by one when the locking operation is performed on the object associated with the description item, and is decremented by one when the unlocking operation is performed on the object associated with the description item; After updating the reference count according to the locking and unlocking operations of the object associated with the description item, the method further includes: When the reference count is zero, the handle state type of the description item is set to an idle state, and the association relationship between the description item and the corresponding handle is released; After setting the handle state type of the description item to an idle state, the method further includes: An object associated with the description item is determined, and a memory defragmentation operation is performed on the object associated with the description item.

2. The object management method based on the handle structure according to claim 1, It is characterized in that The generating a handle associated with the description item based on the unique identifier comprises: An index number of the description item in the handle description table is determined, and the index number and the unique identifier are combined into a handle associated with the description item.

3. The object management method based on handle structure according to claim 1, It is characterized in that After extracting the description item in the idle state from the preset handle description table, it also includes: The handle state type of the description item is switched from an idle state to an associated state.

4. An object management device based on a handle structure, It is characterized in that include: A creation module, used to extract a description item in an idle state from a preset handle description table, create an object in a system memory and associate it with the description item, and generate an associated handle based on the description item, wherein the creation module is specifically used to generate a unique identifier for the description item, and generate the handle associated with the description item based on the unique identifier; a comparison module, configured to compare the handle with the corresponding description item in the handle description table when the handle is used to access the object, and determine whether the handle matches the corresponding description item, wherein the comparison module is specifically configured to determine whether the handle matches the corresponding description item based on the comparison result of the unique identifier; An access module, used to determine whether the handle matches the corresponding description item, lock the object associated with the description item, and perform an object access operation; Determining that the handle does not match the corresponding description item, and ending the current object access process; After extracting the description item in the idle state from the preset handle description table, it also includes: Clearing a reference count of the description item, where the reference count is used to count the number of locks of an object associated with the description item; Correspondingly, locking the object associated with the description item further includes: updating the reference count according to the locking and unlocking operations of the object associated with the description item, wherein the reference count is incremented by one when the locking operation is performed on the object associated with the description item, and is decremented by one when the unlocking operation is performed on the object associated with the description item; After updating the reference count according to the locking and unlocking operations of the object associated with the description item, the method further includes: When the reference count is zero, the handle state type of the description item is set to an idle state, and the association relationship between the description item and the corresponding handle is released; After setting the handle state type of the description item to an idle state, the method further includes: An object associated with the description item is determined, and a memory defragmentation operation is performed on the object associated with the description item.

5. An electronic device, It is characterized in that include: memory and one or more processors; The memory is used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the handle structure-based object management method as described in any one of claims 1 to 3.

6. A storage medium containing computer executable instructions, It is characterized in that When the computer executable instructions are executed by a computer processor, they are used to execute the handle structure-based object management method as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Data access method of caching system

    CN103853504A

  • Data receiving method and device and remote control terminal

    CN105931441A