Resource capacity expansion method and device, electronic equipment and storage medium

The proxy function calls the setting function related to the pthread key, and uses the target array in the expanded memory to process the setting function when the resource exceeds the limit, which solves the application crash problem caused by the exhaustion of pthread key resources in the existing technology, and achieves faster and higher system stability.

CN119440786APending Publication Date: 2025-02-14BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310956177.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-31
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

When the pthread key resources are exhausted, the troubleshooting of unreasonable use situations and long cycles, resulting in application crashes.

Method used

Setting the function by proxy function call, and when setting the function call fails, the target array in the expansion memory is used to process the setting function, thereby realizing resource expansion and avoiding the use of thread key resources.

Benefits of technology

Improves the response speed of setting function calls, avoids the application crash due to the limit of pthread key resource, and improves the stability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119440786A_ABST
    Figure CN119440786A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a resource capacity expansion method and device, electronic equipment and a storage medium. The resource capacity expansion method comprises the steps that in response to a calling event of a set function, the set function is called through a proxy function, and the set function comprises an application programming interface related to a thread key; under the condition that calling of the set function fails, the set function is processed based on a target array associated with the set function; wherein the target array is an expansion resource stored in an expanded memory, and is used for storing contents associated with the set function. The technical problem caused by unreasonable use of thread key resources in troubleshooting is solved, under the condition that call of the set function fails, the set function is processed by expanding the target array in the memory, that is, the set function is processed by expanding the resources, use of the thread key resources is prevented from being analyzed, and the service life of the set function is prolonged. And the response speed of setting function calling is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to computer technology, and more particularly to a resource expansion method, device, electronic device, and storage medium. Background Art

[0002] The thread key, or pthread key, is an interface provided by the system to applications to support thread-local data capabilities. The Application Programming Interface (API) provided by the pthread key can implement a variety of functions, such as applying for a key, reading and writing thread values, and destroying a key. The pthread key is related to thread-local storage and provides the ability to isolate data between different threads using the same key.

[0003] Currently, the number of pthread key resources is limited. When an application uses more than the limit of pthread key resources, the application will crash, resulting in interruption of application use.

[0004] In the prior art, when pthread key resources are exhausted, a commonly used method is to check whether there is any unreasonable use of pthread key. During the checking, continuous detection is required, the checking method is complex, and the checking cycle is long. Summary of the invention

[0005] The present disclosure provides a resource expansion method, device, electronic device and storage medium, which solve the technical problems caused by checking the unreasonable use of thread key resources through the expansion method.

[0006] In a first aspect, an embodiment of the present disclosure provides a resource expansion method, including:

[0007] In response to a calling event of a setting function, calling the setting function through a proxy function, wherein the setting function includes an application programming interface related to a thread key;

[0008] In the case where the setting function fails to be called, processing the setting function based on the target array associated with the setting function;

[0009] The target array is an expanded resource stored in the expanded memory, and is used to store content associated with the set function.

[0010] In a second aspect, the embodiment of the present disclosure further provides a resource expansion device, including:

[0011] A calling module, for responding to a calling event of a setting function, calling the setting function through a proxy function, wherein the setting function includes an application programming interface related to a thread key;

[0012] A processing module, configured to process the setting function based on a target array associated with the setting function when the setting function fails to be called;

[0013] The target array is an expanded resource stored in the expanded memory, and is used to store content associated with the set function.

[0014] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:

[0015] one or more processing devices;

[0016] a storage device for storing one or more programs,

[0017] When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the resource expansion method provided by the present disclosure.

[0018] In a fourth aspect, an embodiment of the present disclosure further provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute the resource expansion method provided in the present disclosure.

[0019] The disclosed embodiment completes the call of the setting function through a proxy function. When implementing the call of the setting function, if the setting function call fails, the setting function is processed by the target array associated with the setting function in the expanded memory, thereby solving the technical problems caused by the unreasonable use of thread key resources. When the setting function call fails, the setting function is processed by the target array in the expanded memory, that is, the setting function is processed by the expanded resources, thereby avoiding the analysis of the use of thread key resources and improving the response speed of the setting function call. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.

[0021] Figure 1 It is a flowchart of a resource expansion method provided by an embodiment of the present disclosure;

[0022] Figure 2 It is a flowchart of a capacity expansion solution provided by an embodiment of the present disclosure;

[0023] Figure 3 It is a schematic diagram of implementing a capacity expansion solution provided by an embodiment of the present disclosure;

[0024] Figure 4 It is a flowchart of a resource expansion method provided by an embodiment of the present disclosure;

[0025] Figure 5 It is a schematic diagram of the structure of a resource expansion device provided by an embodiment of the present disclosure;

[0026] Figure 6 It is a structural schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0027] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0028] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0029] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0030] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0031] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0032] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0033] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.

[0034] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.

[0035] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.

[0036] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.

[0037] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.

[0038] Figure 1 It is a flow chart of a resource expansion method provided by an embodiment of the present disclosure. The embodiment of the present disclosure is applicable to the situation where a call to a set function is implemented when a thread key resource exceeds the limit. The method can be executed by a resource expansion device, which can be implemented in the form of software and / or hardware. Optionally, it can be implemented by an electronic device, which can be a mobile terminal, a PC or a server. The resource expansion method of the present disclosure can achieve resource expansion, such as achieving the expansion of thread key resources. The operating system of the present disclosure is not limited. For example, under the Android operating system, the pthread key, that is, the thread key resource can be expanded. The resource expansion method provided by the present disclosure can be executed after the application is started.

[0039] like Figure 1 As shown, the method includes:

[0040] S110 . In response to a calling event of a setting function, calling the setting function through a proxy function, wherein the setting function includes an application programming interface related to a thread key.

[0041] The setting function includes the application programming interface related to the thread key, that is, the API for hooking the pthread key. For example, a key creation function (i.e., pthread_key_create) for creating a key, a key deregistration function (i.e., pthread_key_delete) for deregistering a key, a function for setting the value of thread private data for a specified key (i.e., pthread_setspecific) and a function for reading the value of thread private data from a specified key (i.e., pthread_getspecific).

[0042] The call event can be considered as an event that calls a set function. The call event is not set here. Any event that requires the use of a set function can be considered a call event.

[0043] The proxy function can be considered as a function of the proxy setting function. The proxy means are not limited here, such as proxy setting function through online proxy, such as inline hook.

[0044] This step may respond to a call event of the setting function and obtain the native capability of the setting function through a proxy, ie, hooking the setting function.

[0045] S120 . When the setting function fails to be called, process the setting function based on a target array associated with the setting function.

[0046] In the present disclosure, the failure of setting function call can be considered as the failure of calling the setting function to return, which can indicate that the thread key resource is over limit, such as all 128 thread key resources have been occupied.

[0047] The target array is an expanded resource stored in the expanded memory, and is used to store content associated with the setting function. Different setting functions correspond to different content, such as a key and a value.

[0048] The target array can be an array of stored keys and / or an array of stored values.

[0049] The target array-based processing setting function can be used to store the content corresponding to the setting function through the target data, such as storing the keys created by the setting function through an array that stores keys, and storing the values ​​set by the setting function through an array that stores values.

[0050] In this step, when the setting function fails to be called, the setting function is called through the target array in the expanded memory. In the case of a setting function call failure, the expansion resource is dynamically enabled, which speeds up the setting function call.

[0051] The expanded memory may be memory expanded on the basis of the native memory. The native memory may be understood as the original memory of the system for storing native arrays. The native array may be considered as the original array of the system for storing key-value pairs related to thread keys.

[0052] In one embodiment, the target array includes: a key array corresponding to the thread stack and a value array corresponding to each thread in the thread stack.

[0053] The key array corresponding to the thread stack can be considered as an array for storing keys, one thread key corresponds to one key array. Each thread in the thread key can correspond to a value array, which can be used to store the values ​​in the key-value pair.

[0054] Figure 2 This is a flow chart of an expansion solution provided by an embodiment of the present disclosure. After the application is started, the API of the pthread key can be hooked (i.e., the hook setting function) to obtain the pthread key logic control right; after the hook proxy function starts, the original function, i.e., the setting function, is called first, so that all the capabilities of the native pthread key can be reused; then it is determined whether the original function is successfully called. In the case of failure to call the original function (i.e., failure to call the setting function), the expansion logic is entered (i.e., processing the setting function based on the target array); finally, the expansion result, i.e., the setting function return value, is returned, and the proxy function ends. When the original function is successfully called, the proxy function ends.

[0055] The implementation of the expansion logic refers to the native system implementation. For example, the key_map2 array in the expanded memory and the native key array of the native system, that is, the key_map array, are similar in implementation. For example, they are all in the native library, that is, inside libsysoptimizer.so, and multiple threads in the thread stack share a key_map array. When the expanded memory is enabled, multiple threads in the thread stack share a key_map2 array. The implementation of the key_data2 array in the expanded memory is similar to the native value array in the native system, that is, the key_data array. Among them, the key_map array and the key_data array can be considered as native arrays. The key_map2 array can be considered as the key array corresponding to the thread stack. The key_data2 array can be considered as the value array corresponding to each thread in the thread stack.

[0056] Figure 3is a schematic diagram of implementing a capacity expansion solution provided by an embodiment of the present disclosure, such as Figure 3 As shown, the thread stack includes multiple threads, the current execution thread can be static_tls, the native array corresponding to the current execution thread is stored in the native memory before the modification, the key_map array of the native array is used to store keys, and the key_data array is used to store values ​​corresponding to the keys. The native array includes placeholder keys (i.e., placeholder keys) and placeholder values ​​(i.e., placeholder values), which are used to indicate the target arrays in the expanded memory: key_map2 array and key_data2 array.

[0057] like Figure 3 As shown, the present disclosure includes expanded memory, i.e., expanded memory, including key_map2 array and key_data2 array. Similar to the native implementation, the key_map2 array is inside libsysoptimizer.so, and the key_data2 array is a copy for each thread (finding the pointer to the expanded memory of the current thread from the thread stack memory, i.e., determining the pointer to the expanded memory of the currently executing thread). In the present disclosure, each thread is bound to a dynamically allocated memory (i.e., malloc) memory.

[0058] The following is an exemplary description of the resource expansion solution using the setting function pthread_setspecific as an example:

[0059] In this example, we need to get the control of the system logic when the time limit is exceeded. The pthread key APIs are all exported symbols provided by the dynamic library libc.so, and we can use hooks to get control.

[0060] After hooking all the pthread key related APIs, you can completely customize the pthread key implementation process. For example, the data structure and processing flow can be different from the native ones.

[0061] The expansion plan process disclosed in this disclosure is as follows:

[0062] 1. In the proxy pthread_setspecific (i.e. setting function), the parameter key is used to identify whether the value is to be written to native memory or extended memory. The proxy pthread_setspecific implements writing the value corresponding to the key in the current execution thread.

[0063] The key is allocated by the proxy key creation function, namely proxy_pthread_key_create. In order to distinguish it from the native key, a special flag (i.e., identification information) is added to the key by bitwise OR, such as: KEY_VALID_FLAG2.

[0064] 2. If it is a natively assigned key (i.e. no identification information is recognized), it will be handed over to the native processing logic for processing and then returned.

[0065] 3. If it is a key allocated for expansion (i.e., the identification information is identified), the actual expansion array subscript is decoded from the key, i.e., the array subscript of the key array storing the key is determined. Figure 3 The array subscript can be 3.

[0066] 4. Get the key_data2 array pointer bound to the current thread (i.e., the current execution thread) for writing elements, that is, determine the key_data2 array pointer in the expanded memory of the current execution thread.

[0067] 5. Get the pointer to the corresponding array element and write the passed parameter value. This completes the information writing process in the current thread, that is, writing value at the position indicated by the array subscript of the value array expansion corresponding to the current thread, that is, writing value at the position corresponding to the array subscript 3.

[0068] The technical solution of the disclosed embodiment completes the call of the setting function through a proxy function. When implementing the call of the setting function, if the setting function call fails, the setting function is processed by the target array associated with the setting function in the expanded memory, thereby solving the technical problems caused by the unreasonable use of thread key resources. When the setting function call fails, the setting function is processed by the target array in the expanded memory, that is, the setting function is processed by the expanded resources, which avoids the analysis of the use of thread key resources and improves the response speed of the setting function call.

[0069] Based on the above embodiment, a variant embodiment of the above embodiment is proposed. It should be noted that in order to make the description concise, only the differences from the above embodiment are described in the variant embodiment.

[0070] In one embodiment, the setting function includes a key creation function, and in the event that the setting function fails to be called, processing the setting function based on a target array associated with the setting function includes:

[0071] In the case where the setting function call fails, the key corresponding to the key creation function is stored in the key array corresponding to the key creation function.

[0072] The key creation function can be pthread_key_create, which is used to create a key. When the target processing function processes the setting function, the key created by the key creation function can be stored by expanding the key array corresponding to the thread stack in the memory. The key is a global variable. No matter which thread calls pthread_key_create, the created key is accessible to all threads. Each thread sets different values ​​in the key according to its own needs, forming the same name but different values, that is, the same key but different values, one key with multiple values.

[0073] In one embodiment, the key array stores identification information of the key corresponding to the key creation function, and the identification information indicates that the key corresponding to the key creation function is stored in the expanded memory.

[0074] In this embodiment, identification information can be added to the key by bitwise OR. The identification information can be used to distinguish whether the key is allocated by native logic or allocated by expansion logic, such as stored in expansion memory.

[0075] In one embodiment, the setting function includes a value setting function, and in the event that the setting function fails to be called, processing the setting function based on a target array associated with the setting function includes:

[0076] In the event that the setting function call fails, determine whether the key corresponding to the value setting function is stored in the expanded memory. If so, store the value set by the value setting function in the value array corresponding to the current execution thread corresponding to the setting function. The value array is an array stored in the expanded memory for storing values ​​in key-value pairs.

[0077] The value setting function can be pthread_setspecific, which is used to set the value for key.

[0078] This embodiment can be used to determine whether the key corresponding to the value setting function is stored in the expanded memory by determining whether there is identification information (i.e., whether the key corresponding to the value setting function has identification information). If there is identification information, it can be considered to be stored in the expanded memory. If there is no identification information, it can be considered to be stored in the native memory.

[0079] See also Figure 3 When the value setting function is used to set the value of the key with array index 3 of the key array, it can be determined whether there is identification information for the key with array index 3. If so, the value set by the value setting function is stored in the corresponding position of the value array with array index 3 and written into value (i.e., the value in the key-value pair).

[0080] Figure 41 is a flow chart of a resource expansion method provided by an embodiment of the present disclosure. This embodiment refines the operation of processing the setting function. For details not yet provided in this embodiment, please refer to the above embodiments, which are not limited here. Figure 4 As shown, the resource expansion method provided by the present disclosure includes the following steps:

[0081] S410 . In response to a calling event of a setting function, calling the setting function through a proxy function, wherein the setting function includes an application programming interface related to a thread key.

[0082] S420: When the setting function fails to be called, determine a pointer to the expanded memory of the current execution thread corresponding to the setting function.

[0083] The current execution thread may be a thread that calls the setting function. The pointer of the expanded memory may indicate a pointer of a target array in the expanded memory corresponding to the current execution thread.

[0084] In this step, when the setting function call fails, a pointer to the expanded memory of the current execution thread corresponding to the setting function can be determined, so as to process the setting function based on the target array pointed to by the pointer.

[0085] This step may determine the pointer to the expanded memory of the current executing thread based on the placeholder value in the native array corresponding to the current executing thread.

[0086] S430: Process the setting function based on the target array stored in the expanded memory indicated by the pointer.

[0087] The pointer may point to a target array stored in the expanded memory, and this step may process the setting function through the target array.

[0088] In one example, see Figure 3 , the current execution thread can be static_tls, which determines the pointer of the expanded memory through the placeholder value in the key_data array, and processes the setting function in the target array pointed to by the pointer.

[0089] This embodiment refines the process of determining the target array. In this embodiment, the pointer of the expanded memory of the current execution thread corresponding to the setting function is first determined, so as to locate the target array of the current execution thread, and then the setting function is processed based on the target array.

[0090] In one embodiment, determining the pointer of the expanded memory of the current execution thread corresponding to the setting function includes:

[0091] Determine the native array corresponding to the current execution thread corresponding to the setting function;

[0092] The pointer of the expanded memory of the current execution thread is determined by the placeholder value in the native array.

[0093] Each thread in the system has a corresponding native array, and this embodiment can determine the native array corresponding to the current execution thread. In order to achieve memory expansion, this embodiment can pre-store placeholder values ​​in the native array, that is, placeholder value, to indicate the target array corresponding to the current execution thread, such as the key_data2 array.

[0094] The placeholder value may be a pointer to the expanded memory, or may be associated with a pointer to the expanded memory, and is not limited here, as long as the target array of the current executing thread can be determined through the placeholder value.

[0095] In the present disclosure, the size of the target array can be the same as the size of the native array. For example, if the size of the native array is 128, the size of the target array can also be 128. The size is not limited here. The size of the target array can be smaller than the size of the native array or larger than the size of the native array.

[0096] The present invention breaks through the 128 pthread key resource limit and can expand the system pthread key resources to 256, so that the application does not crash when the resources exceed 128. According to the principle of native pthread key, the design goal of the expansion plan can be: the native pthread key principle remains unchanged as much as possible; it can be dynamically expanded by 1 times in the case of exceeding the limit.

[0097] In the scenario where more than 128 pthread key resources are applied, the log is printed to verify whether the expansion is effective. From the log results, it can be seen that before the resource expansion, it failed when 114 resources were reached, and it was successful when 240 resources were reached after the resource expansion. Taking the key creation function as an example, failure can be failure to create successfully, and success can be success to create successfully. The crash rate after resource expansion is significantly lower than the crash rate before resource expansion.

[0098] The problem of insufficient thread keys in this disclosure has been basically solved, and the repair rate has reached 99.25%

[0099] Figure 5 is a schematic diagram of a resource expansion device provided by an embodiment of the present disclosure. The resource expansion device can be integrated in an electronic device, such as Figure 5 As shown, the device comprises:

[0100] A calling module 510, for responding to a calling event of a setting function, calling the setting function through a proxy function, wherein the setting function includes an application programming interface related to a thread key;

[0101] A processing module 520 is used for processing the setting function based on the target array associated with the setting function when the setting function fails to be called;

[0102] The target array is an expanded resource stored in the expanded memory, and is used to store content associated with the set function.

[0103] The technical solution provided by the embodiment of the present disclosure responds to the calling event of the setting function through the calling module 510, and calls the setting function through the proxy function, and the setting function includes an application programming interface related to the thread key; when the setting function call fails, the processing module 520 processes the setting function based on the target array associated with the setting function; the calling of the setting function is completed through the proxy function, and when implementing the calling of the setting function, when the setting function call fails, the setting function is processed by the target array associated with the setting function in the expanded memory, so as to solve the technical problems caused by the unreasonable use of thread key resources. When the setting function call fails, the processing of the setting function is implemented by the target array in the expanded memory, that is, the setting function processing is implemented by the expanded resources, so as to avoid the analysis of the use of thread key resources and improve the response speed of the setting function call.

[0104] In one embodiment, the processing module 520 includes:

[0105] A determination unit, configured to determine a pointer to an expanded memory of a current execution thread corresponding to the setting function when the setting function fails to be called;

[0106] The processing unit is used to process the setting function based on the target array stored in the extended memory indicated by the pointer.

[0107] In one embodiment, the determining unit is configured to:

[0108] Determine the native array corresponding to the current execution thread corresponding to the setting function;

[0109] The pointer of the expanded memory of the current execution thread is determined by the placeholder value in the native array.

[0110] In one embodiment, the target array includes:

[0111] A key array corresponding to the thread stack and a value array corresponding to each thread in the thread stack.

[0112] In one embodiment, the setting function includes a key creation function, and the processing module 520 is specifically used to:

[0113] In the case where the setting function call fails, the key corresponding to the key creation function is stored in the key array corresponding to the key creation function.

[0114] In one embodiment, the key array stores identification information of the key corresponding to the key creation function, and the identification information indicates that the key corresponding to the key creation function is stored in the expanded memory.

[0115] In one embodiment, the setting function includes a value setting function, a processing module 520, specifically configured to:

[0116] In the event that the setting function call fails, determine whether the key corresponding to the value setting function is stored in the expanded memory. If so, store the value set by the value setting function in the value array corresponding to the current execution thread corresponding to the setting function. The value array is an array stored in the expanded memory for storing values ​​in key-value pairs.

[0117] The resource expansion device provided in the embodiments of the present disclosure can execute the resource expansion method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.

[0118] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.

[0119] Figure 6 Schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 6 , which shows an electronic device (eg, Figure 6 A schematic diagram of the structure of a terminal device or server) 500.

[0120] The electronic device includes: one or more processing devices;

[0121] a storage device for storing one or more programs,

[0122] When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the resource expansion method provided by the present disclosure.

[0123] The terminal devices in the embodiments of the present disclosure may include but are not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., as well as fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0124] like Figure 6 As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An edit / output (I / O) interface 505 is also connected to the bus 504.

[0125] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0126] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 509, or installed from a storage device 508, or installed from a ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0127] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0128] The electronic device provided in the embodiment of the present disclosure and the resource expansion method provided in the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0129] The embodiments of the present disclosure provide a computer storage medium on which a computer program is stored. When the program is executed by a processor, the resource expansion method provided in the above embodiments is implemented.

[0130] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two.

[0131] The computer storage medium may be a storage medium of computer executable instructions, which, when executed by a computer processor, are used to perform the methods provided by the present disclosure.

[0132] Computer readable storage media may be, for example, but not limited to: electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination thereof. More specific examples of computer readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate, or transmit a program used by or in combination with an instruction execution system, device, or device. The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wire, optical cable, RF (radio frequency), etc., or any suitable combination of the foregoing.

[0133] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0134] The computer-readable medium may be included in the electronic device, or may exist independently without being installed in the electronic device.

[0135] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:

[0136] The computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device: responds to a call event of a setting function, calls the setting function through a proxy function, and the setting function includes an application programming interface related to a thread key;

[0137] In the case where the setting function fails to be called, processing the setting function based on the target array associated with the setting function;

[0138] The target array is an expanded resource stored in the expanded memory, and is used to store content associated with the set function.

[0139] The present disclosure may be written in one or more programming languages ​​or combinations thereof to form computer program codes for performing the operations of the present disclosure, including but not limited to object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).

[0140] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0141] The modules or units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a module or unit does not limit the unit itself in some cases. For example, calling a module may also be described as "setting a function call operation".

[0142] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0143] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0144] According to one or more embodiments of the present disclosure, [Example 1] provides a resource expansion method, including:

[0145] In response to a calling event of a setting function, calling the setting function through a proxy function, wherein the setting function includes an application programming interface related to a thread key;

[0146] In the case where the setting function fails to be called, processing the setting function based on the target array associated with the setting function;

[0147] The target array is an expanded resource stored in the expanded memory, and is used to store content associated with the set function.

[0148] According to one or more embodiments of the present disclosure, [Example 2] provides the method of Example 1, wherein, when the setting function call fails, processing the setting function based on the target array associated with the setting function includes:

[0149] In the case where the setting function fails to be called, determining a pointer to the expanded memory of the current execution thread corresponding to the setting function;

[0150] The setting function is processed based on the target array stored in the extended memory indicated by the pointer.

[0151] According to one or more embodiments of the present disclosure, [Example 3] provides the method described in Example 2, characterized in that determining the pointer of the expanded memory of the current execution thread corresponding to the setting function includes:

[0152] Determine the native array corresponding to the current execution thread corresponding to the setting function;

[0153] The pointer of the expanded memory of the current execution thread is determined by the placeholder value in the native array.

[0154] According to one or more embodiments of the present disclosure, [Example 4] provides the method described in Example 1, characterized in that the target array includes:

[0155] A key array corresponding to the thread stack and a value array corresponding to each thread in the thread stack.

[0156] According to one or more embodiments of the present disclosure, [Example 5] provides the method of Example 1, characterized in that the setting function includes a key creation function, and in the case where the setting function call fails, processing the setting function based on the target array associated with the setting function, including:

[0157] In the case where the setting function call fails, the key corresponding to the key creation function is stored in the key array corresponding to the key creation function.

[0158] According to one or more embodiments of the present disclosure, [Example 6] provides the method described in Example 5, characterized in that the key array stores identification information of the key corresponding to the key creation function, and the identification information indicates that the key corresponding to the key creation function is stored in the expanded memory.

[0159] According to one or more embodiments of the present disclosure, [Example 7] provides the method of Example 1, characterized in that the setting function includes a value setting function, and in the case where the setting function fails to be called, processing the setting function based on the target array associated with the setting function, including:

[0160] In the event that the setting function call fails, determine whether the key corresponding to the value setting function is stored in the expanded memory. If so, store the value set by the value setting function in the value array corresponding to the current execution thread corresponding to the setting function. The value array is an array stored in the expanded memory for storing values ​​in key-value pairs.

[0161] According to one or more embodiments of the present disclosure, [Example 8] provides a resource expansion device, including:

[0162] A calling module, for responding to a calling event of a setting function, calling the setting function through a proxy function, wherein the setting function includes an application programming interface related to a thread key;

[0163] A processing module, configured to process the setting function based on a target array associated with the setting function when the setting function fails to be called;

[0164] The target array is an expanded resource stored in the expanded memory, and is used to store content associated with the set function.

[0165] According to one or more embodiments of the present disclosure, [Example 9] provides an electronic device, the electronic device comprising:

[0166] one or more processing devices;

[0167] a storage device for storing one or more programs,

[0168] When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the resource expansion method as described in any one of claims 1-7.

[0169] According to one or more embodiments of the present disclosure, [Example 10] provides a storage medium containing computer executable instructions, which, when executed by a computer processor, are used to execute the resource expansion method as described in any one of claims 1-7.

[0170] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0171] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0172] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A resource expansion method, characterized in that: include: In response to a calling event of a setting function, calling the setting function through a proxy function, wherein the setting function includes an application programming interface related to a thread key; In the case where the setting function fails to be called, processing the setting function based on the target array associated with the setting function; The target array is an expanded resource stored in the expanded memory, and is used to store content associated with the set function.

2. The method according to claim 1, characterized in that: In the case where the setting function fails to be called, processing the setting function based on the target array associated with the setting function includes: In the case where the setting function fails to be called, determining a pointer to the expanded memory of the current execution thread corresponding to the setting function; The setting function is processed based on the target array stored in the extended memory indicated by the pointer.

3. The method according to claim 2, characterized in that The step of determining a pointer to an expanded memory of a current execution thread corresponding to the setting function includes: Determine the native array corresponding to the current execution thread corresponding to the setting function; The pointer of the expanded memory of the current execution thread is determined by the placeholder value in the native array.

4. The method according to claim 1, characterized in that: The target array includes: A key array corresponding to the thread stack and a value array corresponding to each thread in the thread stack.

5. The method according to claim 1, characterized in that: The setting function includes a key creation function, and in the case where the setting function fails to be called, processing the setting function based on a target array associated with the setting function, including: In the case where the setting function call fails, the key corresponding to the key creation function is stored in the key array corresponding to the key creation function.

6. The method according to claim 5, characterized in that The key array stores identification information of the key corresponding to the key creation function, and the identification information indicates that the key corresponding to the key creation function is stored in the expanded memory.

7. The method according to claim 1, characterized in that The setting function includes a value setting function, and in the case where the setting function fails to be called, processing the setting function based on a target array associated with the setting function includes: In the event that the setting function call fails, determine whether the key corresponding to the value setting function is stored in the expanded memory. If so, store the value set by the value setting function in the value array corresponding to the current execution thread corresponding to the setting function. The value array is an array stored in the expanded memory for storing values ​​in key-value pairs.

8. A resource expansion device, characterized in that: include: A calling module, for responding to a calling event of a setting function, calling the setting function through a proxy function, wherein the setting function includes an application programming interface related to a thread key; A processing module, configured to process the setting function based on a target array associated with the setting function when the setting function fails to be called; The target array is an expanded resource stored in the expanded memory, and is used to store content associated with the set function.

9. An electronic device, characterized in that: The electronic device comprises: one or more processing devices; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the resource expansion method as described in any one of claims 1-7.

10. A storage medium comprising computer executable instructions, wherein the computer executable instructions are used to execute the resource expansion method according to any one of claims 1 to 7 when executed by a computer processor.