Methods, apparatus, electronic devices and storage media for determining wake-up relationships

By constructing a target array to obtain wake-up source information layer by layer, the problem of large computational load and complexity in existing technologies is solved, and efficient thread wake-up relationship identification is achieved.

CN119473405BActive Publication Date: 2025-10-31HUAWEI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311017083.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-11
Publication Date
2025-10-31
Estimated Expiration
2043-08-11

AI Technical Summary

Technical Problem

Existing technologies involve large computational loads when identifying thread wake-up relationships, cannot perform cross-process searches, cannot support simultaneous searches of multiple threads, have space redundancy and invalid threads, and are computationally complex.

Method used

By constructing a target array, wake-up source information is obtained layer by layer. The wake-up relationship is identified by using a layer-by-layer search method, avoiding the use of binary search and breadth-first search algorithms, and using stubs to identify the wake-up relationship.

Benefits of technology

It reduces the computational load of wake-up relationship identification, improves identification efficiency, supports cross-process and multi-threaded searches, and reduces space redundancy and invalid threads.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473405B_ABST
    Figure CN119473405B_ABST
Patent Text Reader

Abstract

This application provides a method, apparatus, electronic device, and storage medium for determining wake-up relationships, applied in the field of communication technology. Specifically, it includes: constructing a target array, where each target array includes a structure built based on target thread information, and each array includes multiple structures; in response to the Mth call to the query interface request, any array in the target array retrieves wake-up source information layer by layer according to the wake-up relationship and the call to the query interface request, based on the addable wake-up levels. This application can reduce the computational load during wake-up relationship identification and improve the efficiency of wake-up identification.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] The embodiments of the present invention relate to the technical field of thread scheduling, and in particular to a method, apparatus, electronic device and storage medium for determining wake-up relationships. [Background Technology]

[0002] In related technologies, under certain specific scenarios, it is necessary to ensure the fast execution of a particular thread, such as a rendering thread related to image drawing. To achieve this, priority can be given to the rendering thread. However, this approach cannot guarantee the fast execution of the thread in some situations because there is a wake-up relationship for this thread; that is, the rendering thread can only be executed after the source thread that wakes it up has finished executing, and the source thread can be woken up by other threads. Therefore, to ensure the priority execution of this thread, it is necessary to query the wake-up relationship.

[0003] In related technologies, binary search and breadth-first search algorithms are used to identify wake-up relationships, but this method involves a large amount of computation. [Summary of the Invention]

[0004] This invention provides a method for determining wake-up relationships, which can reduce the computational load of wake-up recognition relationships.

[0005] In a first aspect, this application provides a method for determining wake-up relationships, comprising the following steps:

[0006] Construct a target array, in which each target array includes a structure built based on the target thread information, and each array includes multiple structures;

[0007] In response to the Mth query interface request, in the target array, any array retrieves the wake-up source information layer by layer according to the wake-up relationship and the call query interface request, based on the addable wake-up level;

[0008] In response to the Mth query interface request, the steps for retrieving wake-up source information from any array in the target array according to the wake-up relationship and the call query interface request, based on the addable wake-up levels, include:

[0009] If in response to the Xth call to the query interface request, the new wake-up level in any array of the target array is 1, query and obtain the wake-up source information of the 1st wake-up level, and place the structure built based on the wake-up source information of the 1st wake-up level in the position corresponding to the 1st wake-up level in any array of the target array;

[0010] In response to the X+1th query request, if any array in the target array has a newly added wake-up level of 2, query and retrieve the wake-up source information for the second wake-up level, and place the structure built based on the wake-up source information of the second wake-up level into the target array. Repeat this process for any array, in the position corresponding to the second wake-up level, until the newly added wake-up level equals the target wake-up level.

[0011] The Xth query interface request is any one of the previous M query interface requests.

[0012] The technical solution provided by the embodiments of this application can identify wake-up relationships without using breadth-first search and binary search, thus reducing the computational load of wake-up relationship identification.

[0013] One possible approach is that, in response to the Mth query interface request, the process of updating the wake-up source information layer by layer according to the wake-up relationship and the call query interface request, based on the addable wake-up levels, includes:

[0014] In response to the Mth query interface request, query the wake-up relationship within a specified time period. The wake-up relationship includes the target waker information and the target wake-up information. The specified time period starts from the time of the Mth query interface request and ends at the time of the (M+1)th query interface request.

[0015] If the target wake-up information meets the first condition, then construct a structure based on the target wake-up information and insert the structure based on the target wake-up information into the target array, at the position corresponding to the y-th wake-up level of any array;

[0016] If the target wake-up information satisfies the second condition, then the structure based on the target wake-up information is updated;

[0017] The first condition includes: the structure based on the target waker information does not exist in the target array, and is located at the position corresponding to the y-th waker level of any array;

[0018] The second condition includes: the structure based on the target waker information exists in the target array, at the position corresponding to the y-th waker level of any array;

[0019] Among them, the structure built based on the target wake-up information exists in the target array. In response to M calls to the query interface request, the new wake-up level that can be added in any array of the target array is y.

[0020] One possible approach is that the number of target arrays is equal to the number of target wake-up levels. In response to a query interface request, some or all of the target arrays are processed according to the wake-up relationship and the query interface request, with wake-up source information being obtained layer by layer according to the number of wake-up levels that can be added. In response to a query interface request, each array in some or all of the target arrays may have a different number of wake-up levels that can be added.

[0021] One possible approach is that, prior to the step of querying the wake-up relationships within a specified time period in response to the Mth call to the query interface request, the method further includes:

[0022] Identify wake-up relationships based on the objective function;

[0023] The steps for identifying wakefulness relationships based on the objective function include:

[0024] Add stubs to the objective function. The stubs are used to identify wake-up relationships. The objective function is called every time a wake-up occurs.

[0025] One possible approach is that the objective function includes at least one of: try to wake up and its upstream and downstream functions, and wake up new task and its upstream and downstream functions.

[0026] One possible approach is to number the subarrays within the target array from top to bottom as 0, 1, 2, 3, 4, 5...N-1, M. <N;

[0027] In response to the Mth query interface request, in the target array, any array is processed according to the steps of retrieving wake-up source information layer by layer based on the wake-up relationship and the query interface request, according to the addable wake-up levels.

[0028] The following method is used to determine the new wake-up levels corresponding to each array in the target array:

[0029] In the target array, the array numbered 0 can add a wake-up level of M+1, the array numbered 1 can add a wake-up level of M, the target array numbered 2 can add a wake-up level of M-1, and so on, with the target array numbered M having a wake-up level of 1.

[0030] One possible approach is to number the arrays in the target array from top to bottom as 0, 1, 2, 3, 4, 5...N-1;

[0031] In response to the Mth query interface request, the available wake-up level for each array in the target array is determined as follows, based on the wake-up relationship and the step of obtaining wake-up source information layer by layer according to the available wake-up levels in the query interface request:

[0032] In the target array, the array with number 0 has a new wake-up level of k+1, the array with number 1 has a new wake-up level of k, and so on. The array with number k has a new wake-up level of 1, the array with number k+1 has a new wake-up level of N, the array with number k+2 has a new wake-up level of N-1, and so on.

[0033] Where M≥N, and M%N=k and k≠0.

[0034] One possible approach is to number the arrays in the target array from top to bottom as 0, 1, 2, 3, 4, 5...N-1;

[0035] In response to the Mth query interface call request, the possible new wake-up levels for each array in the target array are determined as follows, based on the wake-up relationship and the step of obtaining wake-up source information layer by layer according to the new wake-up levels requested by the query interface call:

[0036] In the target array, the array with number 0 has a new wake-up level of 1, the array with number 1 has a new wake-up level of N, the array with number 2 has a new wake-up level of N-1, the array with number 3 has a new wake-up level of N-2, and so on.

[0037] Where M ≥ N, and M%N = 0.

[0038] One possible approach is that, in response to the Mth query interface request, the number of newable wake-up levels in one of the target arrays is equal to the target wake-up level.

[0039] The method also includes: in response to the Mth call to the query interface request, uploading the wake-up source information stored in one of the arrays in the target array, where one of the arrays in the target array only retains the structure built based on the target thread information.

[0040] Secondly, embodiments of this application provide a wake-up relationship determination device, comprising:

[0041] Builder module: Used to construct target arrays. Each target array contains a structure built based on the target thread information. Each array contains multiple structures.

[0042] Response module: Used to respond to the Mth query interface request. In the target array, any array is used to obtain wake-up source information layer by layer according to the wake-up relationship and the query interface request, based on the addable wake-up level.

[0043] The response module shown is specifically used for:

[0044] If in response to the Xth call to the query interface request, the new wake-up level in any array of the target array is 1, query and obtain the wake-up source information of the 1st wake-up level, and place the structure built based on the wake-up source information of the 1st wake-up level in the position corresponding to the 1st wake-up level in any array of the target array;

[0045] In response to the X+1th query request, if any array in the target array has a newly added wake-up level of 2, query and retrieve the wake-up source information for the second wake-up level, and place the structure built based on the wake-up source information of the second wake-up level into the target array. Repeat this process for any array, in the position corresponding to the second wake-up level, until the newly added wake-up level equals the target wake-up level.

[0046] The Xth query interface request is any one of the previous M query interface requests.

[0047] Thirdly, this application provides an electronic device, comprising:

[0048] At least one processor; and at least one memory communicatively connected to the processor, wherein:

[0049] The memory stores program instructions that can be executed by the processor, which can invoke the program instructions to perform the method as described in any one of claims 1 to 9.

[0050] Fourthly, this application provides a computer-readable storage medium that stores computer instructions that cause a computer to perform the method as described in the first aspect.

[0051] It should be understood that the second to fourth aspects of the embodiments of the present invention are consistent with the technical solutions of the first aspect of the embodiments of the present invention, and the beneficial effects achieved by each aspect and the corresponding feasible implementation are similar, and will not be described again. [Attached Image Description]

[0052] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0053] Figures 1(a) to 1(e) This is a schematic diagram illustrating wake-up relationship lookup in related technologies;

[0054] Figure 2 A software structure block diagram of an electronic device provided in an embodiment of the present invention.

[0055] Figures 3(a) to 3(d)This application provides a schematic diagram illustrating the step-by-step search for wake-up sources in its embodiments;

[0056] Figure 4 This is a schematic diagram of the structure provided for an embodiment of this application;

[0057] Figures 5(a) to 5(b) This application provides a schematic diagram illustrating the wake-up source process update for a specific array in an exemplary embodiment.

[0058] Figure 6 A schematic diagram of an array provided for an exemplary embodiment of Embodiment 1 of this application;

[0059] Figure 7 A schematic diagram illustrating an exemplary embodiment provided in this application, showing the addition of new wake-up levels;

[0060] Figure 8(a) is a schematic diagram of a newly added wake-up layer in another exemplary embodiment provided by the present application;

[0061] Figure 8(b) is a schematic diagram of another exemplary embodiment provided by the present application, showing the addition of a wake-up level;

[0062] Figures 9(a) to 9(d) A schematic diagram illustrating wake-up relationship recognition as an exemplary embodiment provided in this application;

[0063] Figure 10 A flowchart illustrating the construction process of the wake-up relationship lookup engine provided in this application embodiment;

[0064] Figure 11 A schematic diagram of the target array provided in the embodiments of this application;

[0065] Figure 12 This application provides a flowchart for updating the wake-up source process in an embodiment of the present application.

[0066] Figure 13 A flowchart illustrating the calculation process for adding wake-up levels is provided for embodiments of this application.

[0067] Figure 14 This is a schematic diagram of multi-threaded parallel search provided in an embodiment of this application;

[0068] Figure 15 This is another schematic diagram of multi-threaded parallel search provided in the embodiments of this application;

[0069] Figure 16 A flowchart illustrating a wake-up relationship determination method provided in this application embodiment;

[0070] Figure 17 This is a structural diagram of a wake-up relationship determination device provided in an embodiment of this application.

Detailed Implementation Methods

[0071] To better understand the technical solutions of the embodiments of the present invention, the embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0072] In certain scenarios, such as image rendering, it is necessary to ensure that the rendering thread runs first. However, simply ensuring that the rendering thread runs first does not guarantee that the rendering thread will run first. This is because the rendering thread is often the one being woken up. For example, the rendering thread may be woken up by thread A, and thread A may be woken up by thread B. In the wake-up relationship between A and the rendering thread, the rendering thread is the one being woken up, and thread A is the one waking up.

[0073] As those skilled in the art understand, in examples where thread B wakes up thread A, and thread A wakes up the rendering thread, the woken-up thread can only execute after the source thread has finished executing. For example, referring to Figure 1(a), where thread B wakes up thread A, thread A can only execute after thread B has finished executing. Therefore, especially when the wake-up relationships are complex, to ensure the priority of the target thread's scheduling, it is necessary to identify the wake-up relationships and synchronize the identification results to the underlying layer to shorten the wake-up time and guarantee the priority of the target thread. Similarly, to ensure the priority of scheduling multiple independent threads, it is necessary to identify the wake-up relationships of multiple independent wake-up trees.

[0074] Please refer to Figure 1(b). Assuming that the wake-up relationship in the wake-up tree in Figure 1(b) needs to be identified, the thread number of each thread needs to be determined first. The filling rule of the thread number is related to the time when the thread was created. That is, the earlier the time when a thread was created, the smaller its thread number.

[0075] This leads to the next step, as shown in Figure 1(b). All wake-up trees are placed into the target array according to their thread numbers in ascending order. Specifically, a binary search is used to determine the structure of the newly inserted thread in the target array. Assuming the newly created thread is 279, the threads after number 279 need to be shifted to ensure the array remains ordered.

[0076] Suppose that a specific wake-up relationship needs to be maintained. In related technologies, instrumentation can be used to add stubs and identify the wake-up relationship. Specifically, as shown in Figure 1(d), a `weaker` array is added to the structure type to record the wake-up source. Assuming A wakes up B, a search is first performed in the array shown in Figure 1(c). If thread A is not found in the `weaker` array of B, then thread A is added to the array shown in Figure 1(c).

[0077] Here, we assume that we need to query the multi-level wake-up sources of a certain thread. We need to use the breadth-first search (BFS) algorithm. The specific method is to recursively use the weaker array in the array shown in Figure 1(c) to find the wake-up source of each thread until the wake-up source of the specified level is found, and then stop the operation. The final array is shown in Figure 1(e).

[0078] For maintenance, the relevant kernel functions are called to identify wake-up relationships and add new stubs. The wake-up and wake-up entities, as well as their respective thread numbers, are identified. If A wakes up B, the target array is first queried to find B, and it is then checked whether A exists in the target array. If A does not exist, it is added. The specific method of adding A can be a binary search, which will not be detailed here.

[0079] This method reveals the following problems in the overall wakefulness relationship recognition:

[0080] 1) Unable to perform cross-process lookup: Since the target array in the relevant technology is based on all threads of the specified process, that is, assuming that in process A, you are looking for the relationship of rendering threads, and there is also a wake-up source C in process B that wakes up the rendering threads, then you cannot find the wake-up source C.

[0081] 2) Cannot support simultaneous lookups for multiple threads: For example, when specifying to look up the wake-up relationship of the rendering thread, it is not possible to look up the wake-up relationship of other threads at the same time.

[0082] 3) Spatial complexity: As mentioned above, placing all wake-up sources in a single target array results in spatial redundancy in the target array.

[0083] 4) Computational complexity: Here, each creation of a new thread requires the use of a binary search algorithm to determine the inserted structure in the target array and to move the corresponding structure of the thread in part of the target array. In addition, each query requires the use of a breadth-first search algorithm.

[0084] 5) Invalid threads exist: Invalid threads are not filtered when creating the target array, thus introducing irrelevant threads.

[0085] Therefore, it can be seen that the efficiency of thread relationship wake-up identification in related technologies needs to be improved. Based on this, this application provides a wake-up relationship determination method to improve the timeliness of wake-up relationship identification.

[0086] Figure 2 This is a software structure block diagram of the electronic device 100 according to an embodiment of the present invention.

[0087] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.

[0088] The application layer can include a series of application packages.

[0089] like Figure 2 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and SMS.

[0090] like Figure 2 As shown, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc.

[0091] The Android Runtime consists of core libraries and a virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.

[0092] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.

[0093] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0094] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.

[0095] The kernel layer is the layer between hardware and software. The kernel layer contains at least the display driver, camera driver, audio driver, and sensor driver.

[0096] The following assumes a scenario where a query is needed for the three wake-up sources of the rendering thread. First, a target array is established, taking a K*3 array as an example. The target array includes three subarrays. To obtain the three wake-up source information of the rendering thread from one of these subarrays, the query needs to proceed upwards layer by layer until the wake-up source information of the target wake-up level is reached. Assuming the number of times the kernel layer calls the query interface is M, refer to Figure 3(a). During the Xth call to the query interface, one subarray in the target array (for ease of description, this subarray will be referred to as the subarray mentioned here) queries the wake-up source information of the first wake-up level and constructs a structure based on this information. This structure is then placed in the position corresponding to the first wake-up level of the array.

[0097] Here, the wake-up source information structure for the Level 1 wake-up level is located at the end of this array.

[0098] Then, referring to Figure 3(b), when the query interface request is obtained for the (X+1)th time, the kernel queries the wake-up source information of the second wake-up level and constructs a structure based on the wake-up source information of the second wake-up level. The structure constructed based on the wake-up source information of the second wake-up level is placed in the position corresponding to the second wake-up level in the target array. At this time, the wake-up source information of the second wake-up level can be directly placed at the end of the array. Based on this, the wake-up source information of the target wake-up level can be obtained by querying layer by layer, as shown in Figure 3(c). Finally, the array shown in Figure 3(d) can be obtained.

[0099] When the query interface is called for the (X+2)th time to request the array to query the wake-up source information of the 3rd wake-up level, the kernel queries the wake-up source information of the 3rd wake-up level, and constructs a structure based on the wake-up source information of the 3rd wake-up level. The structure constructed based on the wake-up source information of the 3rd wake-up level is placed in the position corresponding to the 3rd wake-up level in the target array, thereby obtaining the 3 wake-up source information of the rendering thread.

[0100] At this point, the wake-up source information of the 3rd wake-up level can be directly constructed into a structure and placed at the end of the array.

[0101] In this application, compared to related technologies, there is no need to use binary search to sort threads by thread number when constructing the array.

[0102] It should be noted that the wake-up level expresses the number of times a wake-up operation needs to be performed to schedule a certain thread to the target thread. In other words, the wake-up level represents the number of wake-ups required to schedule a certain thread to the target thread.

[0103] For example, regarding the rendering thread, assuming A wakes up the rendering thread, then for the rendering thread, thread A is the parent thread of the rendering thread, and the wake-up level of thread A for the rendering thread is 1. If thread B wakes up thread A, and thread B is the parent thread of thread A, then the wake-up level of thread B for the rendering thread is 2.

[0104] In summary, in the embodiments provided in this application, in order to find the wake-up relationship of the target thread, it is first necessary to construct a target array and place the target thread in the target array. Then, in response to the Mth call to the query interface request, any array in the target array obtains the wake-up source information layer by layer according to the wake-up relationship and the call to the query interface request, according to the addable wake-up level.

[0105] It should be noted that the target thread here refers to the thread for finding the wake-up level. In the previous example, the search was performed on the rendering thread, and the target thread corresponds to the rendering thread mentioned in the previous embodiment.

[0106] Therefore, it is possible to obtain N levels of wake-up sources for the target thread without using binary search or breadth-first search algorithms.

[0107] In summary, in response to the Mth query interface request, the steps for any array in the target array to retrieve wake-up source information based on wake-up relationships and the query interface request, according to the addable wake-up levels, include:

[0108] If in response to the Xth call to the query interface request, the new wake-up level in any array of the target array is 1, query and obtain the wake-up source information of the 1st wake-up level, and place the structure built based on the wake-up source information of the 1st wake-up level in the position corresponding to the 1st wake-up level in any array of the target array;

[0109] In response to the X+1th query request, if any array in the target array has a newly added wake-up level of 2, query and retrieve the wake-up source information for the second wake-up level, and place the structure built based on the wake-up source information of the second wake-up level into the target array. Repeat this process for any array, in the position corresponding to the second wake-up level, until the newly added wake-up level equals the target wake-up level.

[0110] The Xth query interface request is any one of the previous M query interface requests.

[0111] The following section describes how to place wake-up source information and how to construct the structure in this application:

[0112] Please refer to Figure 4Assuming that in response to the Mth call to the query interface request, the wake-up relationship within a specified time period is queried. The wake-up relationship includes the target waker information and the target wake-up information. The target waker information and the target wake-up information include, but are not limited to: the wake-up level of the wake-up source relative to the target thread, the number of wake-ups of the wake-up source between the time when it obtains the Mth call to the query interface request and the time when it obtains the (M-1)th call to the query interface request (i.e., the number of wake-ups within the specified time period described below), the thread number of the wake-up source, and the parent thread number of the wake-up source (i.e., the thread number of the waker of the wake-up source), and a structure is constructed based on this.

[0113] Those skilled in the art can write the wake-up level of the wake-up source relative to the target thread, the number of wake-ups between the time when the wake-up source obtains the Mth call to the query interface request and the time when it obtains the (M-1th)th call to the query interface request, the thread number of the wake-up source, and the parent thread number of the wake-up source (i.e., the thread number of the waker of the wake-up source) into a structure in sequence, thereby constructing a structure based on the wake-up source type.

[0114] It should be noted that three integer variables are defined within the structure, used to identify the number of wake-ups within a specified time period, the thread number of the wake-up source, and the parent thread number of the wake-up source, respectively. Additionally, to read the target wake-up level, an unsigned integer variable of size W bits can be defined in the kernel task struct, where W / N bits represent the position of the structure in a certain array, thereby allowing the read of the wake-up level.

[0115] Meanwhile, for arrays, each structure is equivalent to a member. In response to the change in the number of times the query interface is called to request input, for any array in the target array, the number of new wake-up levels can be added layer by layer until the number of new wake-up levels equals the target wake-up level. When the number of new wake-up levels equals the target wake-up level, the wake-up source information of the target wake-up level can be obtained. When the system layer performs the operation of querying the wake-up source of the new wake-up level, the structure can be placed in the array.

[0116] For example, assuming that the level of the wake-up source that can be added to array A is 2, the structure of the level 2 wake-up source information within the specified time period will be constructed and placed in the position of the level 2 wake-up source in array A. At the same time, the thread corresponding to the level 2 wake-up source information in array A has a wake-up relationship with the thread corresponding to the level 1 wake-up source in array A within the specified time period. That is, the thread corresponding to the level 2 wake-up source in array A is the parent thread of the thread corresponding to the level 1 wake-up source in array A. The specified time period is the time period between the two most recent calls to the query interface.

[0117] For example, assuming the current request is the M+1th call to the query interface, the specified time period is the time period between the M+1th request to retrieve the query interface and the Mth request to retrieve the query interface.

[0118] Based on this, in response to the (M+1)th call to the query interface, the level 2 wake-up source information in array A is obtained. Here, it is necessary to obtain the parent thread of the thread corresponding to the level 1 wake-up source information in array A between the (M+1)th time the query interface is obtained and the Mth time the query interface is obtained. A structure is then constructed based on the parent thread information, and the structure constructed based on this parent thread is placed in the position of the level 2 wake-up source in array A.

[0119] It should be noted that the structure constructed by the parent thread mentioned in this application is placed in the position of the second-level wake-up source in array A. Specifically, this means inserting the aforementioned custom structure containing three variables into the array and writing the unsigned integer variable of size Wbit into the task struct structure.

[0120] Then, in a certain scenario, assuming the Mth query interface request is made, the addable level of array B is y, and L11 is located in the position corresponding to the wake-up level y-1 of array B. Within a specified time period, multiple wake-up events of thread A waking up L11 occur. When the query first finds that A has woken up L11, combined with the above, the structure built based on thread A exists in array B, which means that the wake-up relationship between thread A and thread L11 has already been expressed in array B. That is, at this time, the wake-up relationship between thread A and thread L11 still exists, and it is necessary to update the wake-up count of thread L11.

[0121] Please refer to Figure 5(a). For example, assume that within a specified time period, L21 thread wakes up L11 thread twice. When L21 wakes up L11 for the first time, the structure built based on the L21 thread information is placed in the position corresponding to the y wake-up level in array B. When L21 wakes up L11 for the second time, the structure built based on the L21 thread information is updated.

[0122] Comparing Figure 5(a) and Figure 5(b), the number of wake-ups in the structure built based on L21 thread information is accumulated. For this reason, the number of wake-ups in the structure built based on L21 thread information changes from 1 to 2.

[0123] Therefore, in response to the Mth query interface request, the process of updating the wake-up source information of any array in the target array according to the wake-up relationship and the call query interface request, layer by layer according to the addable wake-up levels, includes:

[0124] In response to the Mth query interface request, query the wake-up relationship within a specified time period. The wake-up relationship includes the target waker information and the target wake-up information. The specified time period starts from the time of the Mth query interface request and ends at the time of the (M+1)th query interface request.

[0125] If the target wake-up information meets the first condition, then construct a structure based on the target wake-up information and insert the structure based on the target wake-up information into the target array, at the position corresponding to the y-th wake-up level of any array;

[0126] If the target wake-up information satisfies the second condition, then the structure based on the target wake-up information is updated;

[0127] The first condition includes: the structure based on the target waker information does not exist in the target array, and is located at the position corresponding to the y-th waker level of any array;

[0128] The second condition includes: the structure based on the target waker information exists in the target array, at the position corresponding to the y-th waker level of any array;

[0129] Among them, the structure built based on the target wake-up information exists in the target array. In response to M calls to the query interface request, the new wake-up level that can be added in any array of the target array is y.

[0130] In summary, regarding the L21 thread waking up the L11 thread, the L21 thread corresponds to the target waker, and the L11 thread corresponds to the target being woken up.

[0131] Continuing with the previous example, and taking the query of the rendering thread's three-level wake-up source as an example, firstly, a structure is built based on the rendering thread and placed in each array of the target array. Assuming that in response to the Mth query interface request, and assuming the wake-up level of array A in the target array is 1, the wake-up source information of level 1 is placed in the structure corresponding to the level 1 wake-up level of array A. In response to the (M+1)th query interface request, the wake-up level of array A is 2. Then, the structure built based on the wake-up source information of level 2 is placed in the structure corresponding to the level 2 wake-up level of array A. In response to the (M+2)th query interface request, the wake-up level of array A is 3. Then, the structure built based on the wake-up source information of level 3 within the specified time period is placed in the position corresponding to the level 3 wake-up level of array A. In response to the (M+4)th query interface request, the query result is returned, and all data except the target thread is uploaded. At this point, array A only retains the rendering thread information, forming the structure shown below. Figure 6 The array shown.

[0132] It should be noted that before each call to the query section interface, the wake-up relationship obtained each time needs to be identified. To identify the wake-up relationship, the specific implementation method is as follows: The waker and the wake-up recipient are identified using the `try_to_wake_up` function and its upstream and downstream functions, or the `wake up new task` function and its upstream and downstream functions. Specifically, stubs are added to `try_to_wake_up` and its upstream and downstream functions, or the `wake up new task` function and its upstream and downstream functions, to identify the waker and the wake-up recipient.

[0133] In other words, before the step of querying the wake-up relationships within a specified time period in response to the Mth call to the query interface request, the method also includes:

[0134] Identify wake-up relationships based on the objective function;

[0135] The steps for identifying wakefulness relationships based on the objective function include:

[0136] Add stubs to the objective function. The stubs are used to identify wake-up relationships. The objective function is called every time a wake-up occurs.

[0137] It should be noted that the objective function includes at least one of: try to wake up and its upstream and downstream functions, and wake up newtask and its upstream and downstream functions.

[0138] Based on the aforementioned embodiments, it is known that for array A, the system layer cannot output the wake-up source of the target wake-up level for each obtained call query interface request. In this regard, in the embodiments provided in this application, the number of arrays in the target array is equal to the number of target wake-up levels. Continuing with the foregoing, if the number of target wake-up levels is 3, then the target array contains three arrays. In each response to the call query interface request, all or part of the aforementioned three arrays perform the aforementioned step of obtaining wake-up source information layer by layer according to the addable wake-up levels. At the same time, for the array that performs the aforementioned step of obtaining wake-up source information layer by layer according to the addable wake-up levels, in response to the call query interface request, each array can add a different wake-up level.

[0139] For example, suppose two arrays in the target array have performed the step of retrieving wake-up source information layer by layer according to the addable wake-up level. Then, the updateable levels of these two arrays in response to the query interface request are different. Understandably, if all arrays in the target array have performed the step of retrieving wake-up source information layer by layer according to the addable wake-up level, then in the target array, in response to the query interface request, there will always be an array whose addable wake-up level is the target wake-up level. This ensures that in each response to the query interface request, the query result of the wake-up source of the target wake-up level can be output, that is, the query result of the wake-up source of the target wake-up level can be output in real time, realizing the maintenance and updating of the query result.

[0140] Therefore, in this application, the method for determining the addition of a wake-up level described later is only one possible implementation and is not a limitation of this application.

[0141] The following will explain how to determine the new wake-up levels for each array in the first array under different circumstances:

[0142] Continuing with the example of finding the wake-up source information of the rendering thread, we construct three arrays, i.e., the target array includes three arrays. Here, we number each array in the first array, for example, numbered 0, 1, and 2. First, we initialize array 0. For array 0, we can add a wake-up level of 1. For arrays 1 and 2, we do not perform any operations at this time. Assuming that L11 wakes up the rendering thread, and thread L11 is the level 1 wake-up source of array 0, we construct a structure for the thread information of L11 and place the structure based on L11 in the structure corresponding to the level 1 wake-up level in array 0. This is the initialization.

[0143] In response to the first query interface request, a wake-up level of 2 can be added for array 0, and a wake-up level of 1 can be added for array 2. If, during the time period between the first and second query interface requests, there is a wake-up relationship where thread L21 wakes up thread L11 and thread L12 wakes up the rendering thread, then, based on the above, L12 is a level 1 wake-up source. Here, the structure built based on L12 is placed in the position corresponding to the level 1 wake-up level of array 1, and the structure built based on L21 is placed in the position corresponding to the level 2 wake-up level of array 0.

[0144] In response to the second query interface request, for array 0, a wake-up level of 3 can be added; for array 2, a wake-up level of 2 can be added; and for array 3, a wake-up level of 1 can be added. Assuming there is a wake-up relationship where thread L31 wakes up thread L22, thread L22 wakes up thread L12, and L12 wakes up the rendering thread, based on the above, for array 0, when thread L31 wakes up thread L22, the structure built based on thread L31 information is placed in the position corresponding to the 3rd wake-up level of array 1; the structure built based on thread L22 information is placed in the position corresponding to the 2nd wake-up level of array 2; and for thread L12 waking up the rendering thread, the structure built based on thread L12 information is placed in the position corresponding to the 1st wake-up level of array 3.

[0145] Based on the foregoing, using a recursive approach, we can derive the new wake-up levels that can be added to each array in the target array:

[0146] Reference Figure 7 In the target array, the array numbered 0 can add a wake-up level of M+1, the array numbered 1 can add a wake-up level of M, the target array numbered 2 can add a wake-up level of M-1, and so on, with the target array numbered M having a wake-up level of 1.

[0147] It is also known that, in response to the Mth query interface request, in the current context, only the M arrays execute the steps of obtaining the wake-up source information layer by layer according to the wake-up relationship and the query interface request, and the wake-up level that can be added is M+1-a. At the same time, for the array numbered a in the target array, the wake-up level that can be added is M+1-a.

[0148] It is worth noting that the target array is also accompanied by a pointer, which points to array 0 (not shown in the figure).

[0149] In summary, when the response is obtained for the third time in response to the query interface request, the second query is considered to have ended by default. Array 0 has obtained the wake-up source information of the target wake-up layer. At this time, array 0 will upload all data except the target thread to the upper layer and clear all data except the target thread. The pointer will then be moved down to array 1.

[0150] At this point, the number of new wake-up levels that can be added to array 0 is 1, the number of new wake-up levels that can be added to array 1 is 3, and the number of new wake-up levels that can be added to array 2 is 2.

[0151] In response to the fourth query interface request, array 1 retrieves the wake-up source information of the target wake-up layer. At this time, array 1 uploads all data except the target thread to the upper layer and clears all data except the target thread. The pointer is then moved down to array 2.

[0152] At this point, the number of new wake-up levels that can be added to array 0 is 2, the number of new wake-up levels that can be added to array 1 is 1, and the number of new wake-up levels that can be added to array 2 is 3.

[0153] In response to the 5th query interface request, array 2 retrieves the wake-up source information of the target wake-up layer. At this time, array 2 uploads all data except the target thread to the upper layer and clears all data except the target thread. The pointer then points to array 0.

[0154] At this point, array 0 can have 3 new wake-up levels, array 1 can have 2 new wake-up levels, and array 2 can have 1 new wake-up level. Array 1 then uploads all data except for the structure built based on the target thread information to the upper layer, clears all data except for the target thread, and moves the pointer down to array 2, thus forming a loop.

[0155] Here, we assume that the target wake-up level is N. When the query interface request is obtained for the N+1th time, compared with the first time the query interface request is obtained, for a certain array, a new wake-up level can be added and looped according to the number of query interface requests, and the loop period is N.

[0156] Therefore, when M>N, by utilizing the cyclic relationship and the remainder of M divided by N, we can determine the new wake-up levels that can be added to each array in the target array.

[0157] Referring to Figure 8(a), if M>N, and M%N=k and k≠0.

[0158] In the target array, the array with number 0 has a new wake-up level of k+1, the array with number 1 has a new wake-up level of k, and so on. The array with number k has a new wake-up level of 1, the array with number k+1 has a new wake-up level of N, the array with number k+2 has a new wake-up level of N-1, and so on.

[0159] Referring to Figure 8(b), when M>N and M%N=0, and considering the number of new wake-up levels for each array during the third query interface request, it can be seen that the number of new wake-up levels for each array in the target array is:

[0160] The array with number 0 can add 1 wake-up level, the array with number 1 can add N wake-up levels, the array with number 2 can add N-1 wake-up levels, the array with number 3 can add N-2 wake-up levels, and so on.

[0161] Meanwhile, for pointers, when M≥N, each time the pointer moves, as mentioned above, when M=3, the pointer moves from array 0 to array 1; when M=4, it moves from array 1 to array 2, and so on. However, when the pointer moves to array N-1, it responds again to the query interface request and moves back to array 1.

[0162] That is, in response to the Mth call to the query interface, the method also includes:

[0163] If k≠N-1, the pointer moves from the index k to the target array with index k+1. If k=N-1, the pointer moves to the target array with index 0.

[0164] It is worth noting that those skilled in the art can refer to the teachings of this application to construct multiple target arrays, each array corresponding to a target thread, and simultaneously search for the wake-up source information of each thread. That is, it is necessary to search for the level 3 wake-up source of thread A and the level 4 wake-up source information of thread B. Here, two target arrays are constructed. The first target array includes three arrays, and each array in the first target array contains the information of thread A. The second target array includes four arrays, and each array in the second target array contains the information of thread B. The two arrays simultaneously identify the wake-up relationship in parallel according to the aforementioned embodiment. To prevent duplication, it will not be described again here.

[0165] For ease of understanding, based on the foregoing embodiments, the wake-up relationship determination method proposed in this application will be described below with reference to an exemplary embodiment:

[0166] Here, assuming we need to find the level 3 wake-up source information for thread T, we first construct a target array. As mentioned above, the target array includes three arrays, numbered 0, 1, and 2 respectively. Initialization is then performed. Whenever a wake-up relationship occurs, the target function is called. Static points are added to the target function to identify the waker and the wake-up. During initialization, we find that L11 wakes up thread T and L12 wakes up thread T. As mentioned above, the L11 and L12 thread information correspond to the first-level wake-up source information. At this point, we construct a structure for the L11 and L12 thread information. This structure includes: thread number, wake-up count, parent thread number, etc. In the task struct structure, we define W-bit unsigned integer variables to prevent duplication, which will not be elaborated here. We place the structure constructed based on the L11 and L12 thread information into the position corresponding to the first-level wake-up level in array 0. The resulting array is shown in Figure 9(a).

[0167] If a query command is issued at this time, a query interface call request is generated in response to the query command. If three wake-up events occur, namely L11>>T, L21>>L11, and L21>>L11, where >> represents wake-up, a search is performed in the target array for the wake-up, that is, T and L11 are traversed and searched in the target array. After the search is completed, for L21>>L11, a search is performed for the L11 thread. At this time, the structure built based on the L11 thread information already exists in array 0, and the wake-up level of L11 is 1. Then it is determined whether the new wake-up level of array 0 is 2. Here, the new wake-up level of array 0 is 2, and there is no structure built based on the L21 thread in array 0. At this time, the first condition is met. Then the structure built based on the L21 thread information is placed in the position corresponding to the second wake-up level of array 0. The position corresponding to the second wake-up level can be located at the end of array 0 at this time.

[0168] If there is also an L21 >> L11 wake-up event, then the same traversal search is performed on L11. The search process will not be described in detail here. At this time, array 0 contains a structure built based on the wake-up source information corresponding to thread L21. The wake-up count of the structure built based on thread L11 in array 0 is updated.

[0169] For L11 >> T, with T as the target thread and L11 as the level 1 wake-up source, the thread information based on L11 is placed in the structure corresponding to the level 1 wake-up level of array 1. The resulting array is shown in Figure 9(b).

[0170] If a second query command is issued, the response to the second query command is as follows: the first query is completed by default, and a query interface call request is generated. The response to the query interface call request is as follows: in conjunction with the above, the number of new wake-up levels that can be added to array 0 is 3, the number of new wake-up levels that can be added to array 1 is 2, and the number of new wake-up levels that can be added to array 0 is 1. If there are wake-up events L31>>L12, L31>>L11, L31>>L21, L12>>T, and L11>>L21 during the time period between the first and second query interface calls, the response is as follows:

[0171] For L31 >> L12, consistent with the previous embodiment, L12 is traversed and searched. It is found that the structure built based on L12 exists in array 0, and the wake-up level of the L12 thread corresponding to the T thread in array 0 is 1. At this time, based on the above, for array 0, a wake-up level of 3 can be added. Therefore, the structure built based on the L31 thread information cannot be placed in array 0.

[0172] For L31 >> L11, we also iterate through the L11 thread information. We find that there are structures built based on L11 thread information in both array 0 and array 1. For array 0 and array 1, the L11 thread corresponds to the T thread, and the wake-up level is 1. However, in array 0, a wake-up level of 3 can be added, so L31 thread information cannot be written into array 0. But for array 1, a wake-up level of 2 can be added, and there is no structure built based on L31 thread information in array 1. Therefore, the structure built based on L31 thread information is placed in array 1 at the position corresponding to the second wake-up level.

[0173] For L31 >> L21, traversing and searching for L21, we find that there is a structure in array 0 that includes information about thread L21. Relative to thread T, the wake-up level of L21 in array 0 is 2, and the new wake-up level that can be added in array 0 is 3. Therefore, the structure based on information about thread L31 can be placed in array 1, in the position corresponding to the 3rd wake-up level.

[0174] For L12 >> T, the L12 thread corresponds to the T thread as a level 1 wake-up source. Here, the new wake-up level that can be added in array 2 is 1. The structure built based on the L12 thread information is placed in the position corresponding to the wake-up source of the first wake-up level in array 2.

[0175] Similarly, a traversal search is performed for the L21 thread. At this time, the structure built based on the L21 thread is found to exist in array 0. Here, the structure built based on the L11 thread information is placed in the position corresponding to the level 3 wake-up source in array 0. At this time, array 0 stores the structure built based on the L11 thread information, the structure built based on the L12 thread information, the structure built based on the L21 thread information, the structure built based on the L31 thread information, and the structure built based on the L11 thread information. It can be seen that the embodiments of this application can identify the circular wake-up relationship using arrays. Here, the query results of the circular wake-up relationship using arrays make the identification results more intuitive.

[0176] Meanwhile, no operation is performed on L31 >> L12, thus filtering out invalid wake-up relationships without the aid of a whitelist. The resulting array is shown in Figure 9(c).

[0177] Meanwhile, comparing the L31 thread, its wake-up level relative to the T thread is 3 in array 0 and 2 in array 1. This comparison shows that for the same thread, the wake-up level may be different in different arrays.

[0178] It should be noted that, referring to Figure 9(d), before the third query command is issued, the pointer of the target array always points to array 0. For array 0, when the third query command is issued, array 0 obtains the level 3 wake-up source information. For array 0, the data in the array is uploaded. After the upload, array 0 only includes the T thread information, that is, the structure built based on the target thread information, and the pointer is moved down to array 2.

[0179] Meanwhile, the number of new wake-up levels that can be added is 1 for array 0, 3 for array 1, and 2 for array 2.

[0180] When the query command is issued for the fourth time, the third query is assumed to have ended. At this time, the data of array 1 will continue to be uploaded, and the pointer will continue to be moved down to array 2.

[0181] At this point, the number of new wake-up levels that can be added for array 0 is 2, the number of new wake-up levels that can be added for array 1 is 1, and the number of new wake-up levels that can be added for array 2 is 3.

[0182] When the fifth query command is issued, the fourth query is assumed to have ended. The data in array 2 will continue to be uploaded, and the pointer will return from array 2 to array 0.

[0183] In other words, when M calls the query interface to request, the call pointer always points to an array that can add a wake-up level of N, where N is the target wake-up level.

[0184] In summary, in response to the Mth query interface request, the number of new wake-up levels that can be added to one of the arrays in the target array is equal to the target wake-up level. At the same time, the wake-up source information stored in one of the arrays in the target array is uploaded, and one of the arrays in the target array only retains the structure built based on the target thread information.

[0185] In summary, this application has the following beneficial effects:

[0186] 1) Filtering of invalid threads was achieved without the aid of blacklists and whitelists.

[0187] 2) Cross-process lookup is implemented. Based on the process of determining the wake-up relationship, and limited to searching all threads in a process, cross-process lookup is implemented.

[0188] 3) It can enable multiple threads to search for wake-up relationships simultaneously. Assuming that the wake-up sources of threads A and B are searched at the same time, it is only necessary to build arrays for threads A and B respectively and search in the manner described above.

[0189] 4) It realizes the search of circular wake-up relationships and expresses the circular wake-up relationships using arrays, that is, it does not use a ring to express circular wake-up relationships, which is convenient for processing.

[0190] 5) When a new thread is created, there is no need to maintain the query results. For example, if a new thread L13 >> T is created, L13 only needs to be placed in an array that can be updated to wake-up layer 1. There is no need to maintain the query results.

[0191] 6) This application is implemented using a kernel, which improves efficiency.

[0192] Based on all the foregoing embodiments, in order to implement the above logic, this application requires the construction of an engine for identifying wake-up relationships. Please refer to [reference needed]. Figure 10 Corresponding to the aforementioned embodiment, firstly, the target thread T and the target wake-up level N are specified, and then N arrays are created and numbered to form the first target array. A structure is constructed based on the thread information of the target thread T. This structure can carry the following information: the thread number of the thread, the thread number of the thread's parent thread, the wake-up level of the thread corresponding to the target thread T, and the number of times the thread is woken up within a specified time period. The structure based on the thread information of the target thread T is placed in the N arrays, thus completing the array construction. The constructed arrays are as follows: Figure 11 As shown

[0193] It should be noted that the relationship between arrays and structures is as follows: the members in an array correspond to the structures. To obtain the position of a member (i.e., a specified structure) in the array, W unsigned integer member variables are added to the task struct in the kernel. Each W / N bit binary value represents the position of the structure in each array, forming an array like this. Figure 11 As shown.

[0194] At this point, the operation of filling the array is performed, and the wake-up source is searched level by level. Here, the wake-up source is searched level by level starting with T, that is, the wake-up source is searched level by level according to the wake-up level that can be added. The rules for determining the wake-up level that can be added and the method of inserting the structure are as described above, and will not be repeated here.

[0195] Please refer to Figure 12 To implement the above-mentioned step-by-step search process, based on the aforementioned embodiment, for a >> t, when a wake-up event occurs, the try_to_wake_up function can optionally be called. In conjunction with the above, try_to_wake_up uses instrumentation to insert stubs, which can be used to identify the waker and the wake-up. Based on the above, the structure built on thread t is traversed and searched.

[0196] Based on the above, the construction method in the structure constructed based on thread t is as follows: Place the custom structure at the corresponding position in the array, and write W unsigned integer member variables in the task struct. Determine the wake-up level of thread t based on W / N. The custom structure has three integer variables, which are used to identify the number of wake-ups within a specified period, the thread number of the wake-up source, and the parent thread number of the wake-up source respectively.

[0197] Here, based on the above, the structure constructed based on thread t includes W unsigned integer member variables. Here, with the help of member variables, it can be determined whether the structure constructed based on thread t exists in the target array. If it exists in the array numbered m, at this time, determine the position p in the m-th array with the help of W unsigned integer member variables, and read the wake-up level d of the target thread corresponding to thread t in the m-th array.

[0198] At this time, calculate the available new wake-up level of the m-th array. If the available new wake-up level of the array numbered m is equal to d + 1, then determine whether the structure constructed based on thread a exists in the position corresponding to the T-level wake-up source in the m-th array. If so, update the structure constructed based on thread a information, specifically adding 1 to the number of wake-ups. If not, place the structure constructed based on thread a information at the end of the m-th array.

[0199] Please refer to Figure 13 , for calculating the available new wake-up level of the array numbered m, first count the number of calls x to the query interface here, and determine the relationship between x and the target wake-up level. If x < N, the available update replacement level y of the m-th array = max(0, x + 1 - m);

[0200] If x ≥ N, use the following formula to determine the available update replacement level of the m-th array: y = (0 - m + N) % N + 1;

[0201] At this time, determine whether y is equal to d + 1, and perform the following operations according to Figure 12 the following method.

[0202] For the pointer, its change rule is: count the number of calls x to the query interface, and read the wake-up tree. Here, if x < N, the pointer points to the 0th array. When x ≥ N, at this time, upload the data of the array pointed to by the current pointer, and only retain the structure constructed based on the target thread information. When the query interface is called for the x-th time, the available new wake-up level of the array pointed to by the current pointer is N.

[0203] Assume that the current pointer points to the array numbered m. After uploading the data, move the pointer to the (m + 1)-th array;

[0204] Assume that the current pointer points to the array numbered N - 1. After uploading the data, move the pointer to the 0th array. This is the movement rule of the pointer.

[0205] Based on the foregoing embodiments, and assuming that within this application, please refer to... Figure 14 Meanwhile, to perform wake-up relationship queries for multiple threads, you only need to specify multiple target threads at the same time, and for each target thread, specify the corresponding wake-up level. For each target thread, construct a target array in the aforementioned manner, and you can search for the wake-up relationship of multiple target threads in parallel.

[0206] Please refer to Figure 15 For each target array, initialization is first performed (not shown in the diagram). Whenever a wake-up time occurs, the wake-up relationship is identified using the instrumented `try to wake up` or `wake up new task` function. Each time the query interface is called, the wake-up relationship is queried, and then... Figure 13 The target array is updated in the manner shown.

[0207] Please refer to Figure 16 , Figure 16 A flowchart of a wake-up relationship determination method provided in this application embodiment includes the following steps:

[0208] S101: Construct a target array. Each target array contains a structure built based on the target thread information. Each array contains multiple structures.

[0209] S102: In response to the Mth query interface call request, in the target array, any array obtains the wake-up source information layer by layer according to the wake-up relationship and the call query interface request, according to the addable wake-up level;

[0210] In response to the Mth query interface request, the steps for retrieving wake-up source information from any array in the target array according to the wake-up relationship and the call query interface request, based on the addable wake-up levels, include:

[0211] If in response to the Xth call to the query interface request, the new wake-up level in any array of the target array is 1, query and obtain the wake-up source information of the 1st wake-up level, and place the structure built based on the wake-up source information of the 1st wake-up level in the position corresponding to the 1st wake-up level in any array of the target array;

[0212] In response to the X+1th query request, if any array in the target array has a newly added wake-up level of 2, query and retrieve the wake-up source information of the first wake-up level, and place the structure built based on the wake-up source information of the second wake-up level into the target array. Repeat this process for any array, in the position corresponding to the second wake-up level, until the newly added wake-up level equals the target wake-up level.

[0213] The Xth query interface request is any one of the previous M query interface requests.

[0214] One possible approach is that, in response to the Mth query interface request, the process of updating the wake-up source information layer by layer according to the wake-up relationship and the call query interface request, based on the addable wake-up levels, includes:

[0215] In response to the Mth query interface request, query the wake-up relationship within a specified time period. The wake-up relationship includes the target waker information and the target wake-up information. The specified time period starts from the time of the Mth query interface request and ends at the time of the (M+1)th query interface request.

[0216] If the target wake-up information meets the first condition, then construct a structure based on the target wake-up information and insert the structure based on the target wake-up information into the target array, at the position corresponding to the y-th wake-up level of any array;

[0217] If the target wake-up information satisfies the second condition, then the structure based on the target wake-up information is updated;

[0218] The first condition includes: the structure based on the target waker information does not exist in the target array, and is located at the position corresponding to the y-th waker level of any array;

[0219] The second condition includes: the structure based on the target waker information exists in the target array, at the position corresponding to the y-th waker level of any array;

[0220] Among them, the structure built based on the target wake-up information exists in the target array. In response to M calls to the query interface request, the new wake-up level that can be added in any array of the target array is Y.

[0221] One possible approach is that the number of target arrays is equal to the number of target wake-up levels. In response to a query interface request, some or all of the target arrays are processed according to the wake-up relationship and the query interface request, with wake-up source information being obtained layer by layer according to the number of wake-up levels that can be added. In response to a query interface request, each array in some or all of the target arrays may have a different number of wake-up levels that can be added.

[0222] One possible approach is that, prior to the step of querying the wake-up relationships within a specified time period in response to the Mth call to the query interface request, the method further includes:

[0223] Identify wake-up relationships based on the objective function;

[0224] The steps for identifying wakefulness relationships based on the objective function include:

[0225] Add stubs to the objective function. The stubs are used to identify wake-up relationships. The objective function is called every time a wake-up occurs.

[0226] One possible approach is that the objective function includes at least one of: try to wake up and wake up new task.

[0227] One possible approach is that the target arrays in at least one of the target arrays are numbered from top to bottom as 0, 1, 2, 3, 4, 5...N-1.

[0228] M <N;

[0229] In response to the Mth query interface request, in the target array, any array is processed according to the steps of retrieving wake-up source information layer by layer based on the wake-up relationship and the query interface request, according to the addable wake-up levels.

[0230] The following method is used to determine the new wake-up levels corresponding to each array in the target array:

[0231] In the target array, the array numbered 0 can add a wake-up level of M+1, the array numbered 1 can add a wake-up level of M, the target array numbered 2 can add a wake-up level of M-1, and so on, with the target array numbered M having a wake-up level of 1.

[0232] One possible approach is that, in response to the Mth query interface request, the possible new wake-up levels for each array in the target array are determined as follows, based on the wake-up relationship and the step of retrieving wake-up source information layer by layer according to the new wake-up levels requested by the query interface:

[0233] In the target array, the array with number 0 has a new wake-up level of k+1, the array with number 1 has a new wake-up level of k, and so on. The array with number k has a new wake-up level of 1, the array with number k+1 has a new wake-up level of N, the array with number k+2 has a new wake-up level of N-1, and so on.

[0234] Where M≥N, and M%N=k and k≠0.

[0235] One possible approach is that, in response to the Mth query interface request, the target array, for any array, determines the new wake-up level corresponding to each array in the target array according to the steps of obtaining wake-up source information layer by layer based on wake-up relationships and query interface requests according to the addable wake-up levels, using the following method:

[0236] In the target array, the array with number 0 has a new wake-up level of 1, the array with number 1 has a new wake-up level of N, the array with number 2 has a new wake-up level of N-1, the array with number 3 has a new wake-up level of N-2, and so on.

[0237] Where M ≥ N, and M%N = 0.

[0238] One possible approach is that, in response to the Mth query interface request, the number of newable wake-up levels in one of the target arrays is equal to the target wake-up level.

[0239] The method also includes uploading the wake-up source information stored in one of the arrays in the target array, and keeping only the structure built based on the target thread information in another array in the target array.

[0240] Please refer to Figure 17 , Figure 17 A structural diagram of a wake-up relationship determination device provided in this application embodiment includes the following steps:

[0241] Builder module: Used to construct target arrays. Each target array contains a structure built based on the target thread information. Each array contains multiple structures.

[0242] Response module: Used to respond to the Mth query interface request. In the target array, any array is used to obtain wake-up source information layer by layer according to the wake-up relationship and the query interface request, based on the addable wake-up level.

[0243] The response module shown is specifically used for:

[0244] If in response to the Xth call to the query interface request, the new wake-up level in any array of the target array is 1, query and obtain the wake-up source information of the 1st wake-up level, and place the structure built based on the wake-up source information of the 1st wake-up level in the position corresponding to the 1st wake-up level in any array of the target array;

[0245] In response to the X+1th query request, if any array in the target array has a newly added wake-up level of 2, query and retrieve the wake-up source information for the second wake-up level, and place the structure built based on the wake-up source information of the second wake-up level into the target array. Repeat this process for any array, in the position corresponding to the second wake-up level, until the newly added wake-up level equals the target wake-up level.

[0246] The Xth query interface request is any one of the previous M query interface requests.

[0247] The foregoing has described specific embodiments of the present invention. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0248] This application provides an electronic device, which can be a terminal device or a circuit device built into a terminal device. This electronic device can be used to perform the functions / steps described in the above method embodiments.

[0249] This application provides a computer-readable storage medium storing instructions that, when executed on a terminal device, cause the terminal device to perform the functions / steps described in the above method embodiments.

[0250] This application can actually contain three relationships. For example, A and / or B can represent the existence of A alone, the simultaneous existence of A and B, or the existence of B alone. A and B can be singular or plural. The character " / " generally indicates that the preceding and following objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of singular or plural items. For example, at least one of a, b, and c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.

[0251] Those skilled in the art will recognize that the units and algorithm steps described in the embodiments disclosed herein can be implemented using electronic hardware, computer software, or a combination of electronic hardware and software. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0252] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0253] In the several embodiments provided in this application, any function, if implemented as a software functional unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0254] The above are merely specific embodiments of this application. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application. The protection scope of this application shall be determined by the protection scope of the claims.

Claims

1. A method for determining wakefulness relationships, characterized in that, Includes the following steps: Construct a target array, wherein each target array includes a structure constructed based on target thread information, and each array includes multiple structures; In response to the Mth call to the query interface request, in the target array, any array obtains the wake-up source information layer by layer according to the wake-up relationship and the call to the query interface request, in accordance with the addable wake-up levels; The step of responding to the Mth call to the query interface request, in the target array, based on the wake-up relationship and the wake-up source information of the call to the query interface request according to the addable wake-up level, includes: If in response to the Xth call to the query interface request, the new wake-up level of any array in the target array is 1, the wake-up source information of the first wake-up level is queried and obtained, and the structure built based on the wake-up source information of the first wake-up level is placed in the target array, in the position corresponding to the first wake-up level of any array; In response to the (X+1)th request to call the query interface, if any array in the target array has a new wake-up level of 2, query and obtain the wake-up source information of the second wake-up level, and place the structure built based on the wake-up source information of the second wake-up level in the target array. In any array, the position corresponding to the second wake-up level is used, and so on, until the new wake-up level is equal to the target wake-up level. The Xth query interface request is any one of the previous M query interface requests.

2. The method according to claim 1, characterized in that, The process of responding to the Mth call to the query interface request, in the target array, according to the wake-up source information layer by layer based on the wake-up relationship and the call to the query interface request according to the addable wake-up levels, includes: In response to the Mth query interface request, query the wake-up relationship within a specified time period. The wake-up relationship includes target waker information and target wake-up information. The specified time period starts from the time of the Mth query interface request and ends at the time of the M+1th query interface request. If the target wake-up information satisfies the first condition, then a structure based on the target wake-up information is constructed, and the structure based on the target wake-up information is inserted into the target array at the position corresponding to the y-th wake-up level of any array. If the target wake-up information meets the second condition, then the structure based on the target wake-up information is updated; The first condition includes: the structure based on the target waker information does not exist in the target array, and is located at the position corresponding to the y-th waker level of any array; The second condition includes: the structure based on the target wake-up information exists in the target array, at the position corresponding to the y-th wake-up level of any array; The structure built based on the target wake-up information exists in the target array. In response to M calls to the query interface, the new wake-up level that can be added to any array in the target array is Y.

3. The method according to claim 2, characterized in that, The number of target arrays is equal to the number of target wake-up levels. In response to a query interface call request, some or all arrays in the target arrays obtain wake-up source information layer by layer according to the wake-up relationship and the query interface call request, and in response to the query interface call request, each array in some or all arrays of the target arrays can have different wake-up levels added.

4. The method according to claim 2, characterized in that, Before the step of querying the wake-up relationships within a specified time period in response to the Mth call to the query interface request, the method further includes: Identify wake-up relationships based on the objective function; The steps for identifying wakefulness relationships based on the objective function include: A stub is added to the objective function to identify wake-up relationships, and the objective function is called each time a wake-up occurs.

5. The method according to claim 4, characterized in that, The objective function includes at least one of: try to wake up and its upstream and downstream functions, and wake up new task and its upstream and downstream functions.

6. The method according to claim 3, characterized in that, The arrays in the target array are numbered from top to bottom as 0, 1, 2, 3, 4, 5...N-1, M. <N; In response to the Mth query interface request, in the step of obtaining wake-up source information layer by layer based on wake-up relationships and the query interface request according to the addable wake-up levels, the addable wake-up level corresponding to each array in the target array is determined in the following manner: In the target array, the array numbered 0 can add a wake-up level of M+1, the array numbered 1 can add a wake-up level of M, the target array numbered 2 can add a wake-up level of M-1, and so on, with the target array numbered M having a wake-up level of 1.

7. The method according to claim 3, characterized in that, The arrays in the target array are numbered from top to bottom as 0, 1, 2, 3, 4, 5...N-1; In response to the Mth query interface request, in the step of obtaining wake-up source information layer by layer based on wake-up relationships and the query interface request according to the addable wake-up levels, the addable wake-up level corresponding to each array in the target array is determined in the following manner: In the target array, the array numbered 0 has a new wake-up level of k+1, the array numbered 1 has a new wake-up level of k, and so on. The array numbered k has a new wake-up level of 1, the array numbered k+1 has a new wake-up level of N, the array numbered k+2 has a new wake-up level of N-1, and so on. Where M≥N, and M%N=k and k≠0.

8. The method according to claim 3, characterized in that, The arrays in the target array are numbered from top to bottom as 0, 1, 2, 3, 4, 5...N-1; In response to the Mth call query interface request, in the step of obtaining wake-up source information layer by layer based on wake-up relationships and the call query interface request according to the addable wake-up levels, the addable wake-up level corresponding to each array in the target array is determined in the following manner: In the target array, the array numbered 0 has a new wake-up level of 1, the array numbered 1 has a new wake-up level of N, the array numbered 2 has a new wake-up level of N-1, the array numbered 3 has a new wake-up level of N-2, and so on. Where M ≥ N, and M%N = 0.

9. The method according to any one of claims 1 to 8, characterized in that, In response to the Mth query interface request, in the target array, the number of new wake-up levels that can be added to an array is equal to the target wake-up level; The method further includes: uploading the wake-up source information stored in one of the arrays in the target array, wherein one of the arrays in the target array only retains a structure built based on the target thread information.

10. A wake-up relationship determination device, characterized in that, include: Construction module: used to construct target arrays, wherein each target array includes a structure constructed based on target thread information, and each array includes multiple structures; Response module: Used to respond to the Mth call to the query interface request. In the target array, any array is used to obtain wake-up source information layer by layer according to the wake-up relationship and the call to the query interface request, according to the addable wake-up level. The response module shown is specifically used for: If in response to the Xth call to the query interface request, the new wake-up level of any array in the target array is 1, the wake-up source information of the first wake-up level is queried and obtained, and the structure built based on the wake-up source information of the first wake-up level is placed in the target array, in the position corresponding to the first wake-up level of any array; In response to the X+1th query interface request, if any array in the target array has a newly added wake-up level of 2, query and obtain the wake-up source information of the second wake-up level, and place the structure built based on the wake-up source information of the second wake-up level into the target array. This process continues in any array, at the position corresponding to the second wake-up level, until the newly added wake-up level equals the target wake-up level. The Xth query interface request is any query interface request among the previous M query interface requests.

11. An electronic device, characterized in that, include: At least one processor; and at least one memory communicatively connected to the processor, wherein: The memory stores program instructions that can be executed by the processor, and the processor can invoke the program instructions to perform the method as described in any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause the computer to perform the method as described in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Multi-core processor thread awakening method based on cache topology

    CN114924801A

  • Load prediction method and load prediction device

    CN115017003A