Wake-up relationship determination method and device, electronic equipment and storage medium
By building a target array and obtaining wake-up source information layer by layer, the problem of large amount of wake-up relationship recognition operations in the existing technology is solved, and efficient thread scheduling is achieved.
Patent Information
- Application Number
- CN202311017083.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-11
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2043-08-11
AI Technical Summary
When identifying wake-up relationships, the prior art has a large amount of operations and cannot effectively ensure the rapid operation of threads, especially in the case of complex wake-up relationships.
By building a target array, the wake-up source information is obtained layer by layer according to the level of wake-up relationship and query interface requests, avoiding the use of breadth-first search algorithm and dichotomy, and reducing the amount of operations.
It realizes efficient identification of wake-up relationships without using breadth-first search algorithm and dichotomy, which reduces the amount of operations and improves the efficiency of thread scheduling.
Smart Images

Figure CN119473405A_ABST
Abstract
Description
[Technical field]
[0001] Embodiments of the present invention relate to the technical field of thread scheduling, and in particular to a method, device, electronic device and storage medium for determining a wakeup relationship. [Background technology]
[0002] In the related art, in certain specific scenarios, it is necessary to ensure the fast operation of a certain thread, such as ensuring the rendering thread related to image drawing. To achieve this effect, the rendering thread can be given priority. However, this solution cannot guarantee the fast operation of the thread in some situations, because there is a wake-up relationship for the thread, that is, the rendering thread can only be executed after the wake-up source thread is executed, and the wake-up source thread is awakened by other threads. Therefore, in order to ensure the priority operation of the thread, it is necessary to query the wake-up relationship.
[0003] In the related art, a binary search method and a breadth-first search algorithm are used to identify the wake-up relationship, but this method requires a large amount of calculation. [Summary of the invention]
[0004] The embodiment of the present invention provides a method for determining a wake-up relationship, which can reduce the amount of calculation of the wake-up identification relationship.
[0005] In a first aspect, the present application provides a method for determining a wake-up relationship, comprising the following steps:
[0006] Construct a target array, wherein each target array includes a structure constructed based on target thread information, and each array includes multiple structures;
[0007] In response to the Mth call query interface request, in the target array, any array obtains the wakeup source information layer by layer according to the newly added wakeup level based on the wakeup relationship and the call query interface request;
[0008] In response to the Mth invocation of the query interface request, in the target array, any array according to the wakeup source information of each layer according to the newly added wakeup level based on the wakeup relationship and the invocation of the query interface request includes:
[0009] If in response to the Xth call to the query interface request, the newly addable wake-up level of any array in the target array is 1, the wake-up source information of the first-level wake-up level is queried and obtained, and the structure constructed based on the wake-up source information of the first-level wake-up level is placed in the position corresponding to the first-level wake-up level in any array in the target array;
[0010] In response to the X+1 acquisition call query interface request, in the target array, the new wake-up level of any array is 2, query and obtain the wake-up source information of the second wake-up level, and place the structure constructed based on the wake-up source information of the second wake-up level in the target array, any array, the position corresponding to the second wake-up level, and so on, until the new wake-up level is equal to the target wake-up level
[0011] The Xth query interface call request is any query interface request among the previous M query interface calls.
[0012] The technical solution provided by the embodiment of the present application can identify the wake-up relationship without using the breadth-first algorithm and the binary search method, thereby reducing the amount of computation required for identifying the wake-up relationship.
[0013] One possible way is that in response to the Mth call query interface request, in the target array, any array according to the wakeup source information of the newly added wakeup level layer by layer based on the wakeup relationship and the call query interface request includes:
[0014] In response to the Mth call to the query interface request, the wake-up relationship within the specified time period is queried, and the wake-up relationship includes the target waker information and the target wakenee information. The specified time period starts from the moment the query interface request is called for the Mth time and ends at the moment the query interface request is called for the M+1th time.
[0015] If the target awakener information satisfies the first condition, a structure based on the target awakener information is constructed, and the structure based on the target awakener information is inserted into the target array, at a position corresponding to the yth level awakening level of any array;
[0016] If the target awakener information satisfies the second condition, the structure based on the target awakener information is updated;
[0017] The first condition includes: the structure based on the target waker information does not exist in the target array, in the position corresponding to the yth level wake-up level of any array;
[0018] The second condition includes: the structure based on the target waker information exists in the target array, in the position corresponding to the yth level wake-up level of any array;
[0019] Among them, the structure constructed based on the target awakened person's information exists in the target array, in the position corresponding to the y-1 level wake-up level of any array, in response to M calls to the query interface request, in the target array, the new wake-up level that can be added to any array is y.
[0020] One possible approach is that the number of target arrays is equal to the number of target wake-up levels, and in response to calling a query interface request, in the target array, some or all arrays obtain the wake-up source information layer by layer according to the newly added wake-up level based on the wake-up relationship and the calling query interface request, and in response to calling the query interface request, in the target array, each array in some or all arrays has a different newly added wake-up level.
[0021] One possible manner is that, in response to the Mth invocation of the query interface request, before the step of querying the wake-up relationship within the specified time period, the method further includes:
[0022] Identify the arousal relationship based on the objective function;
[0023] The steps of identifying the arousal relationship according to the objective function include:
[0024] Add stubs to the target function. The stubs are used to identify the wakeup relationship. The target function is called every time the wakeup occurs.
[0025] One possible approach is that the target 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 way is to number the arrays in the target array from top to bottom as 0, 1, 2, 3, 4, 5, ... N-1, M <N;
[0027] In response to the Mth call query interface request, in the step of obtaining the wakeup source information layer by layer according to the newly added wakeup level based on the wakeup relationship and the call query interface request in any array in the target array,
[0028] The following method is used to determine the newly added wake-up level corresponding to each array in the target array:
[0029] In the target array, the newly added wake-up level of the array numbered 0 is M+1, the newly added wake-up level of the array numbered 1 is M, the newly added wake-up level of the target array numbered 2 is M-1, and so on. The newly added wake-up level of the target array numbered M is 1.
[0030] One possible way is that the arrays in the target array are numbered 0, 1, 2, 3, 4, 5, ... N-1 from top to bottom;
[0031] In response to the Mth call to the query interface request, in the step of obtaining the wakeup source information layer by layer according to the newly added wakeup level based on the wakeup relationship and the call to the query interface request, any array in the target array determines the newly added wakeup level corresponding to each array in the target array in the following manner:
[0032] In the target array, the newly added wake-up level of the array numbered 0 is k+1, the newly added wake-up level of the array numbered 1 is k, and so on. The newly added wake-up level of the array numbered k is 1, the newly added wake-up level of the array numbered k+1 is N, the newly added wake-up level of the array numbered k+2 is N-1, and so on.
[0033] Among them, M≥N, and M%N=k and k≠0.
[0034] One possible way is that the arrays in the target array are numbered 0, 1, 2, 3, 4, 5, ... N-1 from top to bottom;
[0035] In response to the Mth call query interface request, in the step of obtaining the wakeup source information layer by layer according to the newly added wakeup level based on the wakeup relationship and the call query interface request, any array in the target array determines the newly added wakeup level corresponding to each array in the target array in the following manner:
[0036] In the target array, the newly added wake-up level of the array numbered 0 is 1, the newly added wake-up level of the array numbered 1 is N, the newly added wake-up level of the array numbered 2 is N-1, the newly added wake-up level of the array numbered 3 is N-2, and so on;
[0037] Among them, M≥N, and M%N=0.
[0038] One possible way is that in response to the Mth call to the query interface request, in the target array, the newly added wake-up level of an array is equal to the target wake-up level
[0039] The method further includes: in response to the Mth call query interface request, uploading the wakeup source information stored in an array in the target array, and retaining only a structure constructed based on the target thread information in an array in the target array.
[0040] In a second aspect, an embodiment of the present application provides a wake-up relationship determination device, including:
[0041] Construction module: used to construct a target array. In the target array, each target array includes a structure constructed based on the target thread information, and each array includes multiple structures;
[0042] Response module: used to respond to the Mth call query interface request, in the target array, any array obtains the wakeup source information layer by layer according to the newly added wakeup level based on the wakeup relationship and the call query interface request;
[0043] The response module shown is specifically used for:
[0044] If in response to the Xth call to the query interface request, the newly addable wake-up level of any array in the target array is 1, the wake-up source information of the first-level wake-up level is queried and obtained, and the structure constructed based on the wake-up source information of the first-level wake-up level is placed in the position corresponding to the first-level wake-up level in any array in the target array;
[0045] In response to the X+1 acquisition call query interface request, in the target array, the new wake-up level of any array is 2, query and obtain the wake-up source information of the second wake-up level, and place the structure constructed based on the wake-up source information of the second wake-up level in the target array, any array, the position corresponding to the second wake-up level, and so on, until the new wake-up level is equal to the target wake-up level
[0046] The Xth query interface call request is any query interface request among the previous M query interface calls.
[0047] In a third aspect, the present application provides an electronic device, including:
[0048] at least one processor; and at least one memory in communication with the processor, wherein:
[0049] The memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the method according to any one of claims 1 to 9.
[0050] In a fourth aspect, the present application provides a computer-readable storage medium, which stores computer instructions, and the computer instructions enable a computer to execute the method of 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 methods are similar and will not be described in detail.
Brief Description of the Drawings
[0052] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0053] Figure 1(a) to Figure 1(e) Find schematic diagrams for wake-up relationships in related technologies;
[0054] Figure 2 A software structure block diagram of an electronic device provided in an embodiment of the present invention.
[0055] Figure 3(a) to Figure 3(d)A schematic diagram of layer-by-layer search for wake-up sources is provided for an embodiment of the present application;
[0056] Figure 4 A schematic diagram of a structure provided in an embodiment of the present application;
[0057] Figure 5(a) to Figure 5(b) A schematic diagram of updating a wake-up source process is provided for an exemplary embodiment of a certain array of data;
[0058] Figure 6 An array schematic diagram provided for an exemplary embodiment of the present application;
[0059] Figure 7 A schematic diagram of a newly added wake-up level for an exemplary embodiment provided in an embodiment of the present application;
[0060] FIG8( a ) is a schematic diagram of a newly added wake-up level according to another exemplary embodiment provided by the present application;
[0061] FIG8( b ) is a schematic diagram of a newly added wake-up level according to another exemplary embodiment provided by the present application;
[0062] Figure 9(a) to Figure 9(d) A schematic diagram of wake-up relationship identification of an exemplary embodiment provided in an embodiment of the present application;
[0063] Fig.10 A flowchart for constructing a wake-up relationship search engine provided in an embodiment of the present application;
[0064] Fig.11 A schematic diagram of a target array provided in an embodiment of the present application;
[0065] Fig.12 A flowchart for updating the wake-up source process provided in an embodiment of the present application;
[0066] Fig.13 A flowchart of the calculation of the wake-up level that can be added in the embodiment of the present application;
[0067] Fig.14 A schematic diagram of multi-threaded parallel search provided in an embodiment of the present application;
[0068] Fig.15 A schematic diagram of another multi-threaded parallel search provided in an embodiment of the present application;
[0069] Fig.16 A flowchart of a method for determining a wake-up relationship provided in an embodiment of the present application;
[0070] Fig.17 A structural diagram of a wake-up relationship determination device provided in an embodiment of the present application. [Specific implementation method]
[0071] In order to better understand the technical solution of the embodiment of the present invention, the embodiment of the present invention is described in detail below with reference to the accompanying drawings.
[0072] In some feature scenarios, such as image drawing, it is necessary to ensure that the rendering thread is prioritized. However, simply ensuring that the rendering thread runs first does not guarantee that the rendering thread is prioritized. This is because the rendering thread is often the awakened thread. For example, the rendering thread may be awakened by thread A, and thread A is awakened by thread B. In the awakening relationship between A and the rendering thread, the rendering thread is the awakened thread and thread A is the awakener.
[0073] As those skilled in the art understand, in the example where B wakes up A and A wakes up the rendering thread, the awakened thread can only execute after the wakeup source thread has finished executing. For example, referring to Figure 1(a), B wakes up A, and the A thread can only execute after the B thread has finished executing. Based on this, especially when the wakeup relationship is more complex, in order to ensure the priority of the target thread scheduling, it is necessary to identify the wakeup relationship and synchronize the identification result to the bottom layer to shorten the wakeup time and ensure the priority of the target thread. Similarly, in order to ensure the priority of scheduling multiple independent threads, it is necessary to identify the wakeup relationship of multiple independent wakeup trees.
[0074] Please refer to Figure 1(b). Assuming that the wake-up relationship of the wake-up tree in Figure 1(b) is identified, it is necessary to first determine the thread number of each thread. The filling rule of the thread number is related to the time when the thread is created. That is to say, the earlier the creation time of a thread, the smaller its thread number.
[0075] From here, we proceed to the next process, as shown in Figure 1(b), where all wake-up trees are placed into the target array in ascending order of thread number, and a binary search is used to determine the structure of the newly inserted thread in the target array. Assuming that the newly added thread is 279, the threads after number 279 need to be shifted to ensure the order of the array.
[0076] Assuming that it is necessary to maintain a certain wake-up relationship, in the related technology, a pile point can be added by inserting piles to identify the wake-up relationship. The specific method is to add a weaker array in the structure type as shown in 1(d), so that the array is used to record the wake-up source. Assuming that A wakes up B, it will first query in the array shown in Figure 1(c). If the A thread does not exist in the weaker array in B, the A thread will be added to the array shown in Figure (c).
[0077] Here, assuming that it is necessary to query the multi-level wake-up sources of a certain thread, it is necessary to use the breadth-first search (BFS) algorithm. The specific approach is to recursively use the weaker array to search for the wake-up source of each thread in the array shown in Figure 1(c) 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 functions of the kernel are called to identify the wake-up relationship and add new stubs, identify the corresponding waker and the awakened and their respective thread numbers. If A wakes up B, it will first search in the target array to find B and determine whether A exists in the target array. If not, it will be added. The specific method of adding can adopt the binary search method, which will not be described in detail here.
[0079] In this way, we can see that the problems in the overall awakening relationship recognition are as follows:
[0080] 1) Cross-process search cannot be achieved: Since the target array in the relevant technology is based on all threads of the specified process, that is, assuming that in process A, the relationship of the rendering thread is searched, and there is also a wakeup source C in process B to wake up the rendering thread, then the wakeup source C cannot be found.
[0081] 2) It cannot support searching for multiple threads at the same time: for example, if you specify to search for the wake-up relationship of the rendering thread, you cannot search for the wake-up relationship of other threads at the same time.
[0082] 3) Spatial complexity: Combined with the above, all wake-up sources are placed in a target array, resulting in spatial redundancy of the target array.
[0083] 4) Complex calculations: Each time a new thread is created, a binary search algorithm is used to determine the inserted structure in the target array and to move the corresponding structure of some threads in the target array. Each time a query is performed, a breadth-first search algorithm is used.
[0084] 5) Invalid threads exist: Invalid threads are not filtered when creating the target array, so irrelevant threads are introduced.
[0085] It can be seen from this that in the related art, the efficiency of thread relationship wakeup identification needs to be improved. Based on this, the present application provides a wakeup relationship determination method to improve the timeliness of wakeup relationship identification.
[0086] Figure 2 1 is a software structure block diagram of the electronic device 100 according to an embodiment of the present invention.
[0087] The layered architecture divides the software into several layers, each with clear roles and division of labor. The 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 library, and the kernel layer.
[0088] The application layer can include a series of application packages.
[0089] like Figure 2 As shown, the application package can include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications
[0090] like Figure 2 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.
[0091] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
[0092] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0093] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0094] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0095] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
[0096] The following assumes a scenario where it is necessary to query the level 3 wakeup source of the rendering thread. First, a target array is established. Taking the target array as a K*3 array as an example, the target array includes three arrays. For one of the three arrays, in order to obtain the level 3 wakeup source information of the rendering thread, it is necessary to query upward layer by layer until the wakeup source information of the target wakeup level is obtained. Assuming that the kernel layer calls the query interface request for M times, please refer to Figure 3(a). When the query interface request is called for the Xth time, there is an array in the target array (for the convenience of description, the array described below corresponds to a certain array mentioned here) to query the wakeup source information of the first-level wakeup level, and construct a structure based on the wakeup source information of the first-level wakeup level, and place the structure constructed based on the wakeup source information of the first-level wakeup level in the position corresponding to the first-level wakeup level of the array.
[0097] Here, the wakeup source information of the 1st wakeup level constructs a structure, which is located at the end of the array.
[0098] Then, referring to Figure 3(b), when the call query interface request is obtained for the X+1th time, the kernel queries the wake-up source information of the second-level wake-up layer, and constructs a structure based on the wake-up source information of the second-level wake-up layer, and places the structure constructed based on the wake-up source information of the second-level wake-up layer in the position corresponding to the second-level wake-up layer in the target array. At this time, the wake-up source information of the second-level wake-up layer can be directly constructed The structure is placed at the end of the array. Based on this, it is possible to obtain the wake-up source information of the target wake-up layer by layer query, as shown in Figure 3(c), and finally the array shown in Figure 3(d) can be obtained.
[0099] When the call query interface obtained for the X+2th time requests the array to query the wakeup source information of the third-level wakeup layer, the kernel queries the wakeup source information of the third-level wakeup layer, and constructs a structure based on the wakeup source information of the third-level wakeup layer, and places the structure constructed based on the wakeup source information of the third-level wakeup layer in the position corresponding to the third-level wakeup layer in the target array, thereby obtaining the 3rd wakeup source information of the rendering thread.
[0100] At this time, the wakeup source information of the three wakeup levels can be directly constructed into a structure and placed at the end of the array.
[0101] Here, compared with the related art, the present application does not need to use binary search to sort threads according to thread numbers when constructing an array.
[0102] It should be noted that the wake-up level expresses the number of wake-ups required 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 from a certain thread to the target thread.
[0103] Exemplarily, for the rendering thread, assuming that 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. Thread B wakes up thread A, and thread B is the parent thread of thread A. Here, thread B for the rendering thread has a wake-up level of 2.
[0104] In summary, in the embodiments provided in the present 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, in the target array, any array obtains the wake-up source information layer by layer according to the newly added wake-up level based on the wake-up relationship and the call to the query interface request.
[0105] It should be noted that the target thread here refers to the thread for searching the wake-up level. In the above example, the search is performed on the rendering thread. At this time, the target thread corresponds to the rendering thread mentioned in the above embodiment.
[0106] Therefore, N levels of wakeup sources for the target thread can be obtained without using the binary search method and the breadth-first search algorithm.
[0107] In summary, in response to the Mth call query interface request, in the target array, any array according to the wakeup source information of the newly added wakeup level layer by layer based on the wakeup relationship and the call query interface request includes:
[0108] If in response to the Xth call to the query interface request, the newly addable wake-up level of any array in the target array is 1, the wake-up source information of the first-level wake-up level is queried and obtained, and the structure constructed based on the wake-up source information of the first-level wake-up level is placed in the position corresponding to the first-level wake-up level in any array in the target array;
[0109] In response to the X+1 acquisition call query interface request, in the target array, the new wake-up level of any array is 2, query and obtain the wake-up source information of the second wake-up level, and place the structure constructed based on the wake-up source information of the second wake-up level in the target array, any array, the position corresponding to the second wake-up level, and so on, until the new wake-up level is equal to the target wake-up level
[0110] The Xth query interface call request is any query interface request among the previous M query interface calls.
[0111] The following describes how to place the wake-up source information and how to construct the structure in this application:
[0112] Please refer to Figure 4, assuming that in response to the Mth call query interface request, the wakeup relationship within the specified time period is queried, the wakeup relationship includes the target waker information and the target wakenee information, the target waker information and the target wakenee information include but are not limited to: the wakeup level of the wakeup source relative to the target thread, the number of wakeups of the wakeup source between the time of obtaining the Mth call query interface request and the time of obtaining the M-1th call query interface request (that is, the number of wakeups within the specified time period described below), the thread number of the wakeup source, the parent thread number of the wakeup source (that is, the thread number of the wakeup source's wakeupper), and a structure is constructed based on this.
[0113] What can be achieved by those skilled in the art is to write the wake-up level of the wake-up source relative to the target thread, the number of wake-up times of the wake-up source between the time of obtaining the Mth call query interface request and the time of obtaining the M-1th call query interface request, the thread number of the wake-up source, and the parent thread number of the wake-up source (that is, the thread number of the wake-up source's wake-up) into the structure in sequence, that is, to construct a structure based on the wake-up source type.
[0114] It should be noted that three integer variables are defined in the structure, which are used to identify the number of wake-up times in the specified period, the thread number of the wake-up source, and the parent thread number of the wake-up source. At the same time, in order to read the target wake-up level, it is optional to define W bit unsigned integer variables in the kernel task struct. The W / N bits represent the position of the structure in a certain array, so that the wake-up level can be read.
[0115] At the same time, for the array, each structure is equivalent to a member. In response to the change in the number of input requests accompanied by calling the query interface, for any array in the target array, the newly added wake-up level increases layer by layer until the newly added wake-up level is equal to the target wake-up level. When the newly added wake-up level is equal to the target wake-up level, the wake-up source information of the target wake-up level can be obtained. When the system layer executes the operation of querying the wake-up source of the newly added wake-up level, the structure can be placed in the array.
[0116] Exemplarily, assuming that for array A, the level of newly added wake-up sources is 2, then the structure constructed by querying the level 2 wake-up source information within the specified time period is placed in the position of the level 2 wake-up source in array A. At the same time, for the thread corresponding to the level 2 wake-up source information in array A, there is 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, and the specified time period is: the time period between the last two times the query interface request is called.
[0117] Exemplarily, assuming that the current query interface request is the M+1th call, the specified time period is the time period between the M+1th obtain call query interface request and the Mth obtain call query interface request.
[0118] Based on this, in response to the M+1th call to the query interface request, the level 2 wake-up source information in the A array is obtained. Here, it is necessary to obtain the parent thread of the thread corresponding to the level 1 wake-up source information in the A array between the time when the M+1th call to the query interface request is obtained and the time when the Mth call to the query interface request is obtained, and a structure is 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 the A array.
[0119] It should be noted that the structure constructed by the parent thread described in this application is placed in the position of the 2nd level wake-up source in the A array, specifically, the aforementioned custom structure containing three variables is inserted into the array, and the Wbit large unsigned integer variable is written into the task struct structure.
[0120] Then, in a certain scenario, assuming that the query interface request is called for the Mth time, the new addable level of the B array is y, and L11 is located in the position corresponding to the y-1 wake-up level of the B array, and multiple wake-up events of the A thread waking up L11 occur within the specified time period. When A wakes up L11 for the first time, combined with the above, the structure built based on the A thread exists in the B array, which means that the wake-up relationship between the A thread and the L11 thread has been expressed in the B array, that is, the wake-up relationship between the A thread and the L11 thread still appears at this time, and the number of wake-up times of the L11 thread needs to be updated here.
[0121] Please refer to Figure 5(a). For example, assuming that within a specified time period, the L21 thread wakes up the 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 of the B array. When L21 wakes up L11 for the second time, the structure built based on the L21 thread information is updated.
[0122] Comparing FIG. 5( a ) and FIG. 5( b ), the number of wake-up times in the structure constructed based on the L21 thread information is accumulated. For this purpose, the number of wake-up times in the structure constructed based on the L21 thread information is changed from 1 to 2.
[0123] It can be seen that in response to the Mth call query interface request, in the target array, any array according to the wakeup source information of the newly added wakeup level layer by layer based on the wakeup relationship and the call query interface request includes:
[0124] In response to the Mth call to the query interface request, the wake-up relationship within the specified time period is queried, and the wake-up relationship includes the target waker information and the target wakenee information. The specified time period starts from the moment the query interface request is called for the Mth time and ends at the moment the query interface request is called for the M+1th time.
[0125] If the target awakener information satisfies the first condition, a structure based on the target awakener information is constructed, and the structure based on the target awakener information is inserted into the target array, at a position corresponding to the yth level awakening level of any array;
[0126] If the target awakener information satisfies the second condition, the structure based on the target awakener information is updated;
[0127] The first condition includes: the structure based on the target waker information does not exist in the target array, in the position corresponding to the yth level wake-up level of any array;
[0128] The second condition includes: the structure based on the target waker information exists in the target array, in the position corresponding to the yth level wake-up level of any array;
[0129] Among them, the structure constructed based on the target awakened person's information exists in the target array, in the position corresponding to the y-1 level wake-up level of any array, in response to M calls to the query interface request, in the target array, the new wake-up level that can be added to any array is y.
[0130] In combination with the foregoing, when the L21 thread wakes up the L11 thread, the L21 thread corresponds to the target waker, and L11 corresponds to the target wakenee.
[0131] Continuing with the above example, let's continue with the example of querying the three-level wake-up source of the rendering thread. First, a structure is constructed based on the rendering thread and placed in each array in the target array. Assuming that in response to the Mth call query interface request, it is assumed that the wake-up level of the A array in the target array is 1. At this time, the wake-up source information of the 1st wake-up level is placed in the structure corresponding to the 1st wake-up level of the A array. In response to the M+1th call query interface request obtained, the wake-up level of the A array is 2. At this time, the structure constructed based on the wake-up source information of the 2nd wake-up level is placed in the position body corresponding to the 2nd wake-up level of the A array. In response to the M+2th call query interface request obtained, the wake-up level of the A array is 3. At this time, the structure constructed based on the wake-up source information of the 3rd wake-up level within the specified time period is placed in the position corresponding to the 3rd wake-up level of the A array. In response to the M+4th call query interface request obtained, the query result is returned and all data except the target thread is uploaded. At this time, the A array only retains the rendering thread information, forming the following Figure 6 The array shown.
[0132] It should be noted that before calling the query section interface each time, the wake-up relationship obtained each time needs to be identified. In order to identify the wake-up relationship, the specific implementation method is: using the try_to_wake_up and its upstream and downstream functions or wake up new task and its upstream and downstream functions in the kernel to identify the waker and the awakened, and the specific method is to add stubs in try_to_wake_up and its upstream and downstream functions or wake up new task and its upstream and downstream functions to identify the waker and the awakened.
[0133] That is, in response to the Mth invocation of the query interface request, before the step of querying the wake-up relationship within the specified time period, the method further includes:
[0134] Identify the arousal relationship based on the objective function;
[0135] The steps of identifying the arousal relationship according to the objective function include:
[0136] Add stubs to the target function. The stubs are used to identify the wakeup relationship. The target function is called every time the wakeup occurs.
[0137] It should be noted that the target 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 can be known that, for array A, the system layer cannot output the wake-up source of the target wake-up level for each acquired call query interface request. In view of this, in the embodiments provided in the present application, the number of arrays in the target array is equal to the number of target wake-up levels. Continuing with the aforementioned, in this case, the number of target wake-up levels is 3, then the target array contains three arrays, and each time in response to a call query interface request, all or part of the aforementioned three arrays execute the aforementioned step of obtaining the wake-up source information layer by layer according to the newly added wake-up level. At the same time, for the array that executes the aforementioned step of obtaining the wake-up source information layer by layer according to the newly added wake-up level, in response to the call query interface request, each array can have a different newly added wake-up level.
[0139] Exemplarily, assuming that there are two arrays in the target array that have executed the step of obtaining the wake-up source information layer by layer according to the newly addable wake-up level, then the updateable levels of these two arrays in response to the query interface request are different. It can be understood that all arrays in the target array execute the step of obtaining the wake-up source information layer by layer according to the newly addable wake-up level. Then, in the target array, in response to the query interface request, there will always be an array whose newly addable wake-up level is the target wake-up level. This ensures that each time the query result of the wake-up source of the target wake-up level is output in response to the query interface request, that is, the query result of the wake-up source of the target wake-up level can be output in real time, thereby realizing maintenance and update of the query results.
[0140] It can be seen that in the present application, the method of determining the newly added wake-up level described later is only a possible implementation method and is not a limitation of the present application.
[0141] The following will describe the method of determining the newly added wake-up level of each array in the first array according to different situations:
[0142] Continuing with the example of finding the 3 wake-up source information of the rendering thread, three arrays are constructed here, that is, the target array includes three arrays. Here, each array in the first array is numbered, exemplarily, numbered 0, 1, 2. Array No. 0 is initialized first. For array No. 0, a new wake-up level 1 can be added. For arrays No. 1 and No. 2, no operation is performed at this time. It is assumed that L11 wakes up the rendering thread, and the L11 thread is the first-level wake-up source of array No. 0. Here, the thread information of L11 is constructed into a structure, and the structure built based on L11 is placed in the structure corresponding to the first-level wake-up level in array No. 0, which is initialized.
[0143] In response to the first obtained call query interface request, for array No. 0, a new wake-up level of 2 can be added, and for array No. 2, a new wake-up level of 1 can be added. If during the first and second time periods of obtaining the call query interface request, it is assumed that there is a wake-up relationship that the L21 thread wakes up L11, and L12 wakes up the rendering thread. In this regard, based on the foregoing, L12 is a level 1 wake-up source. Here, the structure constructed based on L12 is placed in the position corresponding to the first level wake-up level of array No. 1, and the structure constructed based on L21 is placed in the position corresponding to the second level wake-up level of array No. 0.
[0144] In response to the second call query interface request obtained, for array No. 0, a new wake-up level of 3 can be added, for array No. 2, a new wake-up level of 2 can be added, and for array No. 3, a new wake-up level of 1 can be added. Assuming that there is a wake-up relationship, L31 thread wakes up L22, the wake-up relationship, L22 thread wakes up L12, and L12 wakes up the rendering thread. Based on the foregoing, for array No. 0, L31 thread wakes up L22. At this time, the structure constructed based on the L31 thread information is placed in the position corresponding to the third-level wake-up level of array No. 1, and the structure constructed based on the L22 thread information is placed in the position corresponding to the second-level wake-up level of array No. 2. For L12 to wake up the rendering thread, the structure constructed based on the L12 thread information is placed in the position corresponding to the first-level wake-up level of array No. 3.
[0145] Based on the above, using recursive method, we can get the new wake-up level corresponding to each array in the target array:
[0146] Reference Figure 7 In the target array, the newly added wake-up level of the array numbered 0 is M+1, the newly added wake-up level of the array numbered 1 is M, the newly added wake-up level of the target array numbered 2 is M-1, and so on. The newly added wake-up level of the target array numbered M is 1.
[0147] At the same time, it can be known that in response to the Mth call to the query interface request, in the current situation, only M arrays execute the steps of obtaining the wake-up source information layer by layer according to the newly added wake-up level based on the wake-up relationship and the call to the query interface request. At the same time, for the array numbered a in the target array, the newly added wake-up level is M+1-a.
[0148] It is worth noting that the target array is also equipped with a pointer, where the pointer points to array No. 0 (not shown in the figure).
[0149] In combination with the above, when the third acquisition responds to the call query interface request, the second query ends by default, and array No. 0 obtains the wake-up source information of the target wake-up level. At this time, array No. 0 uploads all data except the target thread to the upper layer, and clears all data except the target thread. At this time, the pointer is dropped to point to array No. 1.
[0150] At this time, the newly added wake-up level for array No. 0 is level 1, the newly added wake-up level for array No. 1 is level 3, and the newly added wake-up level for array No. 2 is level 2.
[0151] In response to the fourth acquisition of the call query interface request, array 1 obtains the wakeup source information of the target wakeup level. At this time, array 1 uploads all data except the target thread to the upper layer and clears all data except the target thread. At this time, the pointer is dropped to point to array 2.
[0152] At this time, the newly added wake-up level for array No. 0 is level 2, for array No. 1, the newly added wake-up level is level 1, and for array No. 2, the newly added wake-up level is level 3.
[0153] In response to the fifth acquired call query interface request, array No. 2 obtains the wake-up source information of the target wake-up level. At this time, array No. 2 uploads all data except the target thread to the upper layer and clears all data except the target thread. At this time, the pointer points to array No. 0.
[0154] At this time, the new wake-up level that can be added to array 0 is level 3, the new wake-up level that can be added to array 1 is level 2, and the new wake-up level that can be added to array 2 is level 1. At this time, array 1 uploads all data except the structure built based on the target thread information to the upper layer, and clears all data except the target thread, and moves the pointer down to array 2, thus forming a loop.
[0155] Assume here that the target wake-up level is N. When the N+1th time the query interface request is obtained, compared with the first time the query interface request is obtained, for a certain array, a new wake-up level can be added to cycle according to the number of query interface request calls, and the cycle period is N.
[0156] Therefore, when M>N, by utilizing the cyclic relationship and the modulo result of M over N, the newly added wake-up level of each array in the target array can be determined.
[0157] Referring to Figure 8(a), if M>N, and M%N=k and k≠0.
[0158] In the target array, the newly added wake-up level of the array numbered 0 is k+1, the newly added wake-up level of the array numbered 1 is k, and so on. The newly added wake-up level of the array numbered k is 1, the newly added wake-up level of the array numbered k+1 is N, the newly added wake-up level of the array numbered k+2 is N-1, and so on.
[0159] Referring to FIG8(b), when M>N and M%N=0, referring to the third time when the query interface is requested, the newly added wake-up level of each array can be known that in the target array, the newly added wake-up level corresponding to each array is:
[0160] The newly added wake-up level of the array numbered 0 is 1, the newly added wake-up level of the array numbered 1 is N, the newly added wake-up level of the array numbered 2 is N-1, the newly added wake-up level of the array numbered 3 is N-2, and so on.
[0161] At the same time, for the pointer, when M≥N, each time the pointer moves, combined with the above, when M=3, the pointer points from array 0 to array 1, when M=4, it points from array 1 to array 2, and so on. However, when the pointer points to array N-1, it responds to the query interface request again and points to array 1 again.
[0162] That is, in response to the Mth call to the query interface, the method further includes:
[0163] If k≠N-1, the pointer moves from number k to the target array, the array numbered k+1. If k=N-1, the pointer moves to the target array numbered 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 search for the wake-up source information of each thread at the same time, 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. Two target arrays are constructed here, the first target array includes three arrays, and each array in the first target array contains the A thread information, the second target array includes four arrays, and each array in the second target array contains the B thread information, and the two arrays simultaneously identify the wake-up relationship in parallel in the manner of the aforementioned embodiment. To avoid repetition, it will not be repeated here.
[0165] For ease of understanding, based on the above embodiments, the wake-up relationship determination method proposed in this application will be described below in conjunction with an exemplary embodiment:
[0166] Here, it is assumed that the three-level wakeup source information of the T thread needs to be found. First, a target array is constructed. Combined with the above, the target array includes three arrays numbered 0, 1, and 2. Initialization is performed at this time. Whenever a wakeup relationship occurs, the target function will be called. Stubs are added to the target function. The waker and the wakenee of the wakeup relationship can be identified through the stubs. During initialization, it is found that L11 wakes up the T thread and L12 wakes up the T thread. Combined with the above, it can be seen that the L11 thread information and the L12 thread information correspond to the first-level wakeup source information. At this time, the L11 thread information and the L12 thread information are constructed into a structure. This structure includes: thread number, wakeup times, thread number of the parent thread, etc., and in the task struct structure, W bit unsigned integer variables are defined. To avoid repetition, they are not repeated here. The structure constructed based on the L11 thread information and the L12 thread information are placed in the position corresponding to the first-level wakeup level of the array No. 0. The array formed at this time is shown in Figure 9(a).
[0167] At this time, if a query instruction is issued, a query interface call request is generated in response to the query instruction. If three wake-up events of L11>>T, L21>>L11, and L21>>L11 occur, where>> represents wake-up, a search is performed in the target array for the awakened person, that is, a traversal search is performed for T and L11 in the target array. After finding, for L21>>L11, a search for the L11 thread is performed. At this time, the structure constructed based on the thread information of L11 already exists in array No. 0, and the wake-up level of L11 is 1, and then it is determined whether the newly added wake-up level of array No. 0 is 2. Here, the newly added wake-up level of array No. 0 is 2, and there is no structure constructed based on the L21 thread in array No. 0. At this time, the first condition is met, and then the structure constructed based on the L21 thread information is placed in the position corresponding to the second-level wake-up level of array No. 0. The position corresponding to the second-level wake-up level can be located at the end of array No. 0 at this time.
[0168] In view of the fact that there is also a wake-up event of L21>>L11, at this time, a traversal search is also performed on L11. The search process is not repeated here. At this time, array No. 0 has a structure built based on the wake-up source information corresponding to the L21 thread. The wake-up count of the structure built based on the L11 thread in array No. 0 is updated.
[0169] For L11>>T, based on T as the target thread and L11 as the level 1 wakeup source, the L11 thread information is placed in the structure corresponding to the first level wakeup level of array No. 1. The array formed at this time is shown in Figure 9(b).
[0170] If the query instruction is issued for the second time, in response to the query instruction issued for the second time, it is assumed that the first query is ended and a query interface call request is generated. In response to the query interface call request, combined with the above, the newly added wake-up level of array No. 0 is 3, the newly added wake-up level of array No. 1 is 2, and the newly added wake-up level of array No. 0 is 1. If there is a wake-up event L31>>L12 during the time period of the first query interface call and the second query interface call, L31>>L11, L31>>L21, L12>>T, L11>>L21.
[0171] For L31>>L12, consistent with the above embodiment, L12 is traversed and searched, and it is found that the structure constructed based on L12 exists in array No. 0, and the wake-up level of the L12 thread corresponding to the T thread in array No. 0 is 1. At this time, based on the above, for array No. 0, a new wake-up level of 3 can be added. At this time, the structure constructed based on the L31 thread information cannot be placed in array No. 0.
[0172] For L31>>L11, a traversal search is performed on the L11 thread information. It can be seen that there are structures built based on the L11 thread information in array No. 0 and array No. 1, and for array No. 0 and array No. 1, the L11 thread corresponds to the T thread, and the wake-up level is 1. However, in array No. 0, a new wake-up level of 3 can be added, so the L31 thread information cannot be written into array No. 0. But for array No. 1, a new wake-up level of 2 can be added, and in array No. 1, there is no structure built based on the L31 thread information. Here, the structure built based on the L31 thread information is placed in array No. 1, at the position corresponding to the second wake-up level.
[0173] For L31>>L21, a traversal search is performed on L21. It can be known that there is a structure built based on the L21 thread information in array No. 0, and relative to the T thread, in array No. 0, the wake-up level of L21 is 2, and the new wake-up level of array No. 0 is 3. At this time, the structure built based on the L31 thread information can be placed in array No. 1, in the position corresponding to the third wake-up level.
[0174] For L12>>T, the L12 thread corresponds to the T thread as the level 1 wake-up source. Here, the newly added wake-up level of array No. 2 is 1, and the structure constructed based on the L12 thread information is placed in array No. 2, in the position corresponding to the first wake-up level wake-up source.
[0175] For this, the traversal search is also performed for the L21 thread. At this time, it is found that the structure constructed based on the L21 thread exists in array No. 0. Here, the structure constructed based on the L11 thread information is placed in the position corresponding to the 3rd level wake-up source of array No. 0. At this time, array No. 0 stores the structure constructed based on the L11 thread information, the structure constructed based on the L12 thread information, the structure constructed based on the L21 thread information, the structure constructed based on the L31 thread information, and the structure constructed based on the L11 thread information. It can be seen that the embodiments of the present application can be used to identify the circular wake-up relationship by using an array. Here, the query result of the array for the circular wake-up relationship is used to make the identification result more intuitive.
[0176] Meanwhile, no operation is performed for L31>>L12, thereby filtering invalid wake-up relationships without the aid of a whitelist. The array formed at this time is shown in FIG9(c).
[0177] At the same time, compared with the L31 thread, the wake-up level relative to the T thread in array No. 0 is 3, and in array No. 1, the wake-up level relative to the T thread is 2. By comparison, it can be seen that for the same thread, the wake-up level may be different in different arrays.
[0178] It should be noted that, please refer to Figure 9(d). At this time, before the query instruction is issued for the third time, the pointer of the target array always points to array No. 0. For array No. 0, when the query instruction is issued for the third time, array No. 0 obtains the level 3 wake-up source information, and for array No. 0, the data in the array is uploaded. After uploading, array No. 0 only includes T thread information, that is, a structure built based on the target thread information, and the pointer is transferred to array No. 2.
[0179] At the same time, the newly added wake-up level for array No. 0 is 1, the newly added wake-up level for array No. 1 is 3, and the newly added wake-up level for array No. 2 is 2.
[0180] When the query instruction is sent for the fourth time, it is assumed that the third query is finished. At this time, the data of array No. 1 continues to be uploaded, and the pointer continues to be transferred to array No. 2.
[0181] At this time, the newly added wake-up level for array No. 0 is 2, the newly added wake-up level for array No. 1 is 1, and the newly added wake-up level for array No. 2 is 3.
[0182] When the fifth query command is issued, it is assumed that the fourth query is completed, and the data of array No. 2 continues to be uploaded, and the pointer returns from array No. 2 to array No. 0.
[0183] That is, when the query interface request is called for the Mth time, the calling pointer always points to an array of N newly added wake-up levels, where N is the target wake-up level.
[0184] In summary, if in response to the Mth call to the query interface request, the newly added wake-up level of an array in the target array is equal to the target wake-up level, and the wake-up source information stored in an array in the target array is uploaded, and 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) Invalid threads are filtered out without the help of blacklists and whitelists.
[0187] 2) Cross-process search is implemented. Based on the process of determining the wake-up relationship, the search is limited to all threads in a process, thereby implementing cross-process search.
[0188] 3) It is possible to implement simultaneous search of multiple threads for wake-up relationships. Assuming that the level 3 wake-up sources of thread A and thread B are searched simultaneously, it is only necessary to construct arrays for thread A and thread B respectively and search in the above manner.
[0189] 4) The search for the circular wake-up relationship is realized, and the circular wake-up relationship is expressed by using an array, that is, the circular wake-up relationship is not expressed in a ring, which is convenient for processing.
[0190] 5) When a new thread exists, there is no need to maintain the query result. For example, if there is a new thread L13>>T, L13 only needs to be placed in the array with updateable wake-up layer as layer 1, and there is no need to maintain the query result.
[0191] 6) This application is specifically implemented using a kernel, which improves efficiency.
[0192] On the basis of all the above embodiments, in order to realize the above logic, in this application, it is necessary to build an engine for identifying the wake-up relationship, please refer to Fig.10 , corresponding to the above embodiment, first specify the target thread T and the target wake-up level N, then create N arrays, and number the arrays to form the first target array, and construct a structure based on the thread information of the target thread T. Here, the structure can carry the following information: the thread number of the thread, the thread number of the parent thread of the thread, the wake-up level of the thread corresponding to the target thread T, and the number of wake-ups of the thread within the specified time period. The structure based on the thread information of the target thread T is placed in the N arrays, thereby completing the construction of the array. The constructed array is as follows: Fig.11 Shown
[0193] It should be noted that the relationship between arrays and structures is that the members in an array are the corresponding structures. In order to obtain the position of a member (i.e. a specified structure) in an 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. The resulting array is as follows: Fig.11 shown.
[0194] At this time, the operation of filling the array is executed to search for the wake-up source level by level. Here, T is used as the starting thread to search for the wake-up source level by level, that is, the wake-up source is searched level by level according to the newly added wake-up level. The determination rules of the newly added wake-up level and the structure insertion method can be referred to above and will not be repeated here.
[0195] Please refer to Fig.12 In order to implement the above-mentioned step-by-step search process, based on the above-mentioned embodiment, for a>>t, when a wake-up event occurs, optionally, the try_to_wake_up function is called. Combined with the above, a stub is inserted into try_to_wake_up by inserting a stub. The stub can be used to identify the waker and the awakened. Based on the above, the structure built based on the t thread 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 the 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 newly available wake-up level of the m-th array. If the newly available 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 the information of thread a, specifically increment the number of wake-ups by 1. If not, place the structure constructed based on the information of thread a at the end of the m-th array.
[0199] Please refer to Fig.13 , for calculating the newly available 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 newly updatable wake-up level y of the m-th array = max(0, x + 1 - m);
[0200] If x ≥ N, use the following formula to determine the newly updatable wake-up 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 in accordance with Fig.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 0-th 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 newly available 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 0-th array. This is the movement rule of the pointer.
[0205] Based on the above embodiments, it is assumed that in this application, please refer to Fig.14 At the same time, if you need to execute the wake-up relationship query 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, build the target array according to the above method, and you can search the wake-up relationship of multiple target threads in parallel.
[0206] Please refer to Fig.15 ,For each target array, first perform initialization (not shown in the figure), whenever the wake-up time occurs, the wake-up relationship is identified by the ,try to wake up or wake up new task function after ,insertion, each time the query interface is called, the wake-up relationship is ,queried, and the wake-up relationship is performed according ,3 to 4. Fig.13 The target array is updated in the manner shown.
[0207] Please refer to Fig.16 , Fig.16 A flowchart of a method for determining a wake-up relationship provided in an embodiment of the present application includes the following steps:
[0208] S101: construct a target array, wherein each target array includes a structure constructed based on target thread information, and each array includes multiple structures;
[0209] S102: In response to the Mth invocation of the query interface request, in the target array, any array obtains the wakeup source information layer by layer according to the newly added wakeup level based on the wakeup relationship and the invocation of the query interface request;
[0210] In response to the Mth invocation of the query interface request, in the target array, any array according to the wakeup source information of each layer according to the newly added wakeup level based on the wakeup relationship and the invocation of the query interface request includes:
[0211] If in response to the Xth call to the query interface request, the newly addable wake-up level of any array in the target array is 1, the wake-up source information of the first-level wake-up level is queried and obtained, and the structure constructed based on the wake-up source information of the first-level wake-up level is placed in the position corresponding to the first-level wake-up level in any array in the target array;
[0212] In response to the X+1 acquisition call query interface request, in the target array, the new wake-up level of any array is 2, query and obtain the wake-up source information of the first wake-up level, and place the structure constructed based on the wake-up source information of the second wake-up level in the target array, any array, in the position corresponding to the second wake-up level, and so on, until the new wake-up level is equal to the target wake-up level
[0213] The Xth query interface call request is any query interface request among the previous M query interface calls.
[0214] One possible way is that in response to the Mth call query interface request, in the target array, any array according to the wakeup source information of the newly added wakeup level layer by layer based on the wakeup relationship and the call query interface request includes:
[0215] In response to the Mth call to the query interface request, the wake-up relationship within the specified time period is queried, and the wake-up relationship includes the target waker information and the target wakenee information. The specified time period starts from the moment the query interface request is called for the Mth time and ends at the moment the query interface request is called for the M+1th time.
[0216] If the target awakener information satisfies the first condition, a structure based on the target awakener information is constructed, and the structure based on the target awakener information is inserted into the target array, at a position corresponding to the yth level awakening level of any array;
[0217] If the target awakener information satisfies the second condition, the structure based on the target awakener information is updated;
[0218] The first condition includes: the structure based on the target waker information does not exist in the target array, in the position corresponding to the yth level wake-up level of any array;
[0219] The second condition includes: the structure based on the target waker information exists in the target array, in the position corresponding to the yth level wake-up level of any array;
[0220] Among them, the structure constructed based on the target awakened person's information exists in the target array, in the position corresponding to the y-1 level wake-up level of any array, in response to M calls to the query interface request, in the target array, the new wake-up level that can be added to any array is Y.
[0221] One possible approach is that the number of target arrays is equal to the number of target wake-up levels, and in response to calling a query interface request, in the target array, some or all arrays obtain the wake-up source information layer by layer according to the newly added wake-up level based on the wake-up relationship and the calling query interface request, and in response to calling the query interface request, in the target array, each array in some or all arrays has a different newly added wake-up level.
[0222] One possible manner is that, in response to the Mth invocation of the query interface request, before the step of querying the wake-up relationship within the specified time period, the method further includes:
[0223] Identify the arousal relationship based on the objective function;
[0224] The steps of identifying the arousal relationship according to the objective function include:
[0225] Add stubs to the target function. The stubs are used to identify the wakeup relationship. The target function is called every time the wakeup 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 way is that the target arrays in at least one target array are numbered 0, 1, 2, 3, 4, 5...N-1 from top to bottom.
[0228] M <N;
[0229] In response to the Mth call query interface request, in the step of obtaining the wakeup source information layer by layer according to the newly added wakeup level based on the wakeup relationship and the call query interface request in any array in the target array,
[0230] The following method is used to determine the newly added wake-up level corresponding to each array in the target array:
[0231] In the target array, the newly added wake-up level of the array numbered 0 is M+1, the newly added wake-up level of the array numbered 1 is M, the newly added wake-up level of the target array numbered 2 is M-1, and so on. The newly added wake-up level of the target array numbered M is 1.
[0232] One possible way is that in response to the Mth call to the query interface request, in the step of obtaining the wake-up source information layer by layer according to the newly added wake-up level based on the wake-up relationship and the call to the query interface request, the newly added wake-up level corresponding to each array in the target array is determined in the following way:
[0233] In the target array, the newly added wake-up level of the array numbered 0 is k+1, the newly added wake-up level of the array numbered 1 is k, and so on. The newly added wake-up level of the array numbered k is 1, the newly added wake-up level of the array numbered k+1 is N, the newly added wake-up level of the array numbered k+2 is N-1, and so on.
[0234] Among them, M≥N, and M%N=k and k≠0.
[0235] One possible way is that in response to the Mth call query interface request, in the step of obtaining the wake-up source information layer by layer according to the newly added wake-up level based on the wake-up relationship and the call query interface request, any array in the target array determines the newly added wake-up level corresponding to each array in the target array in the following way:
[0236] In the target array, the newly added wake-up level of the array numbered 0 is 1, the newly added wake-up level of the array numbered 1 is N, the newly added wake-up level of the array numbered 2 is N-1, the newly added wake-up level of the array numbered 3 is N-2, and so on;
[0237] Among them, M≥N, and M%N=0.
[0238] One possible way is that in response to the Mth call to the query interface request, in the target array, the newly added wake-up level of an array is equal to the target wake-up level
[0239] The method also includes: uploading the wake-up source information stored in an array in the target array, and retaining only a structure constructed based on the target thread information in the array in the target array.
[0240] Please refer to Fig.17 , Fig.17 A structure diagram of a wake-up relationship determination device provided in an embodiment of the present application includes the following steps:
[0241] Construction module: used to construct a target array. In the target array, each target array includes a structure constructed based on the target thread information, and each array includes multiple structures;
[0242] Response module: used to respond to the Mth call query interface request, in the target array, any array obtains the wakeup source information layer by layer according to the newly added wakeup level based on the wakeup relationship and the call query interface request;
[0243] The response module shown is specifically used for:
[0244] If in response to the Xth call to the query interface request, the newly addable wake-up level of any array in the target array is 1, the wake-up source information of the first-level wake-up level is queried and obtained, and the structure constructed based on the wake-up source information of the first-level wake-up level is placed in the position corresponding to the first-level wake-up level in any array in the target array;
[0245] In response to the X+1 acquisition call query interface request, in the target array, the new wake-up level of any array is 2, query and obtain the wake-up source information of the second wake-up level, and place the structure constructed based on the wake-up source information of the second wake-up level in the target array, any array, the position corresponding to the second wake-up level, and so on, until the new wake-up level is equal to the target wake-up level
[0246] The Xth query interface call request is any query interface request among the previous M query interface calls.
[0247] The above describes specific embodiments of the present invention. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0248] The embodiment of the present application provides an electronic device, which may be a terminal device or a circuit device built into the terminal device. The electronic device may be used to execute the functions / steps in the above method embodiment.
[0249] An embodiment of the present application provides a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a terminal device, the terminal device executes the functions / steps in the above method embodiment.
[0250] The present application actually has three kinds of relationships, for example, A and / or B can represent the situation where A exists alone, A and B exist at the same time, or B exists alone. A and B can be singular or plural. The character " / " generally indicates that the objects before and after 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 single 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, c can be single or multiple.
[0251] Those of ordinary skill in the art will appreciate that the various units and algorithm steps described in the embodiments disclosed herein can be implemented in a combination of electronic hardware, computer software, and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0252] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0253] In several embodiments provided in the present application, any function can be stored in a computer-readable storage medium if it is implemented in the form of a software functional unit and sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art, and the computer software product is stored in a storage medium, including several instructions for an electronic device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0254] The above are only specific implementations of the present application. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. The protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for determining a wake-up relationship, characterized in that: The steps include: Constructing a target array, wherein each of the target arrays includes a structure constructed based on target thread information, and each array includes a plurality of structures; In response to the Mth call query interface request, in the target array, any array obtains the wakeup source information layer by layer according to the newly added wakeup level based on the wakeup relationship and the call query interface request; In response to the Mth calling query interface request, the step of any array in the target array according to the wakeup source information of each layer according to the newly added wakeup level based on the wakeup relationship and the calling query interface request includes: If in response to the Xth call to the query interface request, the newly addable wake-up level of any array in the target array is 1, the wake-up source information of the first-level wake-up level is queried and obtained, and the structure constructed based on the wake-up source information of the first-level wake-up level is placed in the target array, any array, in the position corresponding to the first-level wake-up level; In response to the call query interface request obtained X+1 times, in the target array, the newly added wake-up level of any array is 2, the wake-up source information of the second-level wake-up level is queried and obtained, and the structure constructed based on the wake-up source information of the second-level wake-up level is placed in the target array, any array, in the position corresponding to the second-level wake-up level, and so on, until the newly added wake-up level is equal to the target wake-up level; The Xth query interface call request is any query interface request among the previous M query interface calls.
2. The method according to claim 1, characterized in that In response to the Mth invocation of the query interface request, in the target array, any array according to the wakeup source information layer by layer based on the wakeup relationship and the invocation of the query interface request according to the newly added wakeup level includes: In response to the Mth call to the query interface request, the wake-up relationship within the specified time period is queried, the wake-up relationship includes the target waker information and the target wakenee information, and the specified time period starts from the moment the query interface request is called for the Mth time and ends at the moment the query interface request is called for the M+1th time. If the target waker information satisfies the first condition, a structure based on the target waker information is constructed, and the structure based on the target waker information is inserted into the target array, into a position corresponding to the yth level wake-up level of any array; If the target awakener information satisfies the second condition, the structure based on the target awakener information is updated; The first condition includes: the structure based on the target waker information does not exist in the target array, in a position corresponding to the yth level wake-up level of any array; The second condition includes: the structure based on the target waker information exists in the target array, in a position corresponding to the yth level wake-up level of any array; Among them, the structure constructed based on the target awakened person information exists in the target array, in the position corresponding to the y-1 level wake-up level of any array, and in response to M calls to the query interface request, in the target array, the newly added wake-up level of any 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 call query interface request, in the target array, some or all arrays obtain the wake-up source information layer by layer according to the newly added wake-up level based on the wake-up relationship and the call query interface request. In response to the call query interface request, in the target array, each array in some or all arrays has a different newly added wake-up level.
4. The method according to claim 2, characterized in that: In response to the Mth invocation of the query interface request, before the step of querying the wake-up relationship within the specified time period, the method further includes: Identify the arousal relationship based on the objective function; The step of identifying the wake-up relationship according to the objective function comprises: A stub is added to the target function, where the stub is used to identify a wakeup relationship, and the target function is called each time a wakeup event occurs.
5. The method according to claim 2, characterized in that: The target 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 0, 1, 2, 3, 4, 5...N-1, M from top to bottom. <N; In the step of, in response to the Mth calling query interface request, in which any array in the target array obtains the wakeup source information layer by layer according to the newly added wakeup level based on the wakeup relationship and the calling query interface request, the newly added wakeup level corresponding to each array in the target array is determined in the following manner: In the target array, the array numbered 0 has an additional wake-up level of M+1, the array numbered 1 has an additional wake-up level of M, the target array numbered 2 has an additional wake-up level of M-1, and so on. The target array numbered M has an additional wake-up level of 1.
7. The method according to claim 3, characterized in that The arrays in the target array are numbered 0, 1, 2, 3, 4, 5...N-1 from top to bottom; In the step of, in response to the Mth calling query interface request, in which any array in the target array obtains the wakeup source information layer by layer according to the newly added wakeup level based on the wakeup relationship and the calling query interface request, the newly added wakeup level corresponding to each array in the target array is determined in the following manner: In the target array, the newly added wake-up level of the array numbered 0 is k+1, the newly added wake-up level of the array numbered 1 is k, and so on. The newly added wake-up level of the array numbered k is 1, the newly added wake-up level of the array numbered k+1 is N, the newly added wake-up level corresponding to the array numbered k+2 is N-1, and so on. Among them, 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 0, 1, 2, 3, 4, 5...N-1 from top to bottom; In the step of obtaining the wakeup source information layer by layer according to the newly added wakeup level based on the wakeup relationship and the call query interface request in response to the Mth call query interface request, the newly added wakeup level corresponding to each array in the target array is determined in the following manner: In the target array, the newly added wake-up level of the array numbered 0 is 1, the newly added wake-up level of the array numbered 1 is N, the newly added wake-up level of the array numbered 2 is N-1, the newly added wake-up level of the array numbered 3 is N-2, and so on; Among them, 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 invocation of the query interface request, in the target array, the newly addable wake-up level of an array is equal to the target wake-up level; The method further includes: uploading the wake-up source information stored in an array in the target array, wherein the array in the target array only retains a structure constructed based on the target thread information.
10. A wake-up relationship determination device, characterized in that: include: Construction module: used to construct a target array, each of which includes a structure constructed based on target thread information, and each array includes multiple structures; Response module: used for responding to the Mth call query interface request, in the target array, any array obtains the wakeup source information layer by layer according to the newly added wakeup level based on the wakeup relationship and the call query interface request; The response module shown is specifically used for: If in response to the Xth call to the query interface request, the newly addable wake-up level of any array in the target array is 1, the wake-up source information of the first-level wake-up level is queried and obtained, and the structure constructed based on the wake-up source information of the first-level wake-up level is placed in the target array, any array, in the position corresponding to the first-level wake-up level; In response to the X+1-time acquired call query interface request, in the target array, the newly addable wake-up level of any array is 2, the wake-up source information of the second-level wake-up level is queried and acquired, and the structure constructed based on the wake-up source information of the second-level wake-up level is placed in the target array, any array, in the position corresponding to the second-level wake-up level, and so on, until the newly addable wake-up level is equal to the target wake-up level. The Xth call query interface request is any query interface request among the previous M call query interface requests.
11. An electronic device, characterized in that: include: at least one processor; and at least one memory in communication with the processor, wherein: The memory stores program instructions executable by the processor, and the processor can execute the method according to any one of claims 1 to 9 by calling the program instructions.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions enable the computer to execute the method according to 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
Wake-up management for mobile devices
US9648564B1
Multi-thread rendering method and apparatus, electronic device and storage medium
WO2023044876A1
Cited By
Multi-thread management and control method and related equipment
CN119861976A