Electronic device and device resource management method thereof
By maintaining a list of program and device resources in the electronic device, recording resource information of applications and device drivers, and releasing resources in a hierarchical manner, the problem of memory waste and performance degradation caused by abnormal exit of device drivers in multi-program application scenarios is solved, and timely resource reclamation and system performance maintenance are achieved.
Patent Information
- Application Number
- CN202310286815.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-22
- Publication Date
- 2026-08-25
- Estimated Expiration
- 2043-03-22
AI Technical Summary
In existing technologies, when a device driver exits abnormally in a multi-program application scenario, resources cannot be reclaimed in a timely manner, leading to memory waste and system performance degradation.
A device resource management method is adopted, which maintains two lists (program resource management list and device resource management list) in the electronic device to record the resource information of application programs and device drivers, and releases resources in a hierarchical order when abnormal exit occurs, ensuring that other programs are not affected.
This effectively avoids memory waste, maintains system performance, and ensures that the resource reclamation process does not affect the normal operation of other programs.
Smart Images

Figure CN116302542B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to electronic devices, and more particularly to electronic devices and methods for managing device resources. Background Technology
[0002] As user applications grow larger and more complex, multi-process application scenarios are becoming increasingly common. Traditional device drivers offer limited support for these scenarios, failing to meet the needs of most embedded electronic products. One application corresponds to one program; for example, in a car dashcam, one main application handles complete image display and recording, another provides the graphical user interface (GUI) operation, and yet another handles blind spot detection (BSD) functionality.
[0003] When a subprocess exits abnormally, the Linux kernel shuts down different device driver nodes to release resources. Finally, the individual device driver's `deinit` callback function performs different garbage collection processes. However, this method cannot guarantee that other programs will not be affected. Furthermore, the device driver module's resources are only fully released when the main program exits; this leads to wasted memory and decreased system performance. Summary of the Invention
[0004] In view of the shortcomings of the prior art, one object of the present invention is to provide an electronic device and a method for managing device resources, so as to improve the technical problem in the prior art where one application corresponds to one program, and the memory is wasted and the system performance is degraded because the program cannot be reclaimed in time when it is abnormal.
[0005] An embodiment of the present invention provides a device resource management method for an electronic device, the electronic device including a memory and executing at least two applications, the memory storing a first list and a second list, the first list containing at least one application resource information, the second list containing at least one device driver, the at least one application resource information corresponding to the at least one device driver, and each device driver corresponding to at least one device resource information. The device resource management method includes: in response to an abnormal exit procedure of a target application of each of the applications, finding target application resource information corresponding to the target application from the first list, the target application resource information being one of the at least one application resource information; determining a target device driver based on the target application resource information; and deleting the target device resource information corresponding to the target device driver from the second list.
[0006] Another embodiment of the present invention provides an electronic device that executes at least two applications and includes: a memory, an application circuit, and a processing circuit. The memory stores a first list and a second list, the first list containing at least one application resource information, and the second list containing at least one device driver, the at least one application resource information corresponding to the at least one device driver, each device driver corresponding to at least one device resource information. The processing circuit is coupled to the memory and the application circuit and performs the following steps: executing a target application corresponding to the application circuit, the target application being one of the applications; in response to an abnormal exit procedure of the target application, retrieving target application resource information corresponding to the target application from the first list, the target application resource information being one of the at least one application resource information; determining a target device driver based on the target application resource information; and deleting the target device resource information corresponding to the target device driver from the second list.
[0007] Another embodiment of the present invention provides an electronic device that executes at least two applications and includes: a memory, an application circuit, and a processing circuit. The memory stores a first list and a second list, the first list containing at least one application resource information, and the second list containing at least one device driver, the at least one application resource information corresponding to the at least one device driver, each device driver corresponding to at least one device resource information. The processing circuit is coupled to the memory and the application circuit and performs the following steps: executing a target application corresponding to the application circuit, the target application being one of the applications; creating target application resource information for the target application in the first list; identifying a target device driver associated with the target application based on the target application resource information; and, when the target device driver does not contain target device resource information, creating the target device resource information. The target device resource information corresponds to the target device driver and is recorded in a device resource information table used by the target device driver.
[0008] The technical means embodied in the embodiments of the present invention can improve at least one of the disadvantages of the prior art. Therefore, the present invention can avoid memory waste and system performance degradation compared with the prior art.
[0009] The features, implementation, and effects of this invention are described in detail below with reference to the accompanying drawings. Attached Figure Description
[0010] Regarding the features, implementation, and effects of this case, a preferred embodiment is described in detail below with reference to the drawings:
[0011] Figure 1 This is a functional block diagram of an embodiment of the electronic device of the present invention;
[0012] Figure 2 show Figure 1 A schematic diagram of an embodiment of the program resource management list LST_AP and the device resource management list LST_DD;
[0013] Figure 3 Displays device resource information;
[0014] Figure 4 This is a schematic diagram of an embodiment of the operating system architecture of the present invention;
[0015] Figure 5 This is a flowchart of an embodiment of the newly added application resource information function of the present invention;
[0016] Figure 6This is a flowchart of an embodiment of the function for deleting application resource information according to the present invention;
[0017] Figure 7 This is a flowchart of an embodiment of the device resource release function of the present invention;
[0018] Figure 8 This is a flowchart of an embodiment of the device resource management method of the present invention;
[0019] Figure 9 This is the detailed process of launching the application according to the present invention;
[0020] Figure 10 This is a flowchart of an embodiment of the normal exit of the application program of the present invention; and
[0021] Figure 11 This is a flowchart of an embodiment of the application program that abnormally exits according to the present invention. Detailed Implementation
[0022] The technical terms used in the following description are based on the customary terms in this technical field. If this specification provides explanations or definitions for certain terms, the interpretation of those terms shall be based on the explanations or definitions in this specification.
[0023] The disclosure of this invention includes electronic devices and methods for managing device resources thereon. Since some components of the electronic device described in this invention may be known individually, details of known components will be omitted in the following description without affecting the full disclosure and implementability of the device invention. Furthermore, some or all of the processes of the device resource management method of the electronic device described in this invention may be in the form of software and / or firmware, and may be executed by the electronic device described in this invention or its equivalent. Without affecting the full disclosure and implementability of the method invention, the following description of the method invention will focus on the steps rather than the hardware.
[0024] Please see Figure 1 , Figure 1This is a functional block diagram of an embodiment of the electronic device of the present invention. The electronic device 100 includes a chip 101 and memory 102. Chip 101 includes a processing circuit 110 and multiple application circuits (including but not limited to an image input interface circuit 111, an image processor 112, an image encoder 113, an on-screen display (OSD) video superposition circuit 114), and a buffer 115. Memory 102 stores a program resource management list LST_AP, a device resource management list LST_DD, a device driver 121, and multiple application programs (including but not limited to application programs 122, 123, and 124). The processing circuit 110 accesses memory 102 through a memory interface or bus 103.
[0025] The processing circuit 110 can be a circuit or electronic component with program execution capability, such as a central processing unit, microprocessor, microprocessor unit, digital signal processor, application specific integrated circuit (ASIC), or equivalent circuit. The processing circuit 110 executes the operating system and application programs of the electronic device 100 by executing program code and / or program instructions stored in memory 102.
[0026] Please see Figure 2 , Figure 2 show Figure 1 A schematic diagram of an embodiment of the program resource management list LST_AP and the device resource management list LST_DD. The program resource management list LST_AP includes a list head AP0 and multiple application resource information (including application resource information AP1, application resource information AP2, application resource information AP3, ...). Each application resource information corresponds to an application and includes program resource information PRI. The program resource information PRI includes the application identifier Pid, the number of device resources ResCount, and the device driver resource list Reslist[].
[0027] The device resource management list LST_DD contains a header DD0 and multiple device drivers (including device driver DD1, device driver DD2, device driver DD3, ...). Each device driver contains or corresponds to a device resource information list LST_RC. A device resource information list LST_RC contains one or more device resource information (including device resource information RC1, device resource information RC2, device resource information RC3, device resource information RC4, ...).
[0028] The device driver resource list Reslist[] of application resource information PRI corresponds to N device drivers, where N is related to the complexity of the application corresponding to the application resource information. For example, when the application corresponding to application resource information AP1 is more complex (i.e., the application requires more device resources), the device driver resource list Reslist[] of application resource information AP1 can correspond to device driver DD1, device driver DD2, or more device drivers; when the application corresponding to application resource information AP1 is less complex (i.e., the application requires fewer device resources), the device driver resource list Reslist[] of application resource information AP1 can correspond to only device driver DD1.
[0029] Please see Figure 3 , Figure 3 Displays the device resource information. The device resource information RCx (x = 1, 2, 3, ...) includes device resource data RscInfo and device resource usage count RefCnt. The device resource data RscInfo records information about the device resources used by the corresponding device driver, such as module identifier eMid, level ePL, key value Ky, private data PriData, data size DataSize, and application identifier Pid.
[0030] The module identifier eMid records the driver type of the device resource.
[0031] The level of ePL (Equivalent Product Rank) is the level of device resources and determines the order in which resources are released. For example, when device resources are initialized, the level ePL is 0; when a device is created or handled, the level ePL is 1; when a channel is created, the level ePL is 2.
[0032] The key value Ky is a unique identifier for resources of the same level within the current application. For example, if the key value Ky is 64 bits, the high 32 bits represent the type of the current resource, while the low 32 bits represent the type of resource created. Channels for the same device resource are further subdivided into the high 16 bits and low 16 bits of the resource type value.
[0033] The application identifier Pid represents the application identifier Pid of the application that uses the device resource information.
[0034] The PriData record contains additional private data required to release the device resource information. The DataSize record contains the size of the PriData record. The default value for the PriData record is NULL, while the default value for the DataSize record is 0.
[0035] Please also refer to Figure 1 and Figure 2 An application circuit can correspond to an application program; more specifically, the processing circuit 110 executes the application program corresponding to the application circuit to operate or manage the application circuit. For example, the processing circuit 110 executes the application program (e.g., application program 122) of the screen display video overlay circuit 114 to operate or manage the screen display video overlay circuit 114. The application program being executed by the processing circuit 110 is recorded in the program resource management list LST_AP (i.e., as a node in the program resource management list LST_AP). One or more device drivers used by an application program are recorded in the device resource management list LST_DD (i.e., as one or more nodes in the device resource management list LST_DD). Device resource information associated with a device driver (i.e., device resources used by the device driver (e.g., input / output devices of electronic device 100, buffer 115, etc.)) is recorded in the device resource information list LST_RC of the device driver.
[0036] Please see Figure 4 , Figure 4 This is a schematic diagram of an embodiment of the operating system architecture of the present invention.
[0037] Call interface 410 (MI_XXX_API) is a call interface provided by the device driver to the user space. It may include device driver-related functions such as create, initialize, stop, destroy, set, and get. In "MI_XXX_API", "XXX" represents the various function names, and the same applies below.
[0038] Control layer 430 (MI_XXX_IOCTL) is the control layer for device drivers to move from user space to kernel space. For Linux platforms, this control layer is accessed through kernel system calls. For dual-OS platforms, a switch from user space to the real-time operating system (RTOS) system space must first be made through adapter layer 420. Kernel system calls and adapter layer 420 are well-known to those skilled in the art and will not be described further.
[0039] Functional implementation layer 440 (MI_XXX_IMPL) is the device driver functional implementation layer, used to communicate with the device hardware to complete the corresponding functions.
[0040] The present invention implements the following three functions in the control layer 430: the function 432 for adding application resource information (MI_COMMON_AddResource), the function 434 for deleting application resource information (MI_COMMON_DelResource), and the function 436 for releasing device resources (MI_XXX_IOCTL_FreeResource).
[0041] In some embodiments, a user can call the creation function "MI_XXX_IOCTL_Create" of the control layer 430 through the creation function "MI_XXX_Create" of the call interface 410 in order to enable the function 432 for adding application resource information.
[0042] In some embodiments, a user can call the destruction function "MI_XXX_IOCTL_Destory" of the control layer 430 through the destruction function "MI_XXX_Destroy" of the call interface 410 in order to enable the function 434 for deleting application resource information.
[0043] In some embodiments, when an application exits due to a system exception, the system exception (e.g., "kill-9") is invoked, which triggers the "MI_XXX_IOCTL_ProcessExit" function in the control layer 430, and further triggers the device resource release function 436.
[0044] Implementing the above three functions in the control layer 430 has the following advantages: (1) The user application and the device driver execution program resource records are separated, so the user does not need to care about the implementation details, and only needs to implement the functions of each application according to the original device driver user interface; and (2) It takes into account the differences of the operating system platform, so that the device driver can support the multi-process function on pure Linux and dual operating system (Linux and Rtos) platforms.
[0045] The following combinations Figures 5-7 Explain these three functions.
[0046] Please see Figure 5 , Figure 5 This is a flowchart of an embodiment of the function for adding application resource information according to the present invention. The function 432 for adding application resource information is used to add application resource information (i.e., add a new node) to the program resource management list LST_AP and update some related parameters when the application is started, including the following steps.
[0047] Step S510: Processing circuit 110 determines whether application resource information corresponding to the current application has been created. More specifically, since an application corresponds to an application identifier Pid, in this step, processing circuit 110 searches for application resource information corresponding to the current application in the program resource management list LST_AP using the application identifier Pid of the current application. If found (i.e., application resource information corresponding to the current application has been created), processing circuit 110 executes step S530; otherwise, processing circuit 110 executes step S520.
[0048] Step S520: Processing circuit 110 creates the current application resource information node and adds the node to the program resource management list LST_AP. The application identifier Pid of the program resource information PRI is the application identifier Pid of the current application; the device driver resource list Reslist[] of the program resource information PRI points to one or more device drivers related to the current application; the value of the device resource count ResCount is the number of device resources used by each of the related device drivers.
[0049] Step S530: Processing circuit 110 determines whether device resource information for the device resources used by each of the related device drivers has been created. More specifically, processing circuit 110 searches for device resource information in the device resource information list LST_RC using at least one of the module identifier eMid, level ePL, and key value Ky. If not found (i.e., device resource information for the device resources used by each of the related device drivers has not been created), processing circuit 110 executes step S540; otherwise, processing circuit 110 executes step S550.
[0050] Step S540: Processing circuit 110 creates a device resource information node, copies the current device resource information to the newly created device resource information node, and adds the node to the device resource information list.
[0051] LST_RC. If the private data PriData of the current device resource information is not empty, then the processing circuit...
[0052] 110 further copies the private data PriData into the newly created device resource information. In addition, the processing circuit 110 increments the device resource usage count RefCnt of the newly created device resource information by 1, and increments the current application's device resource count ResCount by 1.
[0053] Step S550: Processing circuit 110 updates the device resource usage count RefCnt of the device resource information (e.g., increments by 1). Because the device resources corresponding to the device resource information are used by the current application, processing circuit 110 increments the device resource usage count RefCnt of the device resource information by 1.
[0054] Step S560: The function 432 for adding application resource information ends normally (returning the first return value (e.g., 0)).
[0055] Please see Figure 6 , Figure 6 This is a flowchart of an embodiment of the function for deleting application resource information according to the present invention. The function 434 for deleting application resource information is used to delete application resource information from the application resource management list LST_AP (i.e., delete a node) when the application exits normally, and includes the following steps.
[0056] Step S610: Processing circuit 110 determines whether application resource information corresponding to the current application has been created. Step S610 is the same as step S510, so it will not be described again. If the application resource information corresponding to the current application has not been created (i.e., the result of step S610 is no), then processing circuit 110 executes step S620; otherwise, processing circuit 110 executes step S630.
[0057] Step S620: The function 434 for deleting application resource information terminates abnormally (returning a second return value (e.g., -1)).
[0058] Step S630: Processing circuit 110 determines whether device resource information for device resources used by one or more device drivers associated with the current application has been created. Step S630 is the same as step S530, and therefore will not be described again. If the device resource information for the said or all said device resources has been created (i.e., the result of step S630 is yes), then processing circuit 110 executes step S640; otherwise, processing circuit 110 executes step S620.
[0059] Step S640: Processing circuit 110 updates the device resource usage count RefCnt of the device resource information of the said or each of the device resources (e.g., decrementing it by 1). Because the current application no longer uses the relevant device resources after exiting, processing circuit 110 decrements the device resource usage count RefCnt of the relevant device resources by 1.
[0060] Step S650: Processing circuit 110 determines whether the device resource usage count RefCnt of the device resource information is a default value (e.g., 0). If it is (meaning that the device resource corresponding to the device resource information is no longer used by any application), then processing circuit 110 executes step S660; otherwise, processing circuit 110 executes step S670.
[0061] Step S660: Processing circuit 110 releases the device resources corresponding to the device resource information and removes the node corresponding to the device resource information from the device resource information list LST_RC. If the private data PriData of the device resource information is not empty, processing circuit 110 further releases the memory corresponding to the private data PriData.
[0062] Step S670: The function 434 for deleting application resource information terminates normally (returning the first return value (e.g., 0)).
[0063] Please see Figure 7 , Figure 7 This is a flowchart of an embodiment of the device resource release function of the present invention. The device resource release function 436 is used to release device resources when the application exits abnormally, and includes the following steps.
[0064] Step S710: Processing circuit 110 determines whether application resource information corresponding to the current application has been created. Step S710 is the same as step S510, so it will not be described again. If the application resource information corresponding to the current application has not been created (i.e., the result of step S710 is no), then processing circuit 110 executes step S720; otherwise, processing circuit 110 executes step S730.
[0065] Step S720: The device resource release function 436 terminates abnormally (returns the second return value (e.g., -1)).
[0066] Step S730: The processing circuit 110 sequentially traverses the device resource management list LST_DD according to the hierarchical ePL in the device resource information to release device resources, and removes the node corresponding to the released device resource from the device resource management list LST_DD. More specifically, the processing circuit 110 first releases the device resources corresponding to the device resource information with higher hierarchical ePL, and then releases the device resources corresponding to the device resource information with lower hierarchical ePL. The processing circuit 110 releases device resources based on the private data PriData.
[0067] Step S740: Because one device resource of the current application has been released, the processing circuit 110 decrements the number of device resources ResCount of the current application by 1.
[0068] Step S750: Processing circuit 110 decrements the level ePL by 1.
[0069] Step S760: Processing circuit 110 determines whether the hierarchical ePL is greater than 0 and whether there is still device resource information. If yes (meaning there may still be device resources to be released), processing circuit 110 executes step S730 to continue trying to release device resources; otherwise (i.e., all the device resources to be released have been released, that is, the number of device resources ResCount in the current application resource information is 0), processing circuit 110 executes step S770.
[0070] Step S770: Processing circuit 110 removes the node corresponding to the current application resource information from the application resource management list LST_AP.
[0071] Step S780: The device resource release function 436 terminates normally (returning the first return value (e.g., 0)).
[0072] In some embodiments, the program resource management list LST_AP, the device resource management list LST_DD, and the device resource information list LST_RC are implemented as hash lists to save search time.
[0073] In summary, because each device resource information record contains a device resource usage count (RefCnt) and an application identifier (Pid), device resources maintain usage records in each application, and the device driver knows which device resources the current application has created. Therefore, when an application exits abnormally, the operating system of the electronic device 100 can properly reclaim or release the device resources used by the device driver associated with that application. Furthermore, because device resource information records the hierarchical ePL, and device resources are released sequentially according to the hierarchical ePL (e.g., from high to low), releasing device resources for one application will not affect the execution of other applications. In other words, this invention effectively manages device resources in an electronic device by creating a hypervisor resource management list (LST_AP) and a device resource management list (LST_DD), thus enabling the electronic device of this invention to make proper use of memory and maintain system performance.
[0074] Please see Figure 8 , Figure 8 This is a flowchart of an embodiment of the device resource management method of the present invention. The device resource management method can be applied to electronic device 100 and includes the following steps.
[0075] Step S810: Processing circuit 110 opens the target application, for example, opens application 122 of screen display video overlay circuit 114, application 122 for example corresponding to Figure 2 Application resource information AP1.
[0076] Step S820: Processing circuit 110 executes the target application.
[0077] Step S830: Processing circuit 110 determines whether the target application has exited. If the target application has not exited (i.e., the result of step S830 is no), processing circuit 110 continues to execute the target application (returning to step S820). If the target application exits normally, processing circuit 110 executes the application's normal exit procedure (…). Figure 10 If the target application exits abnormally, the processing circuit 110 executes the application's abnormal exit procedure. Figure 11 ).
[0078] Please see Figure 9 , Figure 9 This invention enables the application to open (i.e., Figure 8 The detailed process of step S810 includes the following steps.
[0079] Step S910: Processing circuit 110 creates target application resource information for the target application in the program resource management list LST_AP. For implementation details of this step, please refer to [link / reference needed]. Figure 5 The following is an explanation of step S520. Figure 8 For example, the target application resource information created by the processing circuit 110 in this step is application resource information AP1.
[0080] Step S920: Processing circuit 110 identifies a target device driver associated with the target application based on the target application resource information. For example, electronic device 100 identifies the target device driver based on the device driver resource list Reslist[] of application resource information AP1. Note that the target application may be associated with multiple device drivers (e.g., Figure 2 The application resource information AP1's device driver resource list Reslist[] can point to device driver DD1 and device driver DD2), and the target device driver is one of the related device drivers (for example, the target device driver is device driver DD1).
[0081] Step S930: Processing circuit 110 determines whether target device resource information contained in the target device driver has been created. For implementation details of this step, please refer to [link / reference needed]. Figure 5The following is a description of step S530. Note that the target device driver may contain multiple device resource information entries, and the target device resource information is one of these entries. If not, proceed to step S940; otherwise, proceed to step S950.
[0082] Step S940: Processing circuit 110 creates target device resource information. For implementation details of this step, please refer to [link / reference needed]. Figure 5 The explanation of step S540. Continuing with the previous example, as follows... Figure 2 As shown, the target device resource information can be the device resource information RC1 of the device driver DD1.
[0083] Step S950: Processing circuit 110 updates the device resource usage count RefCnt of the target device resource information. For implementation details of this step, please refer to [link to relevant documentation]. Figure 5 The following is an explanation of step S550.
[0084] Please see Figure 10 , Figure 10 This is a flowchart of an embodiment of the normal exit of the application program of the present invention, which includes the following steps.
[0085] Step S1010: The processing circuit 110 searches for target application resource information corresponding to the target application in the program resource management list LST_AP. This step is equivalent to... Figure 6 The result of step S610 is yes. Figure 8 For example, the target application resource information found by the processing circuit 110 in this step is application resource information AP1.
[0086] Step S1020: Processing circuit 110 identifies a target device driver associated with the target application. For implementation details of this step, please refer to [link / reference needed]. Figure 9 The explanation of step S920.
[0087] Step S1030: Processing circuit 110 determines whether the target device driver contains target device resource information. For implementation details of this step, please refer to [link / reference needed]. Figure 5 The following is a description of step S530. If yes, then proceed to step S1040; otherwise, terminate the normal exit procedure of the target application.
[0088] Step S1040: Processing circuit 110 updates the device resource usage count RefCnt of the target device resource information. For implementation details of this step, please refer to [link to relevant documentation]. Figure 6 The explanation of step S640.
[0089] Step S1050: Processing circuit 110 determines whether the device resource usage count RefCnt of the target device resource information is equal to a target value. If yes, processing circuit 110 executes step S1060; otherwise, the normal exit procedure of the target application is terminated. For implementation details of step S1050, please refer to [link to relevant documentation]. Figure 6 The following is a description of step S650.
[0090] Step S1060: Processing circuit 110 releases the device resources corresponding to the target device resource information and removes the target device resource information from the target device driver. For implementation details of this step, please refer to [link to relevant documentation]. Figure 6 The explanation of step S660.
[0091] Please see Figure 11 , Figure 11 This is a flowchart of an embodiment of the application program that abnormally exits according to the present invention, which includes the following steps.
[0092] Step S1110: The processing circuit 110 searches for target application resource information corresponding to the target application in the program resource management list LST_AP. This step is equivalent to... Figure 7 The result of step S710 is yes. Figure 8 For example, the target application resource information found by the processing circuit 110 in this step could be application resource information AP1.
[0093] Step S1120: Processing circuit 110 determines a target device driver based on the target application resource information. More specifically, processing circuit 110 determines the target device driver based on the device driver resource list Reslist[] of the target application resource information. Figure 8 and Figure 9 For example, the target device driver determined by the processing circuit 110 in this step can be device driver DD1.
[0094] Step S1130: Processing circuit 110 deletes a target device resource information corresponding to the target device driver from the device resource management list LST_DD. Step S1130 includes sub-steps S1132 and S1134. Figure 8 and Figure 9 In this example, the processing circuit 110 can delete the device resource information RC1 in this step.
[0095] Step S1132: Processing circuit 110 checks the hierarchical ePL of the target device resource information. Continuing with the previous example, processing circuit 110 checks the hierarchical ePL of device resource information RC1 in this step.
[0096] Step S1134: When the level is a target value (e.g., 0), the processing circuit 110 deletes the target device resource information corresponding to the target device driver from the device resource management list LST_DD. For implementation details of sub-steps S1132 and S1134, please refer to [link to relevant documentation]. Figure 7 The following is an explanation of step S730.
[0097] Step S1140: Processing circuit 110 updates the device resource count ResCount of the target application resource information, for example, by decrementing the device resource count ResCount by 1. For implementation details of this step, please refer to [link to relevant documentation]. Figure 7 The following is a description of step S740. Continuing with the previous example, in this step, the processing circuit 110 can decrement the number of device resources ResCount of the application resource information AP1 by 1.
[0098] Step S1150: Processing circuit 110 determines whether the number of device resources ResCount is equal to the target value. If yes, processing circuit 110 executes step S1160; otherwise, it terminates the abnormal exit procedure of the target application. For implementation details of step S1150, please refer to [link to relevant documentation]. Figure 7 The following is a description of step S760.
[0099] Step S1160: Processing circuit 110 deletes the target application resource information from the program resource management list LST_AP. For implementation details of this step, please refer to [link / reference needed]. Figure 7 The following is a description of step S770. Continuing with the previous example, in this step, the processing circuit 110 can delete the node corresponding to the application resource information AP1 from the program resource management list LST_AP.
[0100] Although the foregoing embodiments use image-related application circuits as examples, this is not a limitation of the present invention. Those skilled in the art can appropriately apply the present invention to other types of application circuits and electronic devices based on the disclosure of the present invention.
[0101] While the embodiments of the present invention have been described above, these embodiments are not intended to limit the present invention. Those skilled in the art can make changes to the technical features of the present invention based on its explicit or implicit content. All such changes may fall within the scope of patent protection sought by the present invention. In other words, the scope of patent protection of the present invention shall be determined by the scope of the patent application as defined in this specification.
[0102] [Symbol Explanation]
[0103] 100: Electronic devices;
[0104] 101: Chip;
[0105] 102: Memory;
[0106] 103: Memory interface or bus;
[0107] 110: Processing circuit;
[0108] 111: Image input interface circuit;
[0109] 112: Image Processor;
[0110] 113: Image encoder;
[0111] 114: Screen display video overlay circuit;
[0112] 115: Buffer;
[0113] LST_AP: Program resource management list;
[0114] LST_DD: Device resource management list;
[0115] 121, DD1, DD2, DD3: Device drivers;
[0116] 122, 123, 124: Applications;
[0117] AP0,DD0: Header;
[0118] AP1, AP2, AP3: Application resource information;
[0119] PRI: Program Resource Information;
[0120] Pid: Application identifier;
[0121] ResCount: Number of device resources;
[0122] Reslist[]: A list of device driver resources;
[0123] LST_RC: List of device resource information;
[0124] RC1, RC2, RC3, RC4, RCx: Equipment resource information;
[0125] RscInfo: Device resource data;
[0126] RefCnt: Device resource usage count;
[0127] eMid: Module identifier;
[0128] ePL: hierarchy;
[0129] Ky: key value;
[0130] PriData: Private Data;
[0131] DataSize: Data size;
[0132] 410: Call interface;
[0133] 420: Adapter layer;
[0134] 430: Control layer;
[0135] 440: Functional Implementation Layer;
[0136] 432: Added application resource information function;
[0137] 434: Function to delete application resource information;
[0138] 436: Function to release device resources;
[0139] RTOS: Real-time Operating System;
[0140] S510, S520, S530, S540, S550, S560, S610, S620, S630, S640, S650, S660, S670, S710, S720, S730, S740, S750, S760, S770, S780, S810, S820, S830, S910, S920, S930, S940, S950, S1010, S1020, S1030, S1040, S1050, S1060, S1110, S1120, S1130, S1132, S1134, S1140, S1150, S1160: Steps.
Claims
1. A method for managing device resources in an electronic device, characterized in that, The electronic device includes a memory and executes at least a plurality of applications. The memory stores a first list and a second list. The first list contains at least one application resource information, and the second list contains at least one device driver. The at least one application resource information corresponds to the at least one device driver, and each device driver corresponds to at least one device resource information. The device resource management method includes: In response to an abnormal exit procedure of a target application in the plurality of applications, a target application resource information corresponding to the target application is identified from the first list, wherein the target application resource information is one of the at least one application resource information; A target device driver is determined based on the target application resource information; and Remove a target device resource information corresponding to the target device driver from the second list.
2. The equipment resource management method as described in claim 1, characterized in that, The at least one device resource information includes one level, and the step of deleting the target device resource information corresponding to the target device driver from the second list includes: Check the level of the target device resource information; When the level is a target value, the target device resource information is deleted from the second list.
3. The equipment resource management method as described in claim 1, characterized in that, The target application resource information includes a number of device resources, and the device resource management method further includes: After deleting the target device resource information corresponding to the target device driver from the second list, update the number of device resources; and When the number of device resources equals a target value, the target application resource information is deleted from the first list.
4. The equipment resource management method as described in claim 1, characterized in that, The at least one device resource information includes a device resource usage count, and the device resource management method further includes: Before the abnormal exit procedure of the target application, the target application resource information is created in the first list; and When the target device driver contains the target device resource information, the device resource usage count is updated.
5. The equipment resource management method as described in claim 1, characterized in that, It also includes: Before the abnormal exit procedure of the target application, the target application resource information is created in the first list; and When the target device driver does not contain the target device resource information, the target device resource information is created.
6. The equipment resource management method as described in claim 1, characterized in that, The target device resource information includes a device resource usage count, and the device resource management method further includes: In response to a normal exit procedure of the target application, determine the target device resource information from the target device driver; and Update the device resource usage count.
7. The equipment resource management method as described in claim 6, characterized in that, It also includes: When the device resource usage count equals a target value, the device resources corresponding to the at least one device resource information are released, and the at least one device resource information is removed from the at least one device driver.
8. An electronic device, characterized in that, The electronic device executes at least two applications and includes: A memory is used to store a first list and a second list, the first list containing at least one application resource information, the second list containing at least one device driver, the at least one application resource information corresponding to the at least one device driver, and each device driver corresponding to at least one device resource information; An application circuit; and A processing circuit, coupled to the memory and the application circuit, is used to perform the following steps: Execute a target application program corresponding to the application circuit, wherein the target application program is one of the applications; In response to an abnormal exit procedure of the target application, a target application resource information corresponding to the target application is found from the first list, wherein the target application resource information is one of the at least one application resource information; A target device driver is determined based on the target application resource information; and Remove a target device resource information corresponding to the target device driver from the second list.
9. The electronic device as claimed in claim 8, characterized in that, The at least one device resource information includes one level, and the step of deleting the target device resource information corresponding to the target device driver from the second list includes: Check the level of the target device resource information; When the level is a target value, the target device resource information corresponding to the target device driver is deleted from the second list.
10. The electronic device as claimed in claim 8, characterized in that, The target application resource information includes a number of device resources, and the processing circuit further performs the following steps: After deleting the target device resource information corresponding to the target device driver from the second list, the number of device resources is updated; and When the number of device resources equals a target value, the target application resource information is deleted from the first list.
11. An electronic device, characterized in that, Execute at least two applications and include: A memory is used to store a first list and a second list, the first list containing at least one application resource information, the second list containing at least one device driver, the at least one application resource information corresponding to the at least one device driver, and each device driver corresponding to at least one device resource information; An application circuit; and A processing circuit, coupled to the memory and the application circuit, is used to perform the following steps: Execute a target application program corresponding to the application circuit, wherein the target application program is one of the applications; Create a target application resource information for the target application in the first list; Based on the target application resource information, identify a target device driver associated with the target application; as well as When the target device driver does not contain target device resource information, the target device resource information is created. The target device resource information corresponds to the target device driver and is recorded in the information of the device resources used by the target device driver.
12. The electronic device as claimed in claim 11, characterized in that, The at least one device resource information includes a device resource usage count, and the processing circuit further performs the following steps: When the target device driver contains the target device resource information, the device resource usage count is updated.
13. The electronic device as claimed in claim 11, characterized in that, The target device resource information includes a device resource usage count, and the processing circuit further performs the following steps: In response to a normal exit procedure of the target application, the target device resource information is retrieved from the target device driver; and Update the device resource usage count.
14. The electronic device as claimed in claim 13, characterized in that, The processing circuit then performs the following steps: When the device resource usage count equals a target value, the device resources corresponding to the at least one device resource information are released, and the at least one device resource information is removed from the at least one device driver.
15. The electronic device as claimed in claim 13, characterized in that, The processing circuit then performs the following steps: In response to an abnormal exit procedure of the target application, the target application resource information corresponding to the target application is retrieved from the first list; The target device driver is determined based on the target application resource information; as well as Remove the target device resource information from the second list.
Citation Information
Patent Citations
Equipment driving method and device and electronic equipment
CN115718625A
Device Driver Non-Volatile Backing-Store Installation
US20190220260A1