Memory management method, gating device and computer program product
By adopting a coexistence solution of RTOS and Linux systems in the gate control device of smart video door locks, and marking RTOS free memory blocks to improve memory utilization, the problem of fast startup of smart video door locks is solved, achieving efficient memory management and function success rate.
Patent Information
- Application Number
- CN202411745367.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-25
AI Technical Summary
Smart video door locks need to quickly obtain video streams when starting, but the startup time of Linux system is long, which makes it impossible to meet the requirements of fast startup.
In the gated device, the coexistence of RTOS system and Linux system are adopted. RTOS is responsible for the startup of the image sensor and video streaming, while the Linux system reads the RTOS cached video frames for processing. At the same time, by marking RTOS free memory blocks and sending their information to the Linux system, the Linux system can manage these memory blocks uniformly to improve memory utilization.
It realizes the rapid start of smart video door locks, and improves the memory utilization rate and the success rate of application functions of Linux systems without increasing the memory cost of gated devices.
Smart Images

Figure CN119690861A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of smart home technology, and in particular to a memory management method, a door control device, and a computer program product. Background Art
[0002] At present, users' home devices are becoming more and more intelligent. Take smart video door locks as an example, which can realize functions such as video surveillance and face recognition. Considering that smart video door locks need to quickly start the video preview function, and the Linux system startup needs to go through the power-on self-test, kernel boot, mount the file system, start the application and other operations, therefore, if the Linux system runs the video stream startup, it will take about 2 seconds after the smart video door lock is turned on to normally obtain the video stream and display it. That is, the above method cannot meet the needs of devices such as smart video door locks that need to start and record videos quickly.
[0003] Compared with the Linux system, considering that the real-time operating system (RTOS) has the advantages of strong real-time performance, small resource usage, small kernel, and fast startup speed, the RTOS system and the Linux system can be placed on the same chip, and the RTOS system is responsible for the initialization of modules such as the startup of the image sensor, video streaming, and cached video frames. Since the RTOS system implements the module initialization work, the Linux system does not need to continue to perform the module initialization action, and the Linux system can read the video frames cached by the RTOS, and then perform corresponding processing on the read video frames, thereby solving the requirements of the smart video door lock for fast startup and the problem that the RTOS system cannot support complex upper-level applications.
[0004] However, when the smart video door lock is implemented using the RTOS system and the Linux system, there may be a low memory utilization rate. Summary of the invention
[0005] The embodiments of the present application provide a memory management method, a gate control device, and a computer program product, which can solve the problem of low memory utilization of existing gate control devices.
[0006] In a first aspect, an embodiment of the present application provides a memory management method, which is applied to a gate control device, including:
[0007] The first system marks a releasable memory block in a first memory, and determines first memory information according to the releasable memory block in the first memory, wherein the first memory is a memory pre-allocated for the first system;
[0008] The first system sends the first memory information to the second system;
[0009] The second system uniformly manages the memory block pointed to by the first memory information and the second memory, wherein the second memory is the memory pre-allocated to the second system.
[0010] In a second aspect, an embodiment of the present application provides a door control device, including a first system and a second system.
[0011] The first system marks a releasable memory block in a first memory to obtain first memory information, wherein the first memory is a memory pre-allocated for the first system;
[0012] The first system sends the first memory information to the second system, wherein the startup time of the first system is shorter than the startup time of the second system;
[0013] The second system uniformly manages the memory block pointed to by the first memory information and the second memory, wherein the second memory is the memory pre-allocated to the second system.
[0014] In a third aspect, an embodiment of the present application provides a computer program product. When the computer program product runs on a gate control device, the gate control device executes the method described in the first aspect above.
[0015] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0016] In an embodiment of the present application, since the first system marks the releasable memory block in the first memory allocated to it and sends the first memory information corresponding to the releasable memory block to the second system, so that the second system can uniformly manage the memory block pointed to by the first memory information and the second memory pre-allocated to the second system, the memory managed by the second system is increased, that is, the memory that the second system can control is increased without increasing the memory of the gate control device, thereby improving the memory utilization without increasing the memory cost, and improving the success rate of the second system in realizing its application function. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.
[0018] Figure 1 It is a flowchart of a memory management method provided by an embodiment of the present application;
[0019] Figure 2 It is a schematic diagram of a releasable memory block that merges a first memory and a shared memory provided by an embodiment of the present application;
[0020] Figure 3 It is a schematic diagram of a process of marking and merging releasable memory provided by an embodiment of the present application;
[0021] Figure 4 It is a structural schematic diagram of a door control device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0022] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0023] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0024] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0025] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0026] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways.
[0027] At present, the degree of intelligence of home appliances is getting higher and higher. Take door control devices (such as smart video door locks or smart doorbells) as an example, which can collect video data and determine whether there are visitors by analyzing the video data.
[0028] Considering that the Linux system takes a long time to start up but has richer functions, while the RTOS system takes a short time to start up but is lighter, the Linux system and the RTOS system can be installed on the same door control device. Specifically, independent memory is allocated to the Linux system and the RTOS system respectively. The RTOS system starts first using the memory allocated to itself and is responsible for system initialization and the execution of real-time tasks. Then the Linux system starts using the memory allocated to itself. The started Linux system can directly obtain the data obtained after the RTOS system executes the real-time task, so that the door control device can support complex upper-layer applications and shorten the startup time.
[0029] Since the upper-layer application is installed in the Linux system, and the upper-layer application is usually more complex and requires more memory resources, the memory pre-allocated to the Linux system may be difficult to meet the memory requirements of the Linux system. To solve this problem, the functions of the upper-layer application can be cut to reduce the memory required by the upper-layer application, or the memory allocated to the Linux system can be increased by increasing the memory of the gate control device. However, cutting the functions of the upper-layer application may lead to a poor user experience, and increasing the memory of the gate control device will increase the cost of the gate control device. In other words, no matter which solution is used, it is difficult to meet the requirements of users and gate control device manufacturers at the same time.
[0030] In an embodiment of the present application, the free memory blocks of the RTOS system are allocated to the Linux system for use. In this way, there is no need to directly increase the memory of the entire gate control device, and the memory that can be used by the Linux system can be increased, thereby greatly improving the memory utilization efficiency of the gate control device without increasing the cost of the gate control device.
[0031] The memory management method provided in the embodiment of the present application is described below with reference to the accompanying drawings.
[0032] Figure 1 The flowchart of a memory management method provided by an embodiment of the present application is shown. The memory management method can be applied to door control devices, such as smart video door locks, smart doorbells, etc. The memory management method includes a first system that pre-allocates a first memory and a second system that pre-allocates a second memory. The first system here can be an RTOS system, and the second system can be a Linux system. The interaction between the first system and the second system is as follows:
[0033] S11, the first system marks a releasable memory block in the first memory, and determines first memory information according to the releasable memory block in the first memory, wherein the first memory is a memory pre-allocated for the first system.
[0034] In the embodiment of the present application, the first memory is a memory pre-allocated for the first system, and the first memory includes a plurality of memory blocks. The releasable memory blocks refer to memory blocks that the first system does not need to use, which may include, at least, memory blocks that are not currently occupied by any task, and may also include memory blocks that have been used but released.
[0035] In an embodiment of the present application, whether the corresponding memory block is releasable can be marked by setting a flag bit for the memory area to indicate whether it is releasable. For example, when the flag bit is "1", it means that the memory block corresponding to the flag bit is releasable. Then, the above-mentioned first memory information is determined based on the memory blocks corresponding to the flag bits "1", wherein the first memory information may include location information, size information, etc. of the memory blocks corresponding to the flag bits "1".
[0036] S12, the first system sends the first memory information to the second system.
[0037] Specifically, information transmission is achieved between the first system and the second system through inter-process communication (IPC).
[0038] Among them, the IPC mechanisms here include: shared memory (Memory Mapping, mmap) (or MMA), named pipe (Named Pipe, FIFO) and message queue (Message Queue) and so on.
[0039] The above-mentioned MMA shared memory allows a process to map part of a file or device into the virtual memory space of the process, that is, the process can directly access the content of the mapped object without performing traditional read and write operations. In other words, MMA shared memory can improve the efficiency of file access, especially for random access or frequent read and write scenarios.
[0040] The above-mentioned FIFO allows communication between unrelated processes. It is a first-in-first-out queue, and its communication is half-duplex.
[0041] The above message queue allows processes to communicate in the form of messages, which can be fixed or variable length.
[0042] S13, the second system uniformly manages the memory block pointed to by the first memory information and the second memory, wherein the second memory is a memory pre-allocated to the second system.
[0043] The unified management here means that the second system has management authority over the memory block pointed to by the first memory information and the second memory. When the second system has management authority over the memory block pointed to by the first memory information, the first system does not have management authority over the memory block pointed to by the first memory information.
[0044] In the embodiment of the present application, when the second system has the management authority of the memory block pointed to by the first memory information, it can allocate the memory block to the application of the second system for use. When the second system is Linux, if the Linux system uses the buddy system algorithm to manage the memory, the second system can transfer the memory block pointed to by the first memory information to the buddy system algorithm for management. The buddy system algorithm can maintain effective management of the original Linux memory (i.e., the second memory) on the basis of the newly added management of the memory block pointed to by the first memory information. That is, on the basis of the newly added memory block to be managed by the buddy system algorithm, it will not affect the management of the original Linux memory.
[0045] The buddy system algorithm is an algorithm used to manage memory allocation and release. It is widely used in the Linux kernel. Its design goal is to manage memory fragmentation efficiently and have fast allocation and release speed. In the buddy system algorithm, all free page frames are grouped into 11 block lists, each of which contains 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 and 1024 consecutive page frames. The maximum request for 1024 page frames corresponds to a 4MB continuous RAM block. The physical address of the first page frame of each block is an integer multiple of the block size. For example, the starting address of a block of 16 page frames is a multiple of 16*2^12=16*4096 (this is the size of a regular page). Assuming a block of 256 page frames is requested, the algorithm first checks whether there is a free block in the list of 256 page frames. If there is no such block, the algorithm looks for the next larger page block, that is, a free block in the linked list of 512 page frames. If such a block exists, the kernel divides the 256 page frames into two equal parts, half of which is used to satisfy the request, and the other half is inserted into the linked list of 256 page frames. If no free block is found in the linked list of 512 page frames, the algorithm continues to look for a larger block - a block of 1024 page frames. If such a block exists, the kernel uses 256 page frames of the 1024 page frame block as the request, and then takes 512 of the remaining 768 page frames and inserts them into the linked list of 512 page frames, and then inserts the last 256 into the linked list of 256 page frames. If the linked list of 1024 page frames is still empty, the algorithm gives up and signals an error. In short, when an application releases memory, the Linux kernel operating system first reclaims the memory, and then checks whether the memory adjacent to the memory is of the same size and is also in an idle state. If so, the two pieces of memory are merged, and then the application recursively performs the same check.
[0046] In an embodiment of the present application, since the first system marks the releasable memory block in the first memory allocated to it and sends the first memory information corresponding to the releasable memory block to the second system, so that the second system can uniformly manage the memory block pointed to by the first memory information and the second memory pre-allocated to the second system, the memory managed by the second system is increased, that is, the memory that the second system can control is increased without increasing the memory of the gate control device, thereby improving the memory utilization without increasing the memory cost, and improving the success rate of the second system in realizing its application function.
[0047] In some embodiments, the above S11 includes:
[0048] After being started stably, the first system searches for unused memory blocks in the first memory, marks the found memory blocks as the releasable memory blocks, and determines the first memory information according to the releasable memory blocks.
[0049] Among them, the first system startup is stable means that the first system enters the ready state (also called IDLE state). Specifically, after the door control device is powered on, the boot module used for booting will be loaded, such as loading the two boot modules IPL (Initial Program Loader) and IPL_CUST (Customer IPL). Loading the IPL boot module is the first stage of system startup. The IPL boot module is responsible for minimally configuring the hardware in order to create an environment that allows subsequent programs to run, such as initializing some common hardware modules. IPL_CUST is a customized version of IPL, which will be personalized according to the specific hardware configuration.
[0050] After loading the boot module, the first system is started and initialized (e.g., the code originally initialized in the sensor driver code is ported to the system hardware initialization to save the time required for sensor initialization and increase the speed of presenting video data), and an audio and video pipeline is created in the first system. The pipeline allows developers to connect the steps of audio and video data collection, processing, encoding, decoding and playback in series to form a continuous processing flow. After creating the audio and video pipeline, it is equivalent to the first system entering the IDLE state, after which the second system can be started.
[0051] In an embodiment of the present application, the first system can record the usage of the first memory by maintaining a memory allocation table. According to the usage of the memory recorded in the memory allocation table, it can be determined which memory blocks in the first memory are still currently in use and which blocks have not been used for a long time. According to the usage of each memory block in the first memory, the memory blocks that are not currently in use can be marked as releasable memory blocks, or the memory blocks that have not been used within a preset time period up to the current moment can be marked as releasable memory blocks. Since the first system usually does not have new memory usage requirements after the first system starts and stabilizes, marking the releasable memory blocks after the first system starts and stabilizes is conducive to improving the accuracy of the obtained first memory information.
[0052] It is described above that the first system marks an unused memory block as a releasable memory block. In some embodiments, the first system may also mark a memory block that was used but released as a releasable memory block. In this case, the above S11 includes:
[0053] After being started stably, the first system searches for memory blocks in the first memory that are released after the task is completed, marks the found memory blocks as the releasable memory blocks, and determines the first memory information according to the releasable memory blocks.
[0054] The task here refers to the task executed by the first system. For example, after the first system executes the face recognition task and releases the corresponding memory block, the memory block occupied by the face recognition task in the first memory can be marked as a releasable memory block.
[0055] In the embodiment of the present application, a memory allocation table can be maintained to record the allocation and release of the first memory, and which memory blocks have been released can be determined based on the allocation and release. At this time, the memory blocks that have been released in the first memory can be marked as releasable memory blocks. Since after the first system is started and stabilized, the first system usually does not have new memory usage requirements, that is, the memory blocks released after the first system is started and stabilized are usually not used. Therefore, marking the memory blocks released at this time as releasable memory blocks is conducive to improving the accuracy of the obtained first memory information.
[0056] In some embodiments, considering that a larger memory block is beneficial for data storage, and the number of releasable memory blocks may be greater than 1, when there are adjacent memory blocks in the releasable memory blocks, these adjacent memory blocks may be merged, that is, when the number of the releasable memory blocks is greater than 1, the found memory blocks are marked as the releasable memory blocks, and the first memory information is determined according to the releasable memory blocks, including:
[0057] A1. In the case where there are adjacent memory blocks in each of the above-mentioned releasable memory blocks, the above-mentioned adjacent memory blocks are merged.
[0058] A2. Determine the first memory information according to the merged memory block, or determine the first memory information according to the merged memory block and the unmerged memory block.
[0059] Specifically, whether two memory blocks are adjacent memory blocks can be determined based on the starting address and the ending address of the memory blocks. For example, when the ending address of one memory block is the starting address of another memory block, it indicates that the two memory blocks are adjacent memory blocks. After merging the adjacent memory blocks, a continuous physical memory area can be obtained, that is, a larger memory area is obtained, and a larger memory area is conducive to data storage.
[0060] In an embodiment of the present application, if the releasable memory blocks are multiple adjacent memory blocks, all memory blocks can be merged, and the first memory information is subsequently determined based on the merged memory blocks (i.e., a continuous physical memory area). If there are both adjacent memory blocks and non-adjacent memory blocks in the releasable memory blocks, after the adjacent memory blocks are merged, the first memory information is determined based on the merged memory blocks and the non-adjacent memory blocks that are not merged. Since the first memory information is determined in a corresponding manner according to the merging situation of each memory block, it is beneficial to improve the accuracy of the determined first memory information.
[0061] It should be noted that if all releasable memory blocks are non-adjacent memory blocks, the first memory information is directly determined according to all non-adjacent memory blocks.
[0062] The above describes how the first system marks releasable memory in its pre-allocated first memory. Considering that the gate control device also allocates a common memory (i.e., the shared memory described below) to the first system and the second system, the first system may also mark releasable memory in the shared memory to further increase the memory of the second system. That is, in some embodiments, the above memory management method further includes:
[0063] The first system marks a releasable memory block of the shared memory after being started stably, and determines the second memory information according to the releasable memory block of the shared memory. The shared memory is a shared memory pre-allocated for the first system and the second system.
[0064] Correspondingly, the first system sends the first memory information to the second system, including:
[0065] The first system sends the first memory information and the second memory information to the second system;
[0066] Correspondingly, the second system manages the memory block pointed to by the first memory information and the second memory in a unified manner, including:
[0067] The second system manages the memory block pointed to by the first memory information, the second memory, and the memory block pointed to by the second memory information in a unified manner.
[0068] In the embodiment of the present application, shared memory refers to memory that can be accessed by both the first system and the second system, and the shared memory is mainly used to cache the video stream and audio stream acquired by the first system. In the shared memory, in addition to the memory blocks occupied by the cached video stream and audio stream, other memory blocks can be used jointly by the first system and the second system. Considering that under the current business, after the first system runs stably, there is usually no new memory usage demand, therefore, in the shared memory, in addition to the memory blocks occupied by the cached video stream and audio stream, the memory blocks can be marked as releasable memory blocks, so that the second system can perform unified management and use in the future.
[0069] In the embodiment of the present application, the information corresponding to the memory block marked by the first system in the shared memory is the second memory information. After the first system determines the first memory information and the second memory information, the first system can choose to send the first memory information to the second system first, or can choose to send the second memory information to the second system first, or can choose to send the first memory information and the second memory information to the second system at the same time.
[0070] In some embodiments, the first system sends the first memory information and the second memory information to the second system, including:
[0071] B1. In the case where the memory block pointed to by the first memory information and the memory block pointed to by the second memory information are adjacent memory blocks, merge the adjacent memory blocks.
[0072] B2. The first system determines merged memory information based on the merged memory blocks, and sends the merged memory information to the second system; alternatively, the first system obtains merged memory information based on the merged memory blocks and unmerged memory blocks, and sends the merged memory information to the second system.
[0073] Specifically, in order to isolate the first system and the second system and prevent malware or unauthorized access of one system from damaging the other system, a shared memory is set between the first memory and the second memory, and the memory blocks at the junction of the shared memory and the first memory belong to adjacent memory blocks, and the memory blocks at the junction of the shared memory and the second memory also belong to adjacent memory blocks.
[0074] In an embodiment of the present application, it is determined whether there are adjacent memory blocks in each memory block pointed to by the first memory information, and if so, the adjacent memory blocks in each memory block pointed to by the first memory information are merged; it is determined whether there are adjacent memory blocks in each memory block pointed to by the second memory information, and if so, the adjacent memory blocks in each memory block pointed to by the second memory information are merged; it is determined whether there are adjacent memory blocks in each memory block pointed to by the first memory information (or the first memory information obtained after the adjacent memory is merged) and each memory block pointed to by the second memory information (or the second memory information obtained after the adjacent memory is merged) are adjacent memory blocks, and if so, the adjacent memory blocks are merged. When each memory block pointed to by the first memory information and each memory block pointed to by the second memory information can be merged into one or more continuous physical memory areas (each continuous physical memory area includes at least 2 memory blocks), the first system determines the merged memory information according to the merged memory blocks, and the merged memory information may include the starting address and the ending address of each continuous physical memory area, and may also include the number of memory blocks included, etc. When the memory blocks pointed to by the first memory information and the memory blocks pointed to by the second memory information cannot be merged into one or more continuous physical memory areas, for example, after merging the memory blocks, a continuous physical memory area and a memory block are obtained, then the merged memory information is determined based on the continuous physical memory area (i.e., the merged memory block) and the memory block (i.e., the unmerged memory block).
[0075] Of course, if there are no adjacent memory blocks to the memory blocks pointed to by the first memory information or the second memory information, the non-adjacent memory blocks are not merged.
[0076] In an embodiment of the present application, since there are adjacent memory blocks between the memory block pointed to by the first memory information and the memory block pointed to by the second memory information, the adjacent memory blocks are merged and the merged memory information is determined based on the merged memory blocks. Therefore, after the first system sends the merged memory information to the second system, the second system does not need to merge the memory blocks pointed to by the received merged memory information again, thereby improving the management efficiency of the memory blocks by the second system.
[0077] In order to more clearly describe the process of the first system merging the adjacent memory blocks pointed to by the first memory information and the memory blocks pointed to by the second memory information, the following is combined with Figure 2 Give a description.
[0078] exist Figure 2In the example, the block where the first system is located represents the first memory (e.g., 8M) pre-allocated for the first system, the block where the second system is located represents the second memory (e.g., 42M) pre-allocated for the second system, and the shared memory (e.g., 78M) is located between the first memory and the second memory. If the memory block marked as releasable by the first system in the first memory is Figure 2 The area formed by the dotted line of the first memory and the boundary line (i.e., the boundary line between the first memory and the shared memory) in the shared memory is as follows: Figure 2 The area formed by the dotted line and the boundary line of the shared memory in the second system is merged, and the obtained merged memory information is sent to the second system. In this way, the second system can not only allocate the second memory, but also manage and allocate the memory block pointed to by the merged memory information.
[0079] In some embodiments, considering that after the first system runs stably, there may be a situation where a memory block needs to be used, therefore, in order to reduce the probability of a conflict between the first system and the second system using the memory block, the memory block marked as releasable may be locked. In this case, the above memory management method further includes:
[0080] The first system locks and marks the releasable memory block, wherein the lock mark is used to indicate that tasks of the first system cannot apply for the locked memory block.
[0081] The releasable memory blocks include memory blocks marked as releasable in the first memory and memory blocks marked as releasable in the shared memory.
[0082] In the embodiment of the present application, the memory blocks with lock marks are in the allocated occupied state for the first system, so the tasks of the first system will not apply for the memory blocks with lock marks, but these memory blocks are not locked for the second system, but are in the unoccupied state, so the tasks of the second system can apply for these memory blocks. Since the first system locks the releasable memory blocks, the probability of the tasks of the first system applying for the use of these locked marked memory blocks is very low, so when the tasks of the second system apply for these locked marked memory blocks, the probability of the second system conflicting with the first system is effectively reduced.
[0083] In order to more clearly describe the marking and merging process of the freeable memory blocks, the following is combined with Figure 3 Describe it. Figure 3 In the example, the first system is RTOS and the second system is Linux.
[0084] S301, power on, that is, the door control device is powered on.
[0085] S302: Load an IPL boot module to initialize some common hardware modules.
[0086] S303, loading the IPL_CUST boot module for performing personalized settings according to the specific hardware configuration.
[0087] S304, start RTOS, which is responsible for initializing hardware devices, setting system clocks, starting necessary real-time tasks, etc. SYS module starts, initializing MMA shared memory
[0088] S305 , running MI_SYS, which is a part of the RTOS system and is used to implement system initialization, memory management, and management of data flows between modules.
[0089] S306, initializing the MMA memory, wherein the MMA memory is the above-mentioned shared memory.
[0090] S307, cache the video frames in the MMA. Specifically, the RTOS caches the collected video frames in the MMA. It should be noted that if the RTOS also collects audio frames, the audio frames are also cached in the MMA. Subsequently, Linux can extract the corresponding audio frames and / or video frames from the MMA, and use a preset algorithm to extract the audio frames and / or video frames. In addition, the Linux can also upload the extracted audio frames and / or video frames to the cloud for subsequent users to view.
[0091] S308, marking the free memory in the MMA memory. Specifically, the RTOS marks the free memory in the MMA as releasable memory.
[0092] S309, start Linux. After RTOS starts and runs stably, start Linux.
[0093] S310, detecting free memory and memory released by the task. The RTOS detects free memory in the first memory and memory released after the task is executed.
[0094] S311, merging the free memories and marking them as releasable. The RTOS merges all the free memories detected in the first memory and marks them as releasable memory blocks.
[0095] S312, merge the memory under RTOS and MMA into the partner management system of Linux. RTOS merges the releasable memory blocks marked in the first memory and MMA, and sends the corresponding merged memory information to the second system so that the second system takes over the memory block pointed to by the merged memory information.
[0096] S313, determine whether the memory merge is successful, if so, execute S16, if not, execute S314 and S315 respectively. Specifically, determine whether the second system takes over the memory block successfully, if not, return the memory block belonging to MMA in the memory block pointed to by the merged memory information to MMA, and return the memory block belonging to RTOS in the memory block pointed to by the merged memory information to RTOS, and unlock these memory blocks when there are lock marks, so that RTOS and MMA can use them.
[0097] S314: Return the memory to the MMA and release the locked state.
[0098] S315, returning the memory to the RTOS and releasing the locked state.
[0099] S316, merge successful.
[0100] In some embodiments, considering that the second system may fail to take over the memory block, after the first system sends the first memory information to the second system, the method further includes:
[0101] After the second system fails to uniformly manage the memory block pointed to by the first memory information and the second memory, the second system sends corresponding notification information to the first system.
[0102] In an embodiment of the present application, if an error occurs in the operation of the second system, such as an operation interruption, the second system may fail to take over the memory block pointed to by the first memory information. At this time, in order to improve the utilization efficiency of the memory block marked as releasable, the second system sends a notification message containing a takeover failure to the first system. In this way, the first system can cancel the relevant mark of the corresponding memory block, such as canceling the mark that marks the memory block as a releasable memory block, such as canceling the lock mark of the memory block, etc. Through the above processing, it is beneficial to improve the probability of stable operation of the first system when an exception occurs during the memory sharing process.
[0103] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0104] Corresponding to the memory management method described in the above embodiment, Figure 4 A structural block diagram of a door control device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0105] Reference Figure 4 The door control device includes a first system 41 and a second system 42.
[0106] The first system 41 marks a releasable memory block in the first memory to obtain first memory information, wherein the first memory is a memory pre-allocated for the first system 41;
[0107] The first system 41 sends the first memory information to the second system 42, wherein the startup time of the first system 41 is shorter than the startup time of the second system 42;
[0108] The second system 42 manages the memory block pointed to by the first memory information and the second memory in a unified manner, wherein the second memory is a memory pre-allocated to the second system 42 .
[0109] In the embodiment of the present application, since the first system 41 marks the releasable memory block in the first memory allocated to it, and sends the first memory information corresponding to the releasable memory block to the second system 42, so that the second system 42 can uniformly manage the memory block pointed to by the first memory information and the second memory pre-allocated to the second system 42, the memory managed by the second system 42 is increased, that is, the memory that the second system 42 can control is increased without increasing the memory of the gate control device, thereby improving the memory utilization without increasing the memory cost, and improving the success rate of the second system 42 in realizing its application function.
[0110] In some embodiments, the first system 41 marks a releasable memory block in the first memory, and determines the first memory information according to the releasable memory block in the first memory, including:
[0111] After being started and stabilized, the first system 41 searches for unused memory blocks in the first memory, marks the found memory blocks as the releasable memory blocks, and determines the first memory information according to the releasable memory blocks.
[0112] In some embodiments, the first system 41 marks a releasable memory block in the first memory, and determines the first memory information according to the releasable memory block in the first memory, including:
[0113] After being started stably, the first system 41 searches for memory blocks released after the task in the first memory is completed, marks the found memory blocks as the releasable memory blocks, and determines the first memory information according to the releasable memory blocks.
[0114] In some embodiments, the number of the releasable memory blocks is greater than 1, the found memory blocks are marked as the releasable memory blocks, and the first memory information is determined according to the releasable memory blocks, including:
[0115] In the case where there are adjacent memory blocks in each of the releasable memory blocks, merging the adjacent memory blocks;
[0116] The first memory information is determined according to the merged memory block, or the first memory information is determined according to the merged memory block and the unmerged memory block.
[0117] In some embodiments, the memory management method further includes:
[0118] The first system 41 marks a releasable memory block of the shared memory after being started stably, and determines the second memory information according to the releasable memory block of the shared memory, wherein the shared memory is a shared memory pre-allocated for the first system 41 and the second system 42;
[0119] Correspondingly, the first system 41 sends the first memory information to the second system 42, including:
[0120] The first system 41 sends the first memory information and the second memory information to the second system 42;
[0121] Correspondingly, the second system 42 manages the memory block pointed to by the first memory information and the second memory in a unified manner, including:
[0122] The second system 42 manages the memory block pointed to by the first memory information, the second memory, and the memory block pointed to by the second memory information in a unified manner.
[0123] In some embodiments, the first system 41 sends the first memory information and the second memory information to the second system 42, including:
[0124] In the case where the memory block pointed to by the first memory information and the memory block pointed to by the second memory information have adjacent memory blocks, merging the adjacent memory blocks;
[0125] The first system 41 obtains merged memory information based on the merged memory blocks and sends the merged memory information to the second system 42. Alternatively, the first system 41 obtains merged memory information based on the merged memory blocks and unmerged memory blocks and sends the merged memory information to the second system 42.
[0126] In some embodiments, the memory management method further includes:
[0127] The first system 41 locks the releasable memory block, wherein the lock mark is used to indicate that the task of the first system 41 cannot apply for the locked memory block.
[0128] In some embodiments, after the first system 41 sends the first memory information to the second system 42, the method further includes:
[0129] After the second system 42 fails to uniformly manage the memory block pointed to by the first memory information and the second memory, the second system 42 sends corresponding notification information to the first system 41 .
[0130] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0131] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0132] An embodiment of the present application also provides a network device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, wherein the processor implements the steps in any of the above-mentioned method embodiments when executing the computer program.
[0133] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0134] An embodiment of the present application provides a computer program product. When the computer program product runs on a gate control device, the gate control device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0135] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium can at least include: any entity or device that can carry the computer program code to the camera / door control device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0136] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0137] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of 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.
[0138] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0139] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0140] It should be noted that the information collection process (such as face image collection process, fingerprint information collection process, etc.) / feature extraction process involved in this application is performed with the user's knowledge and permission, that is, the information collection process / feature extraction process complies with the requirements of laws and regulations and does not constitute an act that harms the public interest.
[0141] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A memory management method, characterized in that: Applied to door control equipment, including: The first system marks a releasable memory block in a first memory, and determines first memory information according to the releasable memory block in the first memory, wherein the first memory is a memory pre-allocated for the first system; The first system sends the first memory information to the second system; The second system uniformly manages the memory block pointed to by the first memory information and the second memory, wherein the second memory is the memory pre-allocated to the second system.
2. The memory management method according to claim 1, characterized in that: The first system marks a releasable memory block in the first memory, and determines first memory information according to the releasable memory block in the first memory, including: After the first system starts and becomes stable, it searches for unused memory blocks in the first memory, marks the found memory blocks as the releasable memory blocks, and determines the first memory information according to the releasable memory blocks.
3. The memory management method according to claim 1, characterized in that: The first system marks a releasable memory block in the first memory, and determines first memory information according to the releasable memory block in the first memory, including: After being started stably, the first system searches for memory blocks in the first memory that are released after the task is completed, marks the found memory blocks as the releasable memory blocks, and determines the first memory information according to the releasable memory blocks.
4. The memory management method according to claim 2 or 3, characterized in that: The number of the releasable memory blocks is greater than 1, the found memory blocks are marked as the releasable memory blocks, and the first memory information is determined according to the releasable memory blocks, including: In the case where there are adjacent memory blocks in each of the releasable memory blocks, merging the adjacent memory blocks; The first memory information is determined according to the merged memory block, or the first memory information is determined according to the merged memory block and the unmerged memory block.
5. The memory management method according to any one of claims 1 to 3, characterized in that: The memory management method further includes: The first system marks a releasable memory block of a shared memory after startup and stabilization, and determines second memory information according to the releasable memory block of the shared memory, wherein the shared memory is a shared memory pre-allocated for the first system and the second system; Correspondingly, the first system sends the first memory information to the second system, including: The first system sends the first memory information and the second memory information to the second system; Correspondingly, the second system uniformly manages the memory block pointed to by the first memory information and the second memory, including: The second system uniformly manages the memory block pointed to by the first memory information, the second memory, and the memory block pointed to by the second memory information.
6. The memory management method according to claim 5, characterized in that: The first system sends the first memory information and the second memory information to the second system, including: In the case where the memory block pointed to by the first memory information and the memory block pointed to by the second memory information have adjacent memory blocks, merging the adjacent memory blocks; The first system obtains merged memory information based on the merged memory blocks and sends the merged memory information to the second system, or the first system obtains merged memory information based on the merged memory blocks and unmerged memory blocks and sends the merged memory information to the second system.
7. The memory management method according to any one of claims 1 to 6, characterized in that: The memory management method further includes: The first system locks and marks the releasable memory block, wherein the lock mark is used to indicate that tasks of the first system cannot apply for the locked memory block.
8. The memory management method according to any one of claims 1 to 6, characterized in that: After the first system sends the first memory information to the second system, the method further includes: After the second system fails to uniformly manage the memory block pointed to by the first memory information and the second memory, the second system sends corresponding notification information to the first system.
9. A door control device, comprising a first system and a second system, characterized in that: The first system marks a releasable memory block in a first memory to obtain first memory information, wherein the first memory is a memory pre-allocated for the first system; The first system sends the first memory information to the second system, wherein the startup time of the first system is shorter than the startup time of the second system; The second system uniformly manages the memory block pointed to by the first memory information and the second memory, wherein the second memory is the memory pre-allocated to the second system.
10. A computer program product, characterized in that The invention comprises a computer program, which, when being executed, enables the method according to any one of claims 1 to 8 to be performed.