Instruction processing method and device, storage medium and electronic equipment
By adopting multi-threaded concurrent processor technology in smart home systems, using unoccupied gateway identifier lock processing instructions, multi-gateway concurrency and single-gateway serial instruction processing is realized, and performance problems in high concurrency scenarios are solved and improved The command processing efficiency and system stability of smart home devices.
Patent Information
- Application Number
- CN202411119622.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-12-17
AI Technical Summary
The existing smart home gateways are too inefficient in high concurrency scenarios to effectively respond to concurrent requests from a large number of users and devices, resulting in a degradation of system performance.
By implementing multi-threaded concurrency on the processor, determining the target worker thread to be run, and locking the command list based on the unoccupied gateway identification, implementing multi-gateway concurrency and single-gateway serial instruction processing to avoid blocking and competition, and improving System concurrency performance.
It improves the efficiency of smart home equipment instruction processing, solves performance bottleneck problems in high concurrency scenarios, and ensures the stability and response capabilities of the system.
Smart Images

Figure CN119149104A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet of Things, and in particular to an instruction processing method, device, storage medium and electronic device. Background Art
[0002] With the rapid development of smart homes, users have put forward higher requirements for the convenience of remotely controlling smart home devices at home, especially common home appliances such as air conditioners, electric lights, and sweeping robots. Users can easily send instructions such as switches, temperature adjustment, and mode switching to smart home devices through cloud services at any place and at any time through terminal devices such as smartphones, tablets, or wearable watches. This process is usually completed by relying on the gateway in the home network. As the core hub of the smart home system, the gateway is responsible for receiving instructions from user devices and converting them into corresponding control signals, thereby realizing the control of various smart home devices in the home.
[0003] However, in the prior art, most gateways use serial execution when processing commands, that is, they can only process one command at a time, and will not start processing the next command until the current command is executed. This processing method is sufficient for a single user or low-concurrency scenario, but with the increase in the number of smart home devices and a large number of users accessing the smart home system, the problem of low command processing efficiency in high-concurrency scenarios has gradually emerged. Summary of the invention
[0004] The embodiments of the present application provide an instruction processing method, device, storage medium and electronic device, which can improve instruction processing efficiency. The technical solution is as follows:
[0005] In a first aspect, an embodiment of the present application provides an instruction processing method, the method is executed by a processor, the processor can run N working threads at the same time, N is a positive integer, and the method includes:
[0006] Determine at least one target working thread to be executed among the N working threads;
[0007] According to at least one unoccupied target gateway identifier among the M gateway identifiers, obtaining and locking the target gateway identifier corresponding to each of the target work threads, wherein M is a positive integer, the M gateway identifiers correspond to M gateways, and each of the gateway identifiers corresponds to a pending instruction list including a plurality of pending instructions;
[0008] Run the target work thread, and process multiple pending instructions in the pending instruction list corresponding to the target work thread in sequence according to the gateway corresponding to the target work thread, until a preset condition is met, stop running and restore the target work thread to be running, and release the target gateway flag as unoccupied;
[0009] Repeat the above steps until the to-be-processed instruction lists corresponding to the M gateway identifiers are processed.
[0010] In a second aspect, an embodiment of the present application provides an instruction processing device, wherein the instruction processing device can run N working threads simultaneously, where N is a positive integer, and the device includes:
[0011] A first processing module, used to determine at least one target working thread to be executed among the N working threads;
[0012] A second processing module is used to obtain and lock the target gateway identifier corresponding to each of the target work threads according to at least one unoccupied target gateway identifier among the M gateway identifiers, where M is a positive integer, and each of the gateway identifiers corresponds to a pending instruction list including a plurality of pending instructions;
[0013] A third processing module is used to run the target work thread, and according to the gateway corresponding to the target work thread, sequentially process multiple pending instructions in the pending instruction list corresponding to the target work thread, until a preset condition is met, stop running and restore the target work thread to be run, and release the target gateway flag as unoccupied;
[0014] The fourth processing module is used to repeat the above steps until the to-be-processed instruction lists corresponding to the M gateway identifiers are processed completely.
[0015] In a third aspect, an embodiment of the present application provides a computer storage medium, wherein the computer storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the above-mentioned method steps.
[0016] In a fourth aspect, an embodiment of the present application provides an electronic device, which may include: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the above-mentioned method steps.
[0017] The beneficial effects brought about by the technical solutions provided by some embodiments of the present application include at least:
[0018] The processor of the instruction processing method of the present application can run N working threads at the same time, that is, it has the ability of multi-threaded concurrency. Determine at least one target working thread to be run among the N working threads, and collect and lock the unoccupied target gateway identifier corresponding to each target working thread, that is, the present application can realize multi-gateway concurrent instruction processing. Further run the target working thread, and process the multiple pending instructions corresponding to the target working thread in turn according to the gateway corresponding to the target working thread, that is, the present application can realize the instruction processing of a single gateway serial. Until the preset conditions are met, stop running and restore the target working thread to be run, and release the target gateway identifier as unoccupied, repeat the above steps until the list of pending instructions corresponding to the M gateway identifiers is processed. In other words, the present application realizes multi-gateway concurrent and single-gateway serial instruction processing, improves the efficiency of multi-instruction processing, and solves the blocking problem that is easily caused when multi-threaded multi-gateway executes instructions, and performs instruction processing by exclusively occupying the gateway identifier, avoiding competition between multiple working threads, and improving the system concurrency performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0020] Figure 1 It is a schematic diagram of the architecture of an instruction processing method provided in an embodiment of the present application;
[0021] Figure 2 It is a flowchart of an instruction processing method provided in an embodiment of the present application;
[0022] Figure 3 It is a flowchart of an instruction processing method provided in an embodiment of the present application;
[0023] Figure 4 It is a flowchart of an instruction processing method provided in an embodiment of the present application;
[0024] Figure 5 It is a flowchart of an instruction processing method provided in an embodiment of the present application;
[0025] Figure 6 It is a structural diagram of an instruction processing method provided in an embodiment of the present application;
[0026] Figure 7 is a structural diagram of an instruction processing device provided in an embodiment of the present application;
[0027] Figure 8 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0029] In the description of the present application, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In the description of the present application, it should be noted that, unless otherwise clearly specified and limited, "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood in specific circumstances. In addition, in the description of the present application, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B, which can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are an "or" relationship.
[0030] The present application is described in detail below with reference to specific embodiments.
[0031] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in the embodiments of this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions. For example, the features and information involved in this application are all obtained with full authorization.
[0032] With the rapid development of smart homes, users have put forward higher requirements for the convenience of remotely controlling smart home devices at home, especially common home appliances such as air conditioners, electric lights, and sweeping robots. Users can easily send instructions such as switches, temperature adjustment, and mode switching to smart home devices through cloud services at any place and at any time through terminal devices such as smartphones, tablets, or wearable watches. This process is usually completed by relying on the gateway in the home network. As the core hub of the smart home system, the gateway is responsible for receiving instructions from user devices and converting them into corresponding control signals, thereby realizing the control of various smart home devices in the home.
[0033] However, in the prior art, most gateways use serial execution when processing commands, that is, they can only process one command at a time, and will not start processing the next command until the current command is executed. This processing method is sufficient for a single user or low-concurrency scenario, but with the increase in the number of smart home devices and a large number of users accessing the smart home system, the problem of low command processing efficiency in high-concurrency scenarios has gradually emerged.
[0034] In view of the above problems, the present application embodiment proposes an instruction processing method to solve them. Figure 1 As shown, Figure 1 It is a scenario diagram of an interactive processing method provided in an embodiment of the present application. Figure 1 The system includes multiple electronic devices and a processor 101, wherein the multiple electronic devices include at least an electronic device 1011, an electronic device 1012, an electronic device 1013, and an electronic device 1014. It is understood that Figure 1 The number of electronic devices shown is for illustration only and this application does not impose any limitation on this.
[0035] The user interacts with the application through the application provided by the electronic device, for example, closing a page of the application by sliding or clicking on the display device of the electronic device. The electronic device receives multiple instructions to be processed generated during the above interaction process.
[0036] The above-mentioned electronic devices include but are not limited to physical or virtual processors, mobile stations (MS), mobile terminals, mobile phones, handsets and portable equipment, Bluetooth headsets, smart watches and other types. The electronic devices can communicate with one or more core networks via a radio access network (RAN).
[0037] In the embodiment of the present application, the electronic device may also be equipped with a display device, and the display device may be any device capable of realizing a display function, for example, the display device may be a cathode ray tube display (Cathoderay tube display, CR for short), a light-emitting diode display (Light-emitting diode display, LED for short), an electronic ink screen, a liquid crystal display (Liquid crystal display, LCD for short), a plasma display panel (Plasma display panel, PDP for short), etc. For example, a user may use the display device on the electronic device to interact with an application, or view the instruction processing result obtained by the processor 101 executing the instruction processing method provided in the embodiment of the present application.
[0038] Processor 101 can be understood as an IoT hardware device that can run N working threads simultaneously and process multiple pending instructions concurrently. Specifically, the Java-based instruction executor uses a multi-threaded approach to issue instructions. Processor 101 is specifically used to receive pending instructions through multiple interfaces, and to provide corresponding data or services based on the pending instructions. In an embodiment of the present application, processor 101 receives multiple pending instructions sent by multiple electronic devices respectively, and processes multiple pending instructions at the same time. For example, processor 101 receives multiple pending instructions generated during the interaction between a user and an application set on electronic device 1021 and sent by electronic device 102. Furthermore, processor 101 executes the instruction processing method of an embodiment of the present application based on multiple pending instructions to obtain a processing result, such as remotely starting the air conditioner on time in the smart home device system.
[0039] It is understandable that the processor 101 also has other service capabilities and functions to complete the tasks in the following embodiments. For example, the processor 101 also provides portal services, resource management services, and CI / CD services.
[0040] The processor 101 may be multiple physical servers, which are independent in hardware; or multiple processors may be multiple virtual servers, which are deployed in the same hardware resource pool. The deployment methods of the virtual servers include but are not limited to VMware, Virtual Box, and Virtual PC.
[0041] The processor 101 and multiple electronic devices can communicate through a communication link established by a communication protocol, such as the gRPC protocol. gRPC is a high-performance, general-purpose open source remote processor call (RPC) framework, which is mainly designed for mobile application development and based on the HTTP / 2 protocol standard, based on the protocol buffer (PB) serialization protocol development, and supports many development languages. In addition, the communication link can also be a wireless communication link or a wired communication link, for example, a wired communication link includes an optical fiber, a twisted pair or a coaxial cable, and a wireless communication link includes a Bluetooth communication link, a wireless fidelity (WIreless-FIdelity, Wi-Fi) communication link or a microwave communication link, etc.
[0042] In one embodiment, Figure 2 As shown, a schematic diagram of an instruction processing method provided in an embodiment of the present application is provided, which can be implemented by a computer program and can be run on an instruction processing device based on the von Neumann architecture. The computer program can be integrated into an application or run as an independent tool application.
[0043] Specifically, the instruction processing method includes:
[0044] S101. Determine at least one target working thread to be executed among N working threads.
[0045] A worker thread is a thread used to perform background tasks in computer science. In the present application, the processor 101 can run N worker threads at the same time, and each worker thread can perform tasks independently. The worker thread of the present application refers to a thread designed to perform instruction distribution and process tasks. Such tasks are not suitable for direct execution in the main thread (such as the UI thread) to avoid blocking the main thread and affecting the responsiveness of the program or the user experience.
[0046] In different programming environments and frameworks, the way to create and manage worker threads may vary. For example, in Java, you can create worker threads by implementing the Runnable interface or inheriting the Thread class; in .NET, you can use Task or ThreadPool to manage worker threads; in JavaScript, Web Workers provides a way to run scripts in background threads to avoid long-running tasks blocking the user interface.
[0047] In this application, a Java-based instruction executor adopts a thread pool approach to start N worker threads, and each worker thread continuously loops to check whether there is an unoccupied gateway identifier in the local storage. It can be understood that N is a positive integer.
[0048] S102. According to at least one unoccupied target gateway identifier among the M gateway identifiers, obtain and lock the target gateway identifier corresponding to each target working thread.
[0049] The Gateway Identifier is used to identify or recognize the gateway device in the system. The gateway is a communication node connecting different networks, responsible for forwarding data packets and realizing communication between different networks. The gateway identifier is a way to uniquely or specifically identify these gateway devices. In this application, M gateways correspond to M gateway identifiers. The gateway identifier may include one or more of the following information: IP address, specific identifier (such as MAC address (Media Access Control Address) or serial number, etc.), national standards or industry standards (for example, National Gateway ID for Internet Gateway), and management information.
[0050] When a worker thread receives and locks a gateway ID, the gateway ID is marked as occupied by a worker thread, ensuring that multiple pending instructions corresponding to each gateway ID are uniquely processed from a global perspective, avoiding conflicts caused by parallel processing of pending instructions corresponding to the same gateway. When multiple pending instructions corresponding to the gateway corresponding to the gateway ID are processed or other preset conditions are met, the gateway ID is released and marked as unoccupied.
[0051] Therefore, at least one gateway identifier marked as unoccupied is confirmed as the target gateway identifier among the M gateway identifiers. In other words, multiple pending instructions corresponding to the gateway corresponding to the target gateway identifier are waiting to be processed. The unrunning target work thread receives and locks any one of the target gateway identifiers among the at least one target gateway identifier.
[0052] S103, run the target work thread, and process multiple pending instructions in the pending instruction list corresponding to the target work thread in sequence according to the gateway corresponding to the target work thread, until the preset conditions are met, stop running and restore the target work thread to be run, and release the target gateway mark as unoccupied.
[0053] There are multiple pending instructions in the pending instruction list corresponding to the target gateway identifier, in other words, the multiple pending instructions need to be processed by the gateway corresponding to the gateway identifier. Run the target work thread, read the multiple pending instructions in the pending instruction list corresponding to the target gateway identifier corresponding to the target work thread in turn, and send them to the gateway corresponding to the gateway identifier corresponding to the target work thread for processing.
[0054] For example, work thread A, which serves as the target work thread, receives and occupies the target gateway identifier, which corresponds to gateway A. Work thread A runs, and reads multiple pending instructions in the pending instruction list corresponding to the target gateway identifier corresponding to work thread A in turn and distributes them to gateway A for processing.
[0055] When the preset conditions are met, stop running and restore the target work thread to be run, and release the target gateway identifier as unoccupied, so that the target work thread continues to receive and lock other unoccupied gateway identifiers among the M gateway identifiers, and release the target gateway identifier as unoccupied. When the pending instructions are updated in the pending instruction list corresponding to the target gateway identifier, other non-running work threads can receive and lock the target gateway identifier.
[0056] The preset conditions include the following conditions: the processing of the pending instruction list corresponding to the target working thread is completed. In other words, when it is detected that there is no pending instruction in the pending instruction list corresponding to the target gateway identifier processed by the target working thread, the target working thread is stopped from continuing to occupy the target gateway identifier. For example, running working thread A, multiple pending instructions in the pending instruction list corresponding to the target gateway identifier corresponding to working thread A are read in turn and distributed to gateway A for processing. When all the multiple pending instructions in the pending instruction list corresponding to gateway A are processed, the gateway identifier corresponding to gateway A is released as unoccupied, and working thread A is restored to not running.
[0057] In this implementation, the preset condition is that the list of pending instructions corresponding to the target work thread is processed, which can ensure that multiple pending instructions corresponding to a single gateway are executed in sequence, and respond to user needs in a timely manner to provide services to users.
[0058] In other embodiments, the preset condition may also be other conditions set as needed. For example, the preset condition is that the target working thread executes the pending instructions in the pending instruction list to reach a preset number, or the target working thread executes the pending instructions in the pending instruction list to reach a preset time.
[0059] S104, repeat the above steps until the to-be-processed instruction lists corresponding to the M gateway identifiers are processed.
[0060] Specifically, in the system corresponding to the processor 101, a server program is written to start a thread pool, which contains N working threads that loop forever and never stop, and corresponding M gateways, each gateway including its corresponding gateway identifier. The unrunning working thread is used to check whether there is an unoccupied gateway identifier in the local storage to represent the gateway identifier that needs to be executed. If there is, the unrunning working thread is used to obtain the gateway identifier, and it is marked as occupied at the same time, and other working threads cannot occupy it at the same time.
[0061] Furthermore, in a single working thread, a pending instruction is read from a pending instruction list corresponding to the gateway identifier, and the pending instruction is sent to the gateway corresponding to the gateway identifier for processing. After completing the processing of one pending instruction, the next instruction in the pending instruction list is read, until multiple pending instructions corresponding to the gateway identifier are processed, thereby releasing the occupation of the gateway identifier.
[0062] Further, after the working thread finishes processing multiple pending instructions corresponding to a gateway identifier, it continues to check other unoccupied gateway identifiers and repeats the above steps. If all M gateway identifiers are occupied, the check continues after a preset period. The preset period can be any time, such as 5 seconds.
[0063] The processor of the instruction processing method of the present application can run N working threads at the same time, that is, it has the ability of multi-threaded concurrency. Determine at least one target working thread to be run among the N working threads, and collect and lock the unoccupied target gateway identifier corresponding to each target working thread, that is, the present application can realize multi-gateway concurrent instruction processing. Further run the target working thread, and process the multiple pending instructions corresponding to the target working thread in turn according to the gateway corresponding to the target working thread, that is, the present application can realize the instruction processing of a single gateway serial. Until the preset conditions are met, stop running and restore the target working thread to be run, and release the target gateway identifier as unoccupied, repeat the above steps until the list of pending instructions corresponding to the M gateway identifiers is processed. In other words, the present application realizes multi-gateway concurrent and single-gateway serial instruction processing, improves the efficiency of multi-instruction processing, and solves the blocking problem that is easily caused when multi-threaded multi-gateway executes instructions, and performs instruction processing by exclusively occupying the gateway identifier, avoiding competition between multiple working threads, and improving the system concurrency performance.
[0064] In one embodiment, Figure 3 As shown, a schematic diagram of an instruction processing method provided in an embodiment of the present application is provided, which can be implemented by a computer program and can be run on an instruction processing device based on the von Neumann architecture. The computer program can be integrated into an application or run as an independent tool application.
[0065] Specifically, the instruction processing method includes:
[0066] S201, receiving a plurality of instructions to be processed.
[0067] The user interacts with the application through the application provided by the electronic device, for example, by sliding or clicking the display device of the electronic device to open the application and control the air conditioner to start. The electronic device receives multiple pending instructions generated during the above interaction process. The multiple pending instructions may come from multiple electronic devices.
[0068] like Figure 4 As shown, Figure 4 1 is a flowchart of an instruction processing method provided in an embodiment of the present application, receiving multiple instructions to be processed. The multiple instructions to be processed at least include instructions to be processed 2021, instructions to be processed 2022, instructions to be processed 2023, ... instructions to be processed 202X. It can be understood that, Figure 4 The number of instructions to be processed is for illustration only and is not limited in this embodiment.
[0069] S202: Distribute multiple pending instructions to the pending instruction lists corresponding to the pending instructions according to the gateway identifier corresponding to each pending instruction and the pending instruction lists corresponding to the M gateway identifiers.
[0070] According to the gateway identifier corresponding to each pending instruction and the preset M gateway identifiers, multiple pending instructions are classified and distributed to a pending instruction list corresponding to the gateway identifier corresponding to the pending instruction. The number of pending instructions included in the pending instruction list corresponding to each gateway identifier may be the same or different.
[0071] like Figure 4 As shown, this embodiment includes a total of M gateway identifiers, namely, gateway identifier 2021, gateway identifier 2022, gateway identifier 2023, gateway identifier 2024, ..., gateway identifier 202M, each gateway identifier corresponds to a gateway. Specifically, gateway identifier 2021 corresponds to gateway A, gateway identifier 2022 corresponds to gateway B, gateway identifier 2023 corresponds to gateway C, gateway identifier 2024 corresponds to gateway D, ..., gateway identifier 202M corresponds to gateway M. Multiple pending instructions are distributed to a pending instruction list Redis List corresponding to the gateway identifier corresponding to the pending instructions. For example, pending instructions 2011 and pending instructions 2012 are distributed to the pending instruction list corresponding to gateway identifier 2021, and pending instructions 2013 and pending instructions 2014 are distributed to the pending instruction list corresponding to gateway identifier 2022.
[0072] In this embodiment, the Redis List data structure is used to generate a list of pending instructions corresponding to the gateway identifier. The pending instructions are divided according to the gateway identifier and distributed to the Redis List corresponding to each gateway identifier in a first-in-first-out manner for storage, which can effectively improve the efficiency of distributing multiple pending instructions and prepare for subsequent multi-gateway concurrency.
[0073] S203: Determine at least one target working thread to be executed among the N working threads.
[0074] See the above S102, which will not be described again here.
[0075] S204: Determine at least one unoccupied target gateway identifier among the M gateway identifiers.
[0076] When a work thread receives and locks a gateway identifier, the gateway identifier is marked as occupied by a work thread, ensuring that multiple pending instructions corresponding to each gateway identifier are uniquely processed from a global perspective, avoiding conflicts caused by parallel processing of pending instructions corresponding to the same gateway. When multiple pending instructions corresponding to the gateway corresponding to the gateway identifier are processed or meet other preset conditions, the gateway identifier is released and marked as unoccupied. Therefore, at least one gateway identifier marked as unoccupied is confirmed as the target gateway identifier among the M gateway identifiers.
[0077] S205. Allocate any target gateway identifier to each target work thread, so that the target work thread obtains and locks the target gateway identifier corresponding to the target work thread.
[0078] The unrunning worker thread is used as the target worker thread, and it obtains and locks any target gateway identifier among at least one target gateway identifier. Figure 4 As shown, the instruction execution thread pool 203 includes N work threads, namely work thread A, work thread B, work thread C, ..., work thread N. The gateway identifier 2021 is received and locked by the work thread A, the gateway identifier 2022 is received and locked by the work thread B, and the gateway identifier 2023 is received and locked by the work thread C.
[0079] S206. Run the target work thread, and process multiple pending instructions in the pending instruction list corresponding to the target work thread in sequence according to the gateway corresponding to the target work thread, until the preset conditions are met, stop running and restore the target work thread to be run, and release the target gateway mark as unoccupied.
[0080] Specifically, run the target work thread, use the target gateway identifier received by the target work thread as the key, read the pending instructions in the pending instruction list corresponding to the target work thread in sequence according to the processing order, and distribute them to the gateway corresponding to the target work thread for processing until the preset conditions are met, stop running and restore the target work thread to wait, and release the target gateway identifier as unoccupied.
[0081] The processing order is the order in which the pending instructions are stored in the pending instruction list. The pending instructions are read from the pending instruction list in sequence according to the first-in-first-out principle and distributed to the gateway corresponding to the target working thread for processing.
[0082] like Figure 4 As shown, taking worker thread A as an example, worker thread A reads multiple pending instructions in the pending instruction list Redis List corresponding to gateway identifier 2021 in the processing order, and the processing order is the order in which multiple pending instructions are stored in the pending instruction list Redis List corresponding to gateway identifier 2021, and the pending instructions are distributed to gateway A for processing in sequence. When the preset conditions are met, the operation is stopped and worker thread A is restored to be ready to run, and gateway identifier 2021 is released as unoccupied, so that worker thread A can claim other unoccupied gateway identifiers.
[0083] In this embodiment, the target gateway identifier received by the target working thread is used as a key, and the pending instructions are read in the pending instruction list corresponding to the target gateway identifier corresponding to the target working thread in sequence according to the processing order. The processing order is related to the writing order of multiple pending instructions stored in the pending instruction list, and follows the first-in-first-out principle to ensure the stability of single gateway serial execution, improve the efficiency of single gateway instruction execution, and avoid the problem of missing processing instructions.
[0084] S207, repeat the above steps until the multiple pending instructions corresponding to the M gateways are processed.
[0085] See the above S104, which will not be described again here.
[0086] The processor of the instruction processing method of the present application can run N working threads at the same time, that is, it has the ability of multi-threaded concurrency. Determine at least one target working thread to be run among the N working threads, and collect and lock the unoccupied target gateway identifier corresponding to each target working thread, that is, the present application can realize multi-gateway concurrent instruction processing. Further run the target working thread, and process the multiple pending instructions corresponding to the target working thread in turn according to the gateway corresponding to the target working thread, that is, the present application can realize the instruction processing of a single gateway serial. Until the preset conditions are met, stop running and restore the target working thread to be run, and release the target gateway identifier as unoccupied, repeat the above steps until the list of pending instructions corresponding to the M gateway identifiers is processed. In other words, the present application realizes multi-gateway concurrent and single-gateway serial instruction processing, improves the efficiency of multi-instruction processing, and solves the blocking problem that is easily caused when multi-threaded multi-gateway executes instructions, and performs instruction processing by exclusively occupying the gateway identifier, avoiding competition between multiple working threads, and improving the system concurrency performance.
[0087] In one embodiment, Figure 5 As shown, a schematic diagram of an instruction processing method provided in an embodiment of the present application is provided, which can be implemented by a computer program and can be run on an instruction processing device based on the von Neumann architecture. The computer program can be integrated into an application or run as an independent tool application.
[0088] Specifically, the instruction processing method includes:
[0089] S301, receiving a plurality of instructions to be processed.
[0090] See the above S201, which will not be repeated here.
[0091] S302: Push multiple pending instructions to a message queue through an instruction producer.
[0092] In this embodiment, the Spring Boot framework is used to write the server program for issuing instructions. The server program can use the instruction producer Kafka Producer to push the instructions to be processed to the Kafka message queue. Figure 6 As shown, it is a flow chart of an instruction processing method provided by the present application, in which multiple instructions to be processed are obtained from the process in which user A, ... user X respectively issue instructions to the device, and the multiple instructions to be processed are pushed to the message list 302 by the instruction pusher 301.
[0093] S302. According to the gateway identifier corresponding to each pending instruction and the gateway identifiers corresponding to the preset M gateways, the instruction consumer distributes the multiple pending instructions in sequence to the pending instruction list corresponding to the gateway identifiers corresponding to the pending instructions in a distribution order.
[0094] The instruction consumer is responsible for consuming the message queue, dividing multiple pending instructions according to gateway identifiers, storing them in Redis List in a first-in-first-out manner, and storing multiple gateway identifiers in a Redis Set collection for backup. In this embodiment, Kafka Consumer is used as the instruction consumer 303, such as Figure 6 As shown, Redis is used to store multiple pending instructions and M gateway identifiers. In this embodiment, a Redis List data structure and a Redis Set data structure are used.
[0095] S304: Determine at least one target working thread to be executed among the N working threads.
[0096] See the above S101, which will not be repeated here.
[0097] S305: According to at least one unoccupied target gateway identifier among the M gateway identifiers, obtain and lock the target gateway identifier corresponding to each target work thread.
[0098] See the above S102, which will not be described again here.
[0099] S306: Record the status information corresponding to the M gateway identifiers into a status information set, and store the status information set into a preset database.
[0100] The status information of the gateway identifier is used to indicate whether the gateway identifier is unoccupied or has been claimed by the target work thread. Specifically, the status information of the gateway identifier is that the gateway identifier is unoccupied, that is, the gateway identifier is waiting to be claimed and occupied by a work thread, for example, the status information of gateway identifier A is unoccupied. The status information of the gateway identifier is that the gateway identifier has been occupied by the target work thread, for example, gateway identifier B is occupied by work thread B.
[0101] The status information corresponding to the M gateway identifiers is recorded in the status information set and stored in the preset database. In this embodiment, the status information records corresponding to the M gateway identifiers are stored in the status information set of the Redis Set data structure. The preset database can be any cloud or other type of database, and this embodiment does not impose any restrictions on this.
[0102] In one embodiment, after the processor restarts the service, a state information set is obtained from the database; the gateway identifier is restored to the corresponding state according to the state information of each gateway identifier in the state information set, and N working threads continue to run to process the list of pending instructions corresponding to the M gateway identifiers.
[0103] When the processor restarts or even restarts the service due to network failure or hardware failure, the local data is cleared. At this time, the Redis Set state information set is obtained from the preset database, and the gateway identifier is restored to the corresponding state according to the state information of each gateway identifier in the state information set, for example, the state information of the gateway identifier A is restored to be unoccupied, and the gateway identifier B is restored to be occupied by the worker thread B. Further, the operation continues based on the states corresponding to the restored M gateway identifiers, so that the N worker threads continue to process the multiple pending instructions corresponding to the M gateways.
[0104] In this embodiment, by recording the status information corresponding to the M gateway identifiers into a status information set and storing it in a preset database, the status information set can be obtained from the database after the processor restarts the service, so as to restore the gateway identifier to the corresponding state according to the status information of each gateway identifier in the status information set, so as to continue to run N working threads to process the multiple pending instructions corresponding to the M gateways until the multiple pending instructions corresponding to the M gateways are processed. This can improve the stability of the entire system, avoid the problem of difficulty in continuing to execute instructions after local data is cleared due to a fault, and improve the intelligence of the system.
[0105] S307, run the target work thread, and according to the gateway corresponding to the target work thread, process the multiple pending instructions in the pending instruction list corresponding to the target gateway identifier corresponding to the target work thread in sequence, until the preset conditions are met, stop running and restore the target work thread to be run, and release the target gateway identifier to be unoccupied.
[0106] See the above S206, which will not be described again here.
[0107] S308, repeat the above steps until the multiple pending instructions corresponding to the M gateways are processed.
[0108] See the above S104, which will not be described again here.
[0109] like Figure 6As shown, multi-threaded processing is performed using work thread 3041, work thread 3042, ..., work thread 3041, a single work thread obtains an unoccupied gateway identifier from Redis Set and locks it, uses the gateway identifier as a key, reads pending instructions from the Redis list in the processing order, and determines whether the multiple pending instructions corresponding to the gateway identifier in the Redis list have been read, and sends the pending instructions one by one to the gateway corresponding to the gateway identifier for instruction processing, until the multiple pending instructions corresponding to the gateway identifier in the Redis list have been read, the work thread continues to obtain unoccupied gateway identifiers from Redis Set and locks them and executes the above steps. This embodiment includes gateway 1, gateway 2, ... gateway M, a total of M gateways.
[0110] The processor of the instruction processing method of the present application can run N working threads at the same time, that is, it has the ability of multi-threaded concurrency. Determine at least one target working thread to be run among the N working threads, and collect and lock the unoccupied target gateway identifier corresponding to each target working thread, that is, the present application can realize multi-gateway concurrent instruction processing. Further run the target working thread, and process the multiple pending instructions corresponding to the target working thread in turn according to the gateway corresponding to the target working thread, that is, the present application can realize the instruction processing of a single gateway serial. Until the preset conditions are met, stop running and restore the target working thread to be run, and release the target gateway identifier as unoccupied, repeat the above steps until the list of pending instructions corresponding to the M gateway identifiers is processed. In other words, the present application realizes multi-gateway concurrent and single-gateway serial instruction processing, improves the efficiency of multi-instruction processing, and solves the blocking problem that is easily caused when multi-threaded multi-gateway executes instructions, and performs instruction processing by exclusively occupying the gateway identifier, avoiding competition between multiple working threads, and improving the system concurrency performance.
[0111] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0112] See also Figure 7 , which shows a schematic diagram of the structure of an instruction processing device provided by an exemplary embodiment of the present application. The instruction processing device can be implemented as all or part of the device through software, hardware or a combination of both. The instruction processing device includes a first processing module 401, a second processing module 402, a third processing module 403 and a fourth processing module 404.
[0113] A first processing module 401 is used to determine at least one target working thread to be executed among the N working threads;
[0114] The second processing module 402 is used to obtain and lock the target gateway identifier corresponding to each of the target work threads according to at least one unoccupied target gateway identifier among the M gateway identifiers, where M is a positive integer, and each of the gateway identifiers corresponds to a pending instruction list including a plurality of pending instructions;
[0115] The third processing module 403 is used to run the target work thread, and according to the gateway corresponding to the target work thread, sequentially process multiple pending instructions in the pending instruction list corresponding to the target work thread, until a preset condition is met, stop running and restore the target work thread to be run, and release the target gateway flag as unoccupied;
[0116] The fourth processing module 404 is used to repeat the above steps until the to-be-processed instruction lists corresponding to the M gateway identifiers are processed completely.
[0117] In one embodiment, the instruction processing device further includes:
[0118] A fifth processing module, configured to receive a plurality of instructions to be processed;
[0119] The sixth processing module is used to distribute the pending instructions to the pending instruction lists corresponding to the pending instructions according to the gateway identifier corresponding to each of the pending instructions and the pending instruction lists corresponding to the M gateway identifiers.
[0120] In one embodiment, the instruction processing device further includes:
[0121] A seventh processing module, configured to push a plurality of pending instructions to a message queue through an instruction producer, wherein the message queue represents a distribution order corresponding to the plurality of pending instructions;
[0122] The sixth processing module comprises:
[0123] An instruction distribution unit is used to distribute the multiple pending instructions in sequence to the pending instruction list corresponding to the pending instructions according to the gateway identifier corresponding to each pending instruction and the pending instruction list corresponding to the M gateway identifiers, through the instruction consumer in the distribution order.
[0124] In one embodiment, the second processing module 402 includes:
[0125] An identifier determining unit, used to determine at least one unoccupied target gateway identifier among the M gateway identifiers;
[0126] The identifier allocation unit is used to allocate any one of the target gateway identifiers to each of the target work threads, so that the target work thread receives and locks the target gateway identifier corresponding to the target work thread.
[0127] In one embodiment, the third processing module 403 includes:
[0128] A thread running unit is used to run the target work thread, use the target gateway identifier received by the target work thread as a key, read the pending instructions in the pending instruction list corresponding to the target work thread in sequence according to the processing order, and distribute them to the gateway corresponding to the target work thread for processing, until the preset conditions are met, stop running and restore the target work thread to be run, and release the target gateway identifier as unoccupied.
[0129] In one embodiment, the instruction processing device further includes:
[0130] The eighth processing module is used to record the status information corresponding to the M gateway identifiers into a status information set, and store the status information set into a preset database. The status information of the gateway identifier is used to indicate that the gateway identifier is unoccupied or has been claimed by the target working thread.
[0131] In one embodiment, the instruction processing device further includes:
[0132] A ninth processing module, configured to obtain the state information set from the database after the processor restarts the service;
[0133] The tenth processing module is used to restore the gateway identifier to a corresponding state according to the state information of each gateway identifier in the state information set, and continue to run the N working threads to process the to-be-processed instruction lists corresponding to the M gateway identifiers.
[0134] The processor of the instruction processing method of the present application can run N working threads at the same time, that is, it has the ability of multi-threaded concurrency. Determine at least one target working thread to be run among the N working threads, and collect and lock the unoccupied target gateway identifier corresponding to each target working thread, that is, the present application can realize multi-gateway concurrent instruction processing. Further run the target working thread, and process the multiple pending instructions corresponding to the target working thread in turn according to the gateway corresponding to the target working thread, that is, the present application can realize the instruction processing of a single gateway serial. Until the preset conditions are met, stop running and restore the target working thread to be run, and release the target gateway identifier as unoccupied, repeat the above steps until the list of pending instructions corresponding to the M gateway identifiers is processed. In other words, the present application realizes multi-gateway concurrent and single-gateway serial instruction processing, improves the efficiency of multi-instruction processing, and solves the blocking problem that is easily caused when multi-threaded multi-gateway executes instructions, and performs instruction processing by exclusively occupying the gateway identifier, avoiding competition between multiple working threads, and improving the system concurrency performance.
[0135] It should be noted that the instruction processing device provided in the above embodiment only uses the division of the above functional modules as an example when executing the instruction processing method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the instruction processing device provided in the above embodiment and the instruction processing method embodiment belong to the same concept, and the implementation process thereof is detailed in the method embodiment, which will not be repeated here.
[0136] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0137] The present application also provides a computer storage medium, which can store multiple instructions, and the instructions are suitable for being loaded and executed by a processor as described above. Figure 1 - Figure 6 The instruction processing method of the embodiment shown in the figure can be found in the specific execution process. Figure 1 - Figure 6 The specific description of the illustrated embodiment will not be repeated here.
[0138] The present application also provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor as described above. Figure 1 - Figure 6 The instruction processing method of the embodiment shown in the figure can be found in the specific execution process. Figure 1 - Figure 6 The specific description of the illustrated embodiment will not be repeated here.
[0139] See also Figure 8 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 8 As shown, the electronic device 500 may include: at least one processor 501 , at least one network interface 504 , a user interface 503 , a memory 505 , and at least one communication bus 502 .
[0140] The communication bus 502 is used to realize the connection and communication between these components.
[0141] The user interface 503 may include a display screen (Display) and a camera (Camera), and the optional user interface 503 may also include a standard wired interface and a wireless interface.
[0142] The network interface 504 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).
[0143] Among them, the processor 501 may include one or more processing cores. The processor 501 uses various interfaces and lines to connect various parts within the entire server 500, and executes various functions and processes data of the server 500 by running or executing instructions, programs, code sets or instruction sets stored in the memory 505, and calling data stored in the memory 505. Optionally, the processor 501 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), thread programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 501 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 501, and it can be implemented separately through a chip.
[0144] Among them, the memory 505 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 505 includes a non-transitory computer-readable storage medium. The memory 505 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 505 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 505 may also be optionally at least one storage device located away from the aforementioned processor 501. As Figure 8 As shown, the memory 505 as a computer storage medium may include an operating system, a network communication module, a user interface module, and an instruction processing application.
[0145] exist Figure 8In the electronic device 500 shown, the user interface 503 is mainly used to provide an input interface for the user and obtain data input by the user; and the processor 501 can be used to call the instruction processing application stored in the memory 505 and specifically perform the following operations:
[0146] Determine at least one target working thread to be executed among the N working threads;
[0147] According to at least one unoccupied target gateway identifier among the M gateway identifiers, obtaining and locking the target gateway identifier corresponding to each of the target work threads, wherein M is a positive integer, the M gateway identifiers correspond to M gateways, and each of the gateway identifiers corresponds to a pending instruction list including a plurality of pending instructions;
[0148] Run the target work thread, and process multiple pending instructions in the pending instruction list corresponding to the target work thread in sequence according to the gateway corresponding to the target work thread, until a preset condition is met, stop running and restore the target work thread to be running, and release the target gateway flag as unoccupied;
[0149] Repeat the above steps until the to-be-processed instruction lists corresponding to the M gateway identifiers are processed.
[0150] In one embodiment, before the processor 501 performs the step of determining at least one target working thread to be executed among the N working threads, the processor 501 further performs:
[0151] receiving a plurality of pending instructions;
[0152] According to the gateway identifier corresponding to each of the pending instructions and the pending instruction lists corresponding to the M gateway identifiers, the pending instructions are distributed to the pending instruction lists corresponding to the pending instructions.
[0153] In one embodiment, the processor 501 executes according to the gateway identifier corresponding to each of the pending instructions, and the list of pending instructions corresponding to the M gateway identifiers, before distributing the pending instructions to the list of pending instructions corresponding to the pending instructions, further executing:
[0154] Pushing multiple pending instructions to a message queue through an instruction producer, wherein the message queue represents a distribution order corresponding to the multiple pending instructions;
[0155] The processor 501 executes, according to the gateway identifier corresponding to each of the pending instructions and the pending instruction lists corresponding to the M gateway identifiers, the pending instructions are distributed to the pending instruction lists corresponding to the pending instructions, specifically performing:
[0156] According to the gateway identifier corresponding to each of the pending instructions and the pending instruction lists corresponding to the M gateway identifiers, the multiple pending instructions are distributed in sequence to the pending instruction lists corresponding to the pending instructions by the instruction consumer in the distribution order.
[0157] In one embodiment, the processor 501 executes the method of obtaining and locking the target gateway identifier corresponding to each of the target working threads according to at least one unoccupied target gateway identifier among the M gateway identifiers, specifically performing:
[0158] Determine at least one unoccupied target gateway identifier among the M gateway identifiers;
[0159] Any one of the target gateway identifiers is allocated to each of the target work threads, so that the target work thread receives and locks the target gateway identifier corresponding to the target work thread.
[0160] In one embodiment, the processor 501 executes and runs the target work thread, and according to the gateway corresponding to the target work thread, sequentially processes multiple pending instructions in the pending instruction list corresponding to the target work thread until a preset condition is met, stops running and restores the target work thread to be run, and releases the target gateway flag as unoccupied, specifically performing:
[0161] Run the target work thread, use the target gateway identifier received by the target work thread as a key, read the pending instructions in the pending instruction list corresponding to the target work thread in sequence according to the processing order, and distribute them to the gateway corresponding to the target work thread for processing, until the preset conditions are met, stop running and restore the target work thread to wait, and release the target gateway identifier as unoccupied.
[0162] In one embodiment, after the processor 501 executes the step of obtaining and locking the target gateway identifier corresponding to each of the target working threads according to at least one unoccupied target gateway identifier among the M gateway identifiers, it further executes:
[0163] The status information corresponding to the M gateway identifiers is recorded in a status information set, and the status information set is stored in a preset database. The status information of the gateway identifier is used to indicate that the gateway identifier is unoccupied or has been claimed by the target working thread.
[0164] In one embodiment, the processor 501 further executes:
[0165] After the processor restarts the service, acquiring the state information set from the database;
[0166] The gateway identification is restored to a corresponding state according to the state information of each gateway identification in the state information set, and the N working threads continue to run to process the to-be-processed instruction lists respectively corresponding to the M gateway identifications.
[0167] The processor of the instruction processing method of the present application can run N working threads at the same time, that is, it has the ability of multi-threaded concurrency. Determine at least one target working thread to be run among the N working threads, and collect and lock the unoccupied target gateway identifier corresponding to each target working thread, that is, the present application can realize multi-gateway concurrent instruction processing. Further run the target working thread, and process the multiple pending instructions corresponding to the target working thread in turn according to the gateway corresponding to the target working thread, that is, the present application can realize the instruction processing of a single gateway serial. Until the preset conditions are met, stop running and restore the target working thread to be run, and release the target gateway identifier as unoccupied, repeat the above steps until the list of pending instructions corresponding to the M gateway identifiers is processed. In other words, the present application realizes multi-gateway concurrent and single-gateway serial instruction processing, improves the efficiency of multi-instruction processing, and solves the blocking problem that is easily caused when multi-threaded multi-gateway executes instructions, and performs instruction processing by exclusively occupying the gateway identifier, avoiding competition between multiple working threads, and improving the system concurrency performance.
[0168] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0169] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of the present application.
[0170] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A command processing method, characterized in that: The method is executed by a processor, the processor can run N working threads simultaneously, N is a positive integer, and the method includes: Determine at least one target working thread to be executed among the N working threads; According to at least one unoccupied target gateway identifier among the M gateway identifiers, obtaining and locking the target gateway identifier corresponding to each of the target work threads, wherein M is a positive integer, the M gateway identifiers correspond to M gateways, and each of the gateway identifiers corresponds to a pending instruction list including a plurality of pending instructions; Run the target work thread, and process multiple pending instructions in the pending instruction list corresponding to the target work thread in sequence according to the gateway corresponding to the target work thread, until a preset condition is met, stop running and restore the target work thread to be running, and release the target gateway flag as unoccupied; Repeat the above steps until the to-be-processed instruction lists corresponding to the M gateway identifiers are processed.
2. The instruction processing method according to claim 1, characterized in that: Before determining at least one target working thread to be executed among the N working threads, the method further includes: receiving a plurality of pending instructions; According to the gateway identifier corresponding to each of the pending instructions and the pending instruction lists corresponding to the M gateway identifiers, the pending instructions are distributed to the pending instruction lists corresponding to the pending instructions.
3. The instruction processing method according to claim 2, characterized in that: The method further includes: before distributing the to-be-processed instructions to the to-be-processed instruction lists corresponding to the to-be-processed instructions according to the gateway identifiers corresponding to the to-be-processed instructions and the to-be-processed instruction lists corresponding to the M gateway identifiers respectively. Pushing multiple pending instructions to a message queue through an instruction producer, wherein the message queue represents a distribution order corresponding to the multiple pending instructions; The step of distributing the to-be-processed instructions to the to-be-processed instruction lists corresponding to the to-be-processed instructions according to the gateway identifiers corresponding to the to-be-processed instructions and the to-be-processed instruction lists corresponding to the M gateway identifiers respectively includes: According to the gateway identifier corresponding to each of the pending instructions and the pending instruction lists corresponding to the M gateway identifiers, the multiple pending instructions are distributed in sequence to the pending instruction lists corresponding to the pending instructions by the instruction consumer in the distribution order.
4. The instruction processing method according to claim 1, characterized in that: The step of acquiring and locking the target gateway identifier corresponding to each of the target working threads according to at least one unoccupied target gateway identifier among the M gateway identifiers includes: Determine at least one unoccupied target gateway identifier among the M gateway identifiers; Any one of the target gateway identifiers is allocated to each of the target work threads, so that the target work thread receives and locks the target gateway identifier corresponding to the target work thread.
5. The instruction processing method according to claim 1 or 4, characterized in that: The running of the target work thread, according to the gateway corresponding to the target work thread, sequentially processing a plurality of pending instructions in a pending instruction list corresponding to the target work thread, until a preset condition is met, stopping the running and restoring the target work thread to be run, and releasing the target gateway mark as unoccupied, includes: Run the target work thread, use the target gateway identifier received by the target work thread as a key, read the pending instructions in the pending instruction list corresponding to the target work thread in sequence according to the processing order, and distribute them to the gateway corresponding to the target work thread for processing, until the preset conditions are met, stop running and restore the target work thread to wait, and release the target gateway identifier as unoccupied.
6. The instruction processing method according to claim 1, characterized in that: After obtaining and locking the target gateway identifier corresponding to each of the target work threads according to at least one unoccupied target gateway identifier among the M gateway identifiers, the method further includes: The status information corresponding to the M gateway identifiers is recorded in a status information set, and the status information set is stored in a preset database. The status information of the gateway identifier is used to indicate that the gateway identifier is unoccupied or has been claimed by the target working thread.
7. The instruction processing method according to claim 7, characterized in that: The method further comprises: After the processor restarts the service, acquiring the state information set from the database; The gateway identification is restored to a corresponding state according to the state information of each gateway identification in the state information set, and the N working threads continue to run to process the to-be-processed instruction lists respectively corresponding to the M gateway identifications.
8. An instruction processing device, characterized in that: The instruction processing device can run N working threads simultaneously, where N is a positive integer, and the device includes: A first processing module, used to determine at least one target working thread to be executed among the N working threads; A second processing module is used to obtain and lock the target gateway identifier corresponding to each of the target work threads according to at least one unoccupied target gateway identifier among the M gateway identifiers, where M is a positive integer, and each of the gateway identifiers corresponds to a pending instruction list including a plurality of pending instructions; A third processing module is used to run the target work thread, and according to the gateway corresponding to the target work thread, sequentially process multiple pending instructions in the pending instruction list corresponding to the target work thread, until a preset condition is met, stop running and restore the target work thread to be run, and release the target gateway flag as unoccupied; The fourth processing module is used to repeat the above steps until the to-be-processed instruction lists corresponding to the M gateway identifiers are processed completely.
9. A computer storage medium, characterized in that The computer storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the method steps according to any one of claims 1 to 7.
10. An electronic device, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps as claimed in any one of claims 1 to 7.
