Data processing method and router

By creating a first thread in a router with an MTK7563 chip and using the first data to control access to shared resources, the problem of spinlocks being unusable was solved, router stability and data accuracy were improved, and system processing efficiency and response speed were enhanced.

CN121967362APending Publication Date: 2026-05-01HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HONOR DEVICE CO LTD
Filing Date
2024-10-31
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

When multiple operations occur simultaneously, the MTK7563 chip cannot introduce a spinlock mechanism, which leads to shared resource access conflicts, data corruption, and affects the stability and accuracy of the router.

Method used

By creating the first thread, determining whether the first data is a preset value to decide whether the first linked list can be referenced, and using the first data to adjust under specific conditions to ensure that the shared resource is accessed by only one task at a time, including restoring the data to the preset value after the operation is completed to release the resource.

Benefits of technology

This ensures the normal operation of the MTK7563 chip, improves the stability of the router system and the accuracy of shared resource data, reduces unnecessary CPU and memory resource consumption, and improves processing efficiency and response speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121967362A_ABST
    Figure CN121967362A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data processing method and a router, relates to the technical field of chips, and can ensure that shared resources are accessed by only one task at the same time when an MTK7563 chip is applied to the router. The method comprises the following steps: creating a first thread; determining whether the first data is a preset value; under the condition that the first data is the preset value, adjusting the first data, and updating the first linked list by utilizing the first thread; the first linked list comprises traffic data of at least one device; the preset value is used for representing that the first linked list is not referenced currently; after the first linked list is updated, controlling the first data to recover to a preset value; under the condition that the first data is not the preset value, the first thread cannot quote the first linked list.
Need to check novelty before this filing date? Find Prior Art

Description

A data processing method and router Technical Field

[0001] This disclosure relates to the field of chip technology, and in particular to a data processing method and a router. Background Technology

[0002] Spin locks, as a locking mechanism to prevent multiprocessor concurrency issues, ensure that shared resources are accessed by only one task at a time. The implementation of spin locks is relatively independent and does not rely on complex operating system kernel functions. Therefore, they can be easily integrated into various types of programs (such as operating system kernel code, drivers, and user-mode applications).

[0003] However, due to its different chip design compared to other chips, the introduction of spinlocks in first-generation chips (such as the MTK7563 chip) can lead to malfunctions. Therefore, for the MTK7563 chip, ensuring that shared resources can only be accessed by one task at a time is a pressing issue that needs to be addressed. Summary of the Invention

[0004] The embodiments of this disclosure provide a data processing method and a router. When the router uses the MTK7563 chip, it can ensure that shared resources are accessed by only one task at a time.

[0005] To achieve the above objectives, the embodiments of this disclosure adopt the following technical solutions:

[0006] In a first aspect, embodiments of this disclosure provide a data processing method applied to a router, the method comprising: creating a first thread; determining whether first data is a preset value; if the first data is a preset value, adjusting the first data and updating a first linked list using the first thread; the first linked list including traffic data of at least one device; after the first linked list is updated, controlling the first data to be restored to a preset value; if the first data is not a preset value, the first thread cannot access the first linked list.

[0007] Based on this scheme, the router can create a first thread. When the first thread needs to access the first linked list, it determines whether the first linked list can be referenced by checking if the first data is a preset value. If the first data is a preset value, it means the first linked list is not currently referenced, so the first thread can reference it. If the first data is not a preset value, it means the first linked list is currently referenced, so the first thread cannot reference it.

[0008] Therefore, when the first data is a preset value, it can be adjusted first. This way, the first data will no longer be the preset value, preventing other programs from accessing the first linked list while the first thread is referencing it. After the first linked list is no longer in use (e.g., after an update), the first data can be restored to the preset value. This effectively releases the resources of the first linked list, making it easier for other programs to access it. In other words, this disclosure ensures that shared resources (e.g., the first linked list) can only be accessed by one task at a time by using the first data. This not only ensures the router operates normally but also guarantees the stability of the router system and the accuracy of shared resource data.

[0009] In conjunction with the first aspect, another possible implementation involves the first thread updating the first linked list, including: the first thread accessing the first linked list and obtaining attribute information for at least one device; the attribute information for at least one device includes the MAC address of at least one device; based on the MAC address of at least one device, obtaining traffic data for at least one device through a preset query interface; and updating the traffic data of at least one device in the first linked list based on the MAC address and traffic data of at least one device. Based on this scheme, the traffic data of at least one device can be monitored and updated in a timely manner, improving the accuracy of the data in the first linked list.

[0010] In conjunction with the first aspect, another possible implementation method further includes: detecting a first event; the first event being used to characterize the first device going online or the first device going offline; obtaining the attribute information and event identifier of the first device based on the first event, and inserting the attribute information and event identifier of the first device into a second linked list; the second linked list includes the attribute information and event identifier of at least one device, the event identifier of at least one device being used to characterize the online or offline status of at least one device; after the first event is inserted into the second linked list, determining whether the first data is a preset value; if the first data is a preset value, adjusting the first data, and updating the first linked list based on the attribute information and event identifier of at least one device in the second linked list; after the first linked list is updated, controlling the first data to be restored to the preset value; if the first data is not a preset value, the first thread cannot access the first linked list.

[0011] Based on this scheme, device online or offline events are stored in a second linked list. This allows the system to monitor the dynamic changes of devices (i.e., connected devices) in real time and respond quickly. By inserting the attribute information and event identifier of the first device into the second linked list, the router can process the events in the second linked list in batches at specific times, thereby reducing frequent update operations and improving processing efficiency.

[0012] Furthermore, in this scenario, controlling access permissions to shared resources by checking if the first piece of data is a preset value ensures that no data races or inconsistencies occur during data updates. This significantly improves data consistency and security. Moreover, the first thread only triggers an update when the first piece of data is a preset value, avoiding unnecessary CPU and memory resource consumption and making the system run more efficiently.

[0013] In conjunction with the first aspect, another possible implementation involves updating the first linked list based on the attribute information and event identifier of at least one device in the second linked list. This includes: determining the processing result of at least one device based on its corresponding event identifier; the processing result of at least one device includes adding or deleting at least one device from the first linked list; and updating the first linked list based on the attribute information and processing result of at least one device. Based on this scheme, determining whether to add or delete a device from the first linked list based on its event identifier not only ensures real-time updates to the status of at least one device, enabling the first linked list to reflect the latest network status, but also avoids data redundancy, maintains the validity of the first linked list, and improves the efficiency of subsequent data processing.

[0014] In conjunction with the first aspect, another possible implementation method further includes: receiving a first request from the target program, the first request being used to request traffic data corresponding to a first address; responding to the first request, determining whether the first data is a preset value; if the first data is a preset value, setting and adjusting the first data, and a first thread retrieving the traffic data corresponding to the first address according to a first linked list; and sending the traffic data corresponding to the first address to the target program. Based on this scheme, when the first data is a preset value, the router can immediately process the first request and quickly send the traffic data corresponding to the first address to the target program, thus improving the system's response speed and user experience.

[0015] In conjunction with the first aspect, another possible implementation, after determining whether the first data is a preset value, further includes: if the first data is not a preset value, the first thread determines the historical traffic data corresponding to the first address; based on the historical traffic data corresponding to the first address, the predicted traffic data corresponding to the first address is determined. Based on this scheme, if the first data is not a preset value and the first linked list cannot be accessed, the target program can be responded to using the historical traffic data corresponding to the first address. This improves the system's fault tolerance and stability, ensuring a response even under high load or special circumstances (e.g., failure scenarios).

[0016] In conjunction with the first aspect, another possible implementation involves adjusting the first data, including: controlling the first data to increment; and controlling the first data to return to a preset value, including: controlling the first data to decrement, so that the first data returns to the preset value. Based on this scheme, controlling the first data through an increment mechanism ensures that the operation only occurs under specific conditions (i.e., the first data is at a preset value). Decrementing the first data to the preset value after the operation ensures that the first data correctly returns to its original position. This approach is simpler, more convenient, and more operable.

[0017] In conjunction with the first aspect, another possible implementation involves the router including a first chip, which is an MTK7563 chip. An example of such a chip is provided.

[0018] Secondly, embodiments of this disclosure provide a data processing apparatus that can be applied to a router to implement the method described in the first aspect. The functions of this data processing apparatus can be implemented in hardware or by executing corresponding software. The hardware or software includes one or more modules corresponding to the aforementioned functions, such as a creation module, a determination module, an update module, and a control module.

[0019] The module includes a creation module, configured to create a first thread; a determination module, configured to determine whether the first data is a preset value; an update module, configured to adjust the first data and update the first linked list using the first thread if the first data is a preset value; the first linked list includes traffic data of at least one device; the preset value is used to indicate that the first linked list is not currently referenced; a control module, configured to control the first data to be restored to the preset value after the first linked list is updated; and to prevent the first thread from referencing the first linked list if the first data is not a preset value.

[0020] In conjunction with the second aspect, in another possible implementation, the update module is also configured to have the first thread access the first linked list to obtain attribute information of at least one device in the first linked list; the attribute information of at least one device includes the MAC address of at least one device; based on the MAC address of at least one device, the traffic data of at least one device is obtained through a preset query interface; and based on the MAC address of at least one device and the traffic data of at least one device, the traffic data of at least one device is updated in the first linked list.

[0021] In conjunction with the second aspect, in another possible implementation, the data processing device further includes a monitoring module. The monitoring module is configured to monitor a first event; the first event represents the first device going online or offline. The update module is further configured to obtain the attribute information and event identifier of the first device based on the first event, and insert the attribute information and event identifier of the first device into a second linked list; the second linked list includes the attribute information and event identifier of at least one device, the event identifier of at least one device representing the online or offline status of at least one device. The determination module is further configured to determine whether the first data is a preset value after the first event is inserted into the second linked list. The update module is further configured to adjust the first data if it is a preset value, and the first thread updates the first linked list based on the attribute information and event identifier of at least one device in the second linked list. The control module is further configured to control the first data to return to the preset value after the first linked list is updated; if the first data is not a preset value, the first thread cannot access the first linked list.

[0022] In conjunction with the second aspect, in another possible implementation, the update module is further configured to determine the processing result of at least one device based on the event identifier corresponding to at least one device; the processing result of at least one device includes adding at least one device to the first linked list or deleting at least one device from the first linked list; and updating the first linked list based on the attribute information of at least one device and the processing result of at least one device.

[0023] In conjunction with the second aspect, in another possible implementation, the data processing device further includes a receiving module, an acquiring module, and a sending module. The receiving module is configured to receive a first request from the target program, the first request being for requesting the acquisition of traffic data corresponding to a first address; the determining module is further configured to, in response to the first request, determine whether the first data is a preset value; the acquiring module is configured to, if the first data is a preset value, adjust the first data, and a first thread acquires the traffic data corresponding to the first address according to a first linked list; the sending module is configured to send the traffic data corresponding to the first address to the target program.

[0024] In conjunction with the second aspect, in another possible implementation, the determining module is further configured to, when the first data is not a preset value, determine the historical traffic data corresponding to the first address by the first thread; and determine the predicted traffic data corresponding to the first address based on the historical traffic data corresponding to the first address.

[0025] In conjunction with the second aspect, in another possible implementation, the control module is also configured to control the first data to increment itself and control the first data to decrement itself, so that the first data is restored to a preset value.

[0026] In conjunction with the second aspect, in another possible implementation, the router includes a first chip, which is an MTK7563 chip.

[0027] Thirdly, this disclosure provides a router, including: a memory, a display screen, and one or more processors; the memory, the display screen, and the processors are coupled. The memory stores computer program code, including computer instructions; when the router is running, the processor executes one or more computer instructions stored in the memory to cause the router to perform a data processing method as described in any of the first aspects above.

[0028] Fourthly, this disclosure provides a computer storage medium including computer instructions that, when executed on a router, cause the router to perform a data processing method as described in any of the first aspects.

[0029] Fifthly, this disclosure provides a computer program product that, when run on a router, causes the router to perform a data processing method as described in any of the first aspects.

[0030] In a sixth aspect, an apparatus (e.g., a chip system) is provided, comprising a processor for supporting a first terminal device in implementing the functions described in the first aspect above. In one possible design, the apparatus further comprises a memory for storing program instructions and data necessary for the router. When the apparatus is a chip system, it may be composed of chips or may include chips and other discrete devices.

[0031] It should be understood that the beneficial effects of the second to sixth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description

[0032] Figure 1 is a schematic diagram of a scenario provided by an embodiment of this disclosure;

[0033] Figure 2 is a schematic diagram of the hardware structure of a router provided in an embodiment of this disclosure;

[0034] Figure 3 is a schematic flowchart of one of the data processing methods provided in this embodiment of the present disclosure;

[0035] Figure 4 is a second schematic flowchart of a data processing method provided in an embodiment of this disclosure;

[0036] Figure 5 is a schematic diagram of the structure of a chip system provided in an embodiment of this disclosure. Detailed Implementation

[0037] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this embodiment, unless otherwise stated, "a plurality of" means two or more.

[0038] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that “ / ” means “or,” for example, A / B can mean A or B; “and / or” in the text is merely a description of the relationship between related persons, indicating that three relationships can exist, for example, A and / or B can mean: A alone, A and B simultaneously, and B alone.

[0039] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application can be combined with other embodiments.

[0040] The directional terms mentioned in the embodiments of this application, such as "up", "down", "front", "back", "inner", "outer", "left", and "right", are only for reference to the direction of the accompanying drawings, or for better and clearer explanation and understanding of the embodiments of this application, and are not intended to indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the embodiments of this application.

[0041] In the description of embodiments of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0042] With the widespread adoption of internet technology, the internet has permeated every aspect of people's lives. Currently, common internet access methods include broadband internet access, fiber optic broadband internet access, and wireless internet access. Among these methods, the router plays a crucial role as a key device. For example, users can configure their internet access method through the router's wizard interface, thereby determining their internet access method.

[0043] In addition, some high-end routers may also have traffic statistics functionality, which can provide detailed statistics on the traffic data of each device connected to the router. In some scenarios, this traffic data can also be categorized and statistically analyzed according to different time periods. By reviewing the router's traffic statistics, users can gain a deeper understanding of network usage, thereby enabling network management and optimization. The router's traffic statistics function can be implemented using hardware acceleration technology on a system-on-a-chip (SoC).

[0044] Generally, when using SoC's hardware acceleration technology for traffic statistics, the router can query the traffic data of devices connected to the router (also known as downstream devices) through a dedicated interface provided by the SoC manufacturer. Conventional query methods are not applicable here. After retrieving the downstream device's traffic data through the dedicated interface, the downstream device's traffic data can be stored in a traffic information linked list (also known as a preset memory node). Subsequently, if the downstream device's traffic data changes, the traffic statistics module in the chip can obtain the latest traffic data from the downstream device through an update operation and update the traffic information linked list with the latest downstream device traffic data.

[0045] In addition, when the router receives a user's query command, the traffic statistics module in the chip can access the traffic information chain through the query operation, obtain the traffic data of the target device, and display the traffic data of the target device to the user so that the user can understand the network usage of the target device.

[0046] Understandably, devices connected to the router are not always online; they can go online or offline as needed. Once the connection status of a device connected to the router changes, the traffic statistics module in the chip must promptly update the corresponding traffic data for that device in the traffic information chain.

[0047] For example, when device A (e.g., a mobile phone) goes offline, the traffic statistics module in the chip can delete the traffic data of device A from the traffic information chain through a deletion operation. When device B (e.g., a tablet computer) comes online, the traffic statistics module in the chip can add the traffic data of device B to the traffic information chain through an addition operation.

[0048] In some scenarios, the operations performed by the traffic statistics module in the chip (i.e., update, query, delete, and add operations) may occur simultaneously, meaning there is a potential competition between these operations. Since these operations are all implemented at the router's kernel level, spinlocks are generally introduced to prevent data corruption when multiple operations occur simultaneously.

[0049] Spinlocks are extensively used in kernel interrupt handling. At any given time, a spinlock can be held by at most one task. If a task attempts to acquire a spinlock already held by another task, the router can instruct the task to repeatedly attempt to acquire the spinlock according to its spin wait time, waiting for the spinlock to become available again. If the spinlock is not held by any other task, the task requesting the spinlock can directly acquire it to access the shared resources protected by the spinlock.

[0050] Therefore, spinlocks can control competing interfaces when accessing the traffic information list (also known as a critical section), ensuring that only one operation is executed at a time (i.e., shared resources are accessed by only one task at a time), thus guaranteeing the integrity of traffic data. In this mode, when different SoC vendors adapt their systems, they only need to replace the encapsulated query interface to match their own data acquisition interface. This improves software scalability and compatibility, allowing different SoC vendors to easily integrate their hardware with the router's traffic statistics functionality.

[0051] However, when the router uses the MTK7563 chip as its primary chip, its design differs significantly from chips from other manufacturers. This presents a data corruption problem when multiple operations occur simultaneously using the MTK7563 chip, making a spinlock mechanism unsuitable. Spinlocks disable interrupts, and the MTK7563's traffic data processing interface is strongly dependent on interrupts; using a spinlock would cause the MTK7563 to malfunction. Therefore, when the router uses the MTK7563 chip, ensuring that shared resources can only be accessed by one task at a time without using spinlocks is a pressing issue that needs to be addressed.

[0052] To address the aforementioned issues, this application provides a data processing method applicable to routers using the MTK7563 chip. This router can create a first thread. When the first thread needs to access a first linked list, it determines whether the first linked list can be referenced by judging whether the first data is a preset value. If the first data is a preset value, it indicates that the first linked list is not currently referenced, so the first thread can reference it. If the first data is not a preset value, it indicates that the first linked list is currently referenced, so the first thread cannot reference it.

[0053] Therefore, when the first data is a preset value, it can be adjusted first. This way, the first data will no longer be the preset value, preventing other programs from accessing the first linked list when the first thread references it. After the first linked list is used (e.g., after it has been updated), the first data can be restored to the preset value. This effectively releases the resources of the first linked list, making it easier for other programs to access it. In other words, this disclosure ensures that shared resources (e.g., the first linked list) can only be accessed by one task at a time by using the first data. This not only ensures the normal operation of the MTK7563 chip but also guarantees the stability of the router system and the accuracy of shared resource data.

[0054] The data processing method provided in the embodiments of this application is described below.

[0055] For example, Figure 1 is a schematic diagram of an application scenario provided by an embodiment of this application. As shown in Figure 1, the application scenario includes: a terminal device and a router 200.

[0056] The terminal devices may include laptops 101, mobile phones 102, tablets 103, personal computers (PCs), ultra-mobile personal computers (UMPCs), handheld computers, netbooks, smart home devices (such as smart TVs, smart screens, large screens, smart speakers, smart air conditioners, etc.), personal digital assistants (PDAs), wearable devices (such as smartwatches, smart bracelets, etc.), in-vehicle devices, virtual reality devices, etc., and this application embodiment does not impose any limitations on them. The terminal devices may run operating systems and install and run various applications.

[0057] Router 200 provides wireless access for terminal devices. Terminal devices can access the wireless local area network (WLAN) provided by router 200, thereby further connecting to devices on various local area networks (LANs) and wide area networks (WANs) within the Internet. Each router 200 corresponds to a routing device identifier, which the terminal device can use to access the corresponding router 200. For example, the routing device identifier is a service set identifier (SSID).

[0058] Router 200 can forward the broadband network signal from your wall outlet to nearby Wi-Fi-enabled wireless network devices (i.e., terminal devices) via its antenna. Multiple terminal devices can access the Internet through router 200.

[0059] For example, Figure 2 is a schematic diagram of the hardware structure of a router provided in an embodiment of this application. As shown in Figure 2, the router 200 may include: a processor 210, a wireless communication module 220, a memory 230, a power module 240, a communication interface 250, a switch 260, and an antenna.

[0060] Processor 210 may include one or more processing units, such as CPU, GPU, DSP, ISP, AP, NPU, modem processor, controller, video codec, baseband processor, etc. In some embodiments, different processing units may be independent devices or integrated into one or more processors. The CPU is the final execution unit for information processing and program execution, and its main tasks include processing instructions, executing operations, controlling timing, and processing data. The CPU may include a controller, an arithmetic logic unit (ALU), a cache memory, and buses for connecting these components.

[0061] The wireless communication module 220 can provide wireless communication such as Wi-Fi, frequency modulation (FM), Bluetooth, or NFC. The wireless communication module 220 can be one or more devices integrating at least one communication processing module. The wireless communication module 220 receives electromagnetic waves via an antenna, performs frequency modulation and filtering of the electromagnetic wave signal, and sends the processed signal to the processor 210. The wireless communication module 220 can also receive signals to be transmitted from the processor 210, perform frequency modulation and amplification on them, and then convert them into electromagnetic waves for radiation via the antenna.

[0062] Memory 230 can be used to store computer executable program code, including computer instructions. Processor 210 performs various functions and data processing by executing the instructions stored in memory 230. Memory 230 may include a program storage area and a data storage area. The program storage area may store the application program required for at least one function (such as generating a key, sending a request, etc.). The data storage area may store target data, keys, etc., received from other devices. In addition, memory 230 may include high-speed random access memory, and may also include non-volatile memory, etc.

[0063] The power module 240 can be used to receive power input, store electrical energy, and supply power to the processor 210, wireless communication module 220, memory 230, etc.

[0064] The communication interface 250 can be used to communicate with external devices such as electronic devices, portable hard drives, and USB flash drives. The communication interface 250 can be any possible interface, such as a network port or a universal serial bus (USB) interface.

[0065] Switch 260 is used to trigger the router to turn on or off.

[0066] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. The specific embodiments below can be implemented independently or in combination with each other, and the same or similar concepts or processes may not be described again in some embodiments.

[0067] The following describes in detail a data processing method provided by an embodiment of this application with reference to FIG3. FIG3 is a schematic flowchart of a data processing method provided by an embodiment of this application. As shown in FIG3, the data processing method may include the following steps 301-315.

[0068] Step 301: After the router starts up, create the first thread.

[0069] The first thread is used to handle traffic statistics tasks and initialize the first and second linked lists. This first thread can also be called the kernel thread or the processing thread.

[0070] The first linked list can be a data structure used to record traffic statistics of devices connected to the router.

[0071] The first linked list includes at least one device (also known as a downstream device), the device's traffic information, and the device's attribute information.

[0072] The first linked list can also be called the traffic information linked list.

[0073] For example, the attribute information of a downstream device includes its Media Access Control (MAC) address and its network interface information. The MAC address is the physical address of the downstream device and is unique. The MAC address is used to identify the downstream device within the local area network (LAN). The network interface information refers to the configuration and status information of the downstream device's network interface. For example, the network interface information includes the IP address, subnet mask, network mask, interface status (e.g., whether it is enabled), and the maximum transmission unit (MTU) of the interface.

[0074] The second linked list can also be a data structure, and it can also be called an event linked list.

[0075] In some examples, as shown in Figure 4, after the router's system boots up, a first thread (i.e., a kernel thread) can be created based on a preset interface. For instance, the router's system can be a Linux-based operating system. The first thread can be created using the `kthread_create()` function. The first thread runs in kernel space and can execute multiple kernel tasks.

[0076] In some examples, once the first thread is created, it can initialize both the first and second linked lists. The process of initializing the first linked list may include: creating the head node of the first linked list; setting the initial values ​​of the first linked list; and setting the properties of the first linked list.

[0077] The head node of the first linked list can include basic information about the list, such as the list length and a pointer to the head node. The initial values ​​of the first linked list can include the number of nodes, at least one device, and the traffic statistics for that device. For example, the number of nodes can be set to a target value, the number of devices can be null, and the traffic statistics for the at least one device can be set to 0. When the first linked list needs to be accessed safely by multiple threads, its attributes can also be set. These attributes can include the lock, state, and flags of the first linked list, among other necessary properties.

[0078] The process of initializing the second linked list by the first thread may include: creating the head node of the second linked list; setting the initial state of the second linked list; and setting the attributes of the second linked list. The head node of the second linked list can be the head node of the event linked list. The attribute of the second linked list can be its lock. Other steps are similar to the initialization process of the first linked list and will not be repeated here.

[0079] After the first and second linked lists are initialized, the first thread can process the traffic statistics task in a loop according to a preset period until the thread is canceled.

[0080] Step 302: Based on the preset loop period, at the beginning of a loop, the first thread checks whether the first data (also known as the reference count) is the preset value.

[0081] After the first thread is created, it can perform preset actions according to a preset cycle. For example, the preset cycle could be 2 seconds. The preset actions could include obtaining traffic statistics information from the downstream devices and updating the first linked list.

[0082] In some examples, the preset cycle period can be set through a timer mechanism (e.g., by using a timer function provided by the operating system to set the preset cycle period of the first thread); it can also be set through a scheduling policy; or it can be set through a clock interrupt. Of course, the preset cycle period can also be set in other ways, and this application does not limit this.

[0083] As mentioned above, the MTK7563 chip is designed differently from other chips. When a router uses the MTK7563 chip to process traffic data, spinlocks cannot be used. This means that the first linked list may be referenced by multiple tasks at the same time, leading to system instability.

[0084] Therefore, to ensure the stable operation of the router system, it is necessary to guarantee that the first linked list can only be referenced by one task at a time. To achieve this, before accessing the first linked list, it can be determined whether the first linked list can be referenced at the current moment by checking the first data.

[0085] For example, as shown in Figure 4, based on a preset loop cycle, at the beginning of a loop, the first thread (i.e., the kernel thread) can determine whether the first linked list is currently referenced based on the first data (i.e., the reference count). Then, based on whether the first linked list is currently referenced, it determines whether the first thread should reference the first linked list. If it is determined that the first linked list is not currently referenced, then the first linked list can be referenced. If it is determined that the first linked list is currently referenced, then the first linked list cannot be referenced, and of course, other tasks cannot reference the first linked list either. Here, the first data is used to identify the number of tasks currently referencing the first linked list.

[0086] This effectively avoids conflicts and chaos that may be caused by multiple tasks operating on the first linked list simultaneously, thereby maintaining the stability of the router system and the integrity of the data, ensuring the normal execution of various router functions, and providing users with continuous and reliable network services.

[0087] In some examples, the process by which the first thread determines whether the first linked list is currently referenced based on the first data may include: the first thread checking if the first data is a preset value. If the first data is a preset value, it means the first linked list is not currently referenced, and the first thread can reference the first linked list. If the first data is not a preset value, it means the first linked list is currently referenced, and the first thread cannot reference the first linked list.

[0088] Step 303: If the first data is a preset value, the first thread increments and executes the first preset action. After the first preset action is completed, the first data decrements. If the first data is not a preset value, the first thread waits for the next loop to begin based on a preset loop period.

[0089] After the first thread checks whether the first data is a preset value, the first thread can decide whether to reference the first linked list based on whether the first data is a preset value.

[0090] In some examples, when the first data is a preset value, it indicates that the first linked list is not currently referenced. Therefore, the first thread can reference the first linked list. Before the first thread references the first linked list, the first data can be adjusted. For example, adjusting the first data can include controlling the first data to increment itself. After the first data is incremented, it is no longer a preset value. This prevents other tasks from referencing the first linked list. Controlling the first data through an increment mechanism ensures that operations are only performed under specific conditions (i.e., when the first data is a preset value).

[0091] In some examples, after the first data is incremented, the first thread executes a first preset action. The process of the first thread executing the first preset action may include: the first thread obtaining the traffic data of the downstream device and updating the traffic data of the downstream device to the first linked list.

[0092] For example, the process of obtaining traffic data from downstream devices and updating the traffic data of downstream devices to the first linked list may include: obtaining the traffic data of at least one device through a preset query interface based on the MAC address of at least one device in the attribute information of at least one device in the first linked list; and updating the traffic data of at least one device in the first linked list based on the MAC address and traffic data of at least one device. This allows for timely monitoring and updating of the traffic data of at least one device, improving the accuracy of the data in the first linked list.

[0093] As shown in Figure 4, the process of the first thread obtaining traffic data from downstream devices may include: the first thread accessing a first linked list (i.e., a traffic information linked list), and based on the first linked list, obtaining attribute information for at least one downstream device. According to the attribute information of at least one downstream device, the first thread obtains the traffic data corresponding to at least one downstream device through the preset traffic query interface of the MTK7563 chip. The preset traffic query interface is used to obtain the traffic data of at least one downstream device. The preset traffic query interface is an interface provided by the MTK7563 chip manufacturer for querying the traffic data of downstream devices.

[0094] The process by which the first thread accesses the first linked list and obtains the attribute information of at least one downstream device based on the first linked list may include the following steps: First, the first thread accesses the first linked list and identifies the head node pointer. Then, based on the head node pointer, it traverses each node in the first linked list sequentially, starting from the head node. Each node in the first linked list includes a pointer to a device structure. Next, using the pointers to the device structures within each node in the first linked list, the first thread can find the corresponding device structure for each node. The device structure stores the attribute information of the downstream device (e.g., MAC address and network port information). Finally, the first thread can read the attribute information of at least one downstream device from at least one device structure.

[0095] For example, the process of traversing each node in the first linked list sequentially, starting from the head node, based on the head node pointer of the first linked list may include: the first thread can access each node sequentially through the pointers of the nodes in the first linked list.

[0096] After obtaining the attribute information of at least one downstream device through the first linked list, you can refer to the above description and use the preset traffic query interface of the MTK7563 chip to obtain the traffic data corresponding to at least one downstream device.

[0097] After obtaining traffic data from at least one downstream device, the first thread can update the traffic data of the downstream device into the first linked list. The process of the first thread updating the traffic data of the downstream device into the first linked list may include: the first thread updating the traffic data corresponding to at least one downstream device into the first linked list based on the MAC address of at least one downstream device.

[0098] For example, at least one downstream device may include mobile phone A, mobile phone B, tablet A, and tablet B. After obtaining the traffic data corresponding to mobile phone A, mobile phone B, tablet A, and tablet B, the traffic data corresponding to mobile phone A, mobile phone B, tablet A, and tablet B can be updated to the first linked list based on their respective MAC addresses.

[0099] The process by which the first thread updates the traffic data corresponding to at least one downstream device to the first linked list based on the MAC address of at least one downstream device may include: the first thread traversing the first linked list and comparing the MAC address of at least one downstream device with the MAC addresses stored in each node of the first linked list. If a MAC address matching the MAC address of at least one downstream device is determined, the first thread adds the traffic data corresponding to that downstream device to the existing traffic data in the node corresponding to the matching MAC address. For example, the traffic data corresponding to the downstream device in this instance is added to the total traffic data of the downstream devices that have been recorded.

[0100] After the first preset action is completed, the first data is restored to the preset value. In some examples, the process of restoring the first data to the preset value may include: decrementing the first data to restore it to the preset value. Decrementing the first data to the preset value after the operation is complete ensures that the first data correctly returns to its origin. This approach is simpler, more convenient, and more operable.

[0101] After the first data is decremented, other threads can continue to reference the first linked list based on the preset value of the first data. For example, the first data can be 0, and after being incremented, the first data can be updated to 1. Of course, the first data can also be other values, and the increment value of the first data can also be other values; this application does not impose any restrictions on this.

[0102] In some examples, if the first data is not a preset value, it indicates that the first linked list is currently being referenced. Therefore, the first thread cannot reference the first linked list. The first thread needs to wait for the next iteration based on the preset loop cycle before continuing to determine whether it can reference the first linked list. In this way, the spinlock function can be implemented using the first data, thereby ensuring that the first linked list can only be referenced by one task at a time.

[0103] In some examples, after the first preset action is completed, the first thread can control the first data to be restored to the preset value. The process by which the first thread controls the first data to be restored to the preset value may include: controlling the first data to decrement so that the first data is restored to the preset value.

[0104] Step 304: After detecting the first event, insert the first event into the second linked list.

[0105] The first event is used to indicate whether a new device is coming online or an existing device is going offline. The first event includes the attribute information of the first device and its event identifier. The first device can be an existing device that has already connected to the router, or a new device connecting to the router for the first time. The event identifier of the first device can be either a coming-on identifier or a going-off identifier. The event identifier of the first device is used to indicate whether the first device is coming online or going offline.

[0106] In some examples, the first event may also include a timestamp that characterizes when the first event occurred, such as the online or offline time of the first device.

[0107] It should be noted that the execution order of step 304 with other steps is not limited in this embodiment. Step 304 can be executed before or after any step. For example, step 304 can be executed before step 301 or after step 302, which can be determined according to actual usage requirements.

[0108] In some examples, the process of inserting the first event into the second linked list after the first event is detected may include: inserting the first event into the tail of the second linked list after the first event is detected.

[0109] After detecting the first event, the process of inserting the first event into the tail of the second linked list can include: when the router detects a new device coming online or an existing device going offline, it can generate a first event based on whether the new device is online or the existing device is offline. Then, the router accesses the second linked list and inserts the first event into the tail of the second linked list through an insertion operation.

[0110] Step 305: The first thread checks if the first data is a preset value. If the first data is a preset value, the first data is incremented and a second preset action is executed. After the second preset action is completed, the first data is decremented. If the first data is not a preset value, the first thread waits for the next loop to begin based on a preset loop period.

[0111] The second preset action includes the first thread accessing the second linked list and updating the first linked list based on the second linked list.

[0112] After inserting the first event into the second linked list, the first thread can determine whether the first data is a preset value; if the first data is a preset value, the first data is incremented. The process of the first thread updating the first linked list according to the second linked list may include: updating the first linked list according to the event identifier corresponding to at least one device in the second linked list.

[0113] After the first linked list is updated, the first data item is decremented.

[0114] If the first data is not a preset value, the first thread cannot access the first linked list, so the first thread waits for the next loop to start based on the preset loop period.

[0115] The second linked list includes attribute information for at least one device and event flags for at least one device. The event flags for at least one device are used to indicate that at least one device is online or offline.

[0116] In some examples, the process of updating the first linked list based on the event identifier corresponding to at least one device in the second linked list may include: determining the processing result of at least one device based on the event identifier corresponding to at least one device in the second linked list; the processing result of at least one device includes adding at least one device to the first linked list or deleting at least one device from the first linked list; and updating the first linked list based on the attribute information of at least one device in the second linked list and the processing result of at least one device.

[0117] In other examples, as shown in Figure 4, the process of the first thread (i.e., the kernel thread) accessing the second linked list (i.e., the event linked list) and updating the first linked list based on the second linked list may include: firstly, the first thread accesses the second linked list and controls the events in the second linked list to be dequeued in the queue order through a dequeue operation; then, the first linked list is updated based on each dequeue event.

[0118] The process of dequeuing events from the second linked list according to the queue order through the dequeue operation can include: the first thread checks the head pointer of the second linked list to confirm that there are events to be processed in the second linked list. If the second linked list is empty, the dequeue operation is skipped. If the second linked list is not empty, the first thread moves the head pointer of the second linked list to the next node, separating the dequeue event (i.e., the head event) from the second linked list. Afterwards, the first linked list can be updated based on the separated dequeue events. Of course, other events in the second linked list can also be separated from the second linked list sequentially in this way, which will not be elaborated here. Through the dequeue operation, events in the second linked list can be gradually removed, thereby releasing related resources. This helps maintain the cleanliness of the data structure, avoids unnecessary memory consumption, and ensures that subsequent operations can correctly track the remaining tasks or events.

[0119] For example, the second linked list includes a second event, a third event, and a first event. The second event is the head event, and the first event is the tail event. After separating the second event, the third event and the first event can be separated from the second linked list sequentially in the manner described above.

[0120] In addition, the first thread can also update the size of the second linked list and other relevant metadata to reflect changes in the state of the second linked list.

[0121] After events in the second linked list are dequeued sequentially from the head of the queue, the process of updating the first linked list based on each dequeue event can include: if the event identifier corresponding to the dequeued device in a dequeue event is an online identifier, adding the dequeued device to the first linked list based on its attribute information; or, if the event identifier corresponding to the dequeued device in a dequeue event is an offline identifier, deleting the dequeued device from the first linked list based on its attribute information. Based on this method, each dequeue event is processed sequentially, and the first linked list is updated accordingly.

[0122] Determining whether to add or remove a device from the first linked list based on the event identifier of at least one device not only ensures the real-time update of the status of at least one device, enabling the first linked list to reflect the latest network status, but also avoids data redundancy, maintains the validity of the first linked list, and improves the efficiency of subsequent data processing.

[0123] In some examples, the process of adding a dequeued device to the first linked list based on its attribute information may include: a first thread creating a first node in the first linked list based on the MAC address in the dequeued device's attribute information, and adding the dequeued device through the first node. The first node is used to store the attribute information of the dequeued device. It is understood that adding the dequeued device to the first linked list can also be achieved in other ways, which will not be elaborated upon here.

[0124] In some examples, the process of deleting a device from the first linked list based on its attribute information may include: a first thread traversing the first linked list based on the MAC address in the device's attribute information, comparing the MAC address of the dequeued device with the MAC addresses stored in each node of the first linked list. After determining a MAC address that matches the MAC address of the dequeued device, the first thread deletes the node corresponding to that matching MAC address, thereby deleting the dequeued device. It is understood that deleting the dequeued device from the first linked list can also be achieved in other ways, which will not be elaborated upon here.

[0125] After the second preset action is completed (i.e., after the second linked list is empty and the first linked list is updated), the first data can be decremented, allowing other threads to access the first linked list normally. If the first data is not the preset value, it means that other tasks are referencing the first linked list, so the current loop does not process it, and the first thread waits for the next loop to start processing.

[0126] In other words, by storing device online or offline events in a second linked list, the system can monitor the dynamic changes of devices (i.e., connected devices) in real time and respond quickly. By inserting the attribute information and event identifier of the first device into the second linked list, the router can process the events in the second linked list in batches at specific times, thereby reducing frequent update operations and improving processing efficiency.

[0127] Furthermore, in this scenario, controlling access permissions to shared resources by checking if the first piece of data is a preset value ensures that no data races or inconsistencies occur during data updates. This significantly improves data consistency and security. Moreover, the first thread only triggers an update when the first piece of data is a preset value, avoiding unnecessary CPU and memory resource consumption and making the system run more efficiently.

[0128] It is understood that the embodiments of this disclosure do not limit the execution order of step 305 with other steps. For example, step 305 may be executed before step 302 or after step 303. For instance, step 305 may be executed at the beginning of a loop after the first thread is created, based on a preset loop period. The specific execution order can be determined according to actual usage requirements.

[0129] In some examples, the triggering time of step 305 can be preset by a preset cycle period, as shown in Figure 4. It can also be triggered after the first event is inserted into the second linked list (i.e., the event linked list). This application does not limit the triggering time of step 305, and the specific timing shall be based on the actual usage requirements.

[0130] Step 306: Received the first request.

[0131] The first request is used to query the traffic data corresponding to the first address. The first request includes the first address.

[0132] In some examples, a first request is received from the target program. For instance, the target program could be a traffic query application, a program on a server, or another higher-level query interface. Of course, the first request could also originate from other sources, and this application does not limit this.

[0133] When other programs need to query traffic, they can send a first request to the router. After receiving the first request, the router can respond to the first request and obtain the traffic data corresponding to the first address.

[0134] It is understood that the embodiments disclosed herein do not limit the execution order of step 306 with other steps. For example, step 306 may be executed after step 305 or after step 303, and the specific execution order may be determined according to actual usage requirements.

[0135] Step 307: In response to the first request, check if the first data is a preset value. If the first data is a preset value, increment the first data and execute the third preset action to determine the traffic data corresponding to the first address, then decrement the first data. If the first data is not a preset value, determine the predicted traffic data corresponding to the first address.

[0136] As shown in Figure 4, after receiving the first request, the router can detect that the first data (i.e., the reference count) is not a preset value (i.e., 0), so as to determine whether the traffic data corresponding to the first address can be obtained based on the first data.

[0137] In some examples, the process of detecting whether the first data is a preset value, and determining whether traffic data corresponding to the first address can be obtained based on the first data, may include: checking whether the first data is a preset value; if the first data is a preset value, it means that traffic data corresponding to the first address can be obtained, and thus the traffic data corresponding to the first address is determined. If the first data is not a preset value, it means that traffic data corresponding to the first address cannot be obtained, and thus the predicted traffic data corresponding to the first address is determined.

[0138] When the first data is a preset value, the process of determining the traffic data corresponding to the first address may include: when the first data is a preset value, incrementing the first data and performing a third preset action to determine the traffic data corresponding to the first address. The third preset action includes accessing a first linked list based on the first address and obtaining the traffic data corresponding to the first address based on the first linked list.

[0139] For example, the process of accessing a first linked list based on a first address and obtaining the traffic data corresponding to the first address based on the first linked list may include: a first thread accessing the first linked list and searching for the traffic data corresponding to the first address in multiple nodes of the first linked list based on the first address.

[0140] If the first data is not a preset value, the first thread cannot execute the third preset action, and therefore cannot obtain the traffic data corresponding to the first address. In this case, the predicted traffic data corresponding to the first address can be determined.

[0141] In some examples, if the first data is not a preset value, the first thread can determine the historical traffic data corresponding to the first address; based on the historical traffic data corresponding to the first address, the predicted traffic data corresponding to the first address can be determined.

[0142] For example, the predicted traffic data corresponding to the first address can be consistent with the most recent historical traffic data corresponding to the first address. Alternatively, the predicted traffic data corresponding to the first address can be obtained by adding a preset value to the most recent historical traffic data corresponding to the first address. For instance, if the most recent historical traffic data corresponding to the first address is 0.5M, the predicted traffic data corresponding to the first address = 0.5 + preset value (0.1) = 0.6M. Of course, the predicted traffic data corresponding to the first address can also be obtained through other methods, and this application does not impose any restrictions on this.

[0143] After obtaining the traffic data corresponding to the first address, or the predicted traffic data corresponding to the first address, the first data is decremented. This releases the resources of the first linked list so that other tasks can access the first linked list.

[0144] It is understandable that after receiving the first request, step 307 can also be executed through the first thread. This application does not restrict this, as long as it conforms to actual use.

[0145] In some examples, as shown in Figure 4, if the first data (i.e., the reference count) is not a preset value (i.e., 0), the router can continue to check whether the first data is a preset value at fixed intervals until it detects that the first data is a preset value. When the first data is detected to be a preset value, the above processing method can be used to obtain the traffic data corresponding to the first address.

[0146] Step 308: Send the first response message to the target program.

[0147] The first response message may include traffic data corresponding to the first address, or the first response message may include predicted traffic data corresponding to the first address.

[0148] Once the first thread finds the traffic data corresponding to the first address through the first linked list, or after the first reply message includes the predicted traffic data corresponding to the first address, it can send the first reply message to reply with the traffic data corresponding to the first address, or the first reply message includes the predicted traffic data corresponding to the first address.

[0149] In some examples, combining the steps above, after receiving the first request, if the first data is detected to be a preset value, the traffic data corresponding to the first address can be obtained by executing a third preset action. Then, the traffic data corresponding to the first address is sent via a first reply message.

[0150] In other examples, after receiving the first request, if the first data is detected to be different from the preset value, the first thread cannot execute the third preset action. Therefore, the predicted traffic data corresponding to the first address can be determined, and the predicted traffic data corresponding to the first address can be sent via the first reply message.

[0151] When the first data is a preset value, the router can immediately process the first request and quickly send the traffic data corresponding to the first address to the target program. This can improve the system's response speed and user experience.

[0152] If the first data is not a preset value, the first linked list cannot be accessed. The target program can be responded to through the historical traffic data corresponding to the first address. This can improve the fault tolerance and stability of the system and ensure that it can still respond under high load or special conditions (e.g., in case of failure).

[0153] Based on the method provided in the embodiment shown in Figure 3, the router can create a first thread. When the first thread needs to access the first linked list, it determines whether the first linked list can be referenced by judging whether the first data is a preset value. If the first data is a preset value, it means that the first linked list is not currently referenced, so the first thread can reference the first linked list. If the first data is not a preset value, it means that the first linked list is currently referenced, so the first thread cannot reference the first linked list.

[0154] Therefore, when the first data is a preset value, it can be adjusted first. This way, the first data will no longer be the preset value, preventing other programs from accessing the first linked list while the first thread is referencing it. After the first linked list is no longer in use (e.g., after an update), the first data can be restored to the preset value. This effectively releases the resources of the first linked list, making it easier for other programs to access it. In other words, this disclosure ensures that shared resources (e.g., the first linked list) can only be accessed by one task at a time by using the first data. This not only ensures the router operates normally but also guarantees the stability of the router system and the accuracy of shared resource data.

[0155] It should be understood that the steps in the above-described method embodiments provided in this disclosure can be implemented by integrated logic circuits in the processor hardware or by instructions in software form. The method steps disclosed in conjunction with the embodiments of this disclosure can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in the processor.

[0156] In one example, the unit in the above device may be one or more integrated circuits configured to implement the above methods, such as one or more ASICs, or one or more DSPs, or one or more FPGAs, or a combination of at least two of these integrated circuit forms.

[0157] For example, when the units in the device can be implemented through a processing element scheduler, the processing element can be a general-purpose processor, such as a CPU or other processor capable of calling programs. Alternatively, these units can be integrated together to form a system-on-a-chip (SoC).

[0158] In one implementation, the units that implement the corresponding steps in the above methods can be implemented in the form of a processing element scheduler. For example, the device may include a processing element and a storage element, wherein the processing element calls a program stored in the storage element to execute the methods of the above method embodiments. The storage element may be a storage element located on the same chip as the processing element, i.e., an on-chip storage element.

[0159] In another implementation, the program used to perform the above methods can be located on a storage element on a different chip than the processing element, i.e., an off-chip storage element. In this case, the processing element calls or loads the program from the off-chip storage element onto the on-chip storage element to call and execute the methods of the above method embodiments.

[0160] For example, embodiments of this disclosure may also provide an apparatus, such as a router, which may include a processor and a memory for storing processor-executable instructions. When the processor is configured to execute the aforementioned instructions, it causes the router to implement the data processing method as described in the foregoing embodiments. The memory may be located within or outside the router. Furthermore, the processor may include one or more processors.

[0161] In another implementation, the unit implementing each step of the above method can be configured as one or more processing elements, which can be disposed on the router described above. These processing elements can be integrated circuits, such as one or more ASICs, one or more DSPs, one or more FPGAs, or combinations of these types of integrated circuits. These integrated circuits can be integrated together to form a chip.

[0162] For example, embodiments of this disclosure also provide a chip, as shown in FIG5, the chip system including at least one processor 501 and at least one interface circuit 502. The processor 501 and the interface circuit 502 are interconnected via lines. For example, the interface circuit 502 can be used to receive signals from other devices. As another example, the interface circuit 502 can be used to send signals to other devices (e.g., the processor 501).

[0163] For example, interface circuit 502 can read instructions stored in the device's memory and send those instructions to processor 501. When the instructions are executed by processor 501, the router (router 200 as shown in FIG2) can perform the various steps in the above embodiments. Of course, the chip system may also include other discrete components, and this disclosure does not specifically limit this.

[0164] This disclosure also provides a computer-readable storage medium storing computer program instructions. When the computer program instructions are executed by a router, the router can implement the data processing method described above.

[0165] This disclosure also provides a computer program product, including computer instructions for operation as described above for a router. When the computer instructions are executed in the router, the router enables the router to implement the data processing method described above. Through the above description of the embodiments, those skilled in the art will clearly understand that, for the sake of convenience and brevity, the division of the above functional modules is only used as an example. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0166] In the several embodiments provided in this disclosure, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.

[0167] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0168] Furthermore, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0169] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this disclosure, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product, such as a program. This software product is stored in a program product, such as a computer-readable storage medium, and includes several instructions to cause a terminal device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.

[0170] For example, embodiments of this disclosure may also provide a computer-readable storage medium having computer program instructions stored thereon. When the computer program instructions are executed by a router, the router causes the router to implement the data processing method as described in the foregoing method embodiments.

[0171] The above are merely specific embodiments of this disclosure, but the scope of protection of this disclosure is not limited thereto. Any changes or substitutions within the technical scope disclosed in this disclosure should be included within the scope of protection of this disclosure. Therefore, the scope of protection of this disclosure should be determined by the scope of the claims.

Claims

1. A data processing method, characterized in that, Applied to a router, the method includes: creating a first thread; determining whether first data is a preset value; if the first data is a preset value, adjusting the first data and updating a first linked list using the first thread; the first linked list includes traffic data of at least one device; the preset value is used to indicate that the first linked list is not currently referenced; after the first linked list is updated, controlling the first data to be restored to the preset value; if the first data is not a preset value, the first thread cannot reference the first linked list.

2. The method according to claim 1, characterized in that, The first thread updates the first linked list, including: the first thread accesses the first linked list and obtains attribute information of at least one device in the first linked list; the attribute information of the at least one device includes the MAC address of the at least one device; based on the MAC address of the at least one device, it obtains traffic data of the at least one device through a preset query interface; based on the MAC address of the at least one device and the traffic data of the at least one device, it updates the traffic data of the at least one device in the first linked list.

3. The method according to claim 1 or 2, characterized in that, The method further includes: detecting a first event; the first event being used to characterize the first device going online or the first device going offline; obtaining attribute information and event identifier of the first device based on the first event, and inserting the attribute information and event identifier of the first device into a second linked list; the second linked list includes attribute information and event identifier of at least one device, the event identifier of the at least one device being used to characterize the at least one device going online or the at least one device going offline; after the first event is inserted into the second linked list, determining whether the first data is a preset value; if the first data is a preset value, adjusting the first data, and the first thread updating the first linked list based on the attribute information and event identifier of the at least one device in the second linked list; after the first linked list is updated, controlling the first data to be restored to the preset value; if the first data is not a preset value, the first thread cannot access the first linked list.

4. The method according to claim 3, characterized in that, The step of updating the first linked list based on the attribute information of the at least one device in the second linked list and the event identifier of the at least one device includes: determining the processing result of the at least one device based on the event identifier corresponding to the at least one device; the processing result of the at least one device includes adding the at least one device to the first linked list or deleting the at least one device from the first linked list; and updating the first linked list based on the attribute information of the at least one device and the processing result of the at least one device.

5. The method according to any one of claims 1-4, characterized in that, The method further includes: receiving a first request from a target program, the first request being used to request traffic data corresponding to a first address; responding to the first request, determining whether the first data is a preset value; if the first data is a preset value, adjusting the first data, the first thread obtaining the traffic data corresponding to the first address according to the first linked list; and sending the traffic data corresponding to the first address to the target program.

6. The method according to claim 5, characterized in that, After determining whether the first data is a preset value, the method further includes: if the first data is not a preset value, the first thread determines the historical traffic data corresponding to the first address; and based on the historical traffic data corresponding to the first address, determines the predicted traffic data corresponding to the first address.

7. The method according to any one of claims 1-6, characterized in that, The adjustment of the first data includes: controlling the first data to increment; the control of the first data to restore the preset value includes: controlling the first data to decrement, so that the first data is restored to the preset value.

8. The method according to any one of claims 1-7, characterized in that, The router includes a first chip, which is an MTK7563 chip.

9. A router, characterized in that, include: Processor, memory, bus, and communication interface; The memory is used to store computer execution instructions. The processor is connected to the memory via the bus. When the router is running, the processor executes the computer execution instructions stored in the memory to cause the router to perform the data processing method as described in any one of claims 1-8.

10. A computer-readable storage medium storing instructions, characterized in that, When the instruction is executed on the router, the router causes the router to perform the data processing method as described in any one of claims 1-8.