CN116795565A - Thread processing method and device, electronic equipment and storage medium - Google Patents

Thread processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN116795565A
CN116795565A CN202310715166.0A CN202310715166A CN116795565A CN 116795565 A CN116795565 A CN 116795565A CN 202310715166 A CN202310715166 A CN 202310715166A CN 116795565 A CN116795565 A CN 116795565A
Authority
CN
China
Prior art keywords
event
state information
thread
target
subscription
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310715166.0A
Other languages
Chinese (zh)
Inventor
董乾钦
姚杰
王森
刘志勇
王浩
张菊
胡一智
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Supcon Technology Co Ltd
Original Assignee
Zhejiang Supcon Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Supcon Technology Co Ltd filed Critical Zhejiang Supcon Technology Co Ltd
Priority to CN202310715166.0A priority Critical patent/CN116795565A/en
Publication of CN116795565A publication Critical patent/CN116795565A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/542Event management; Broadcasting; Multicasting; Notifications
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application discloses a thread processing method, a thread processing device, electronic equipment and a storage medium. Wherein the method comprises the following steps: acquiring event state information issued by a common event set; synchronizing event state information to a subscription event set, wherein the event state information comprises event states of a plurality of events; and operating the target thread under the condition that the event state information in the subscription event set meets the operation condition of the target thread, wherein the target thread and the subscription event set have a mapping relation. The application solves the technical problem that the event is cleared after the waiting event of a certain thread is met due to the common event set in the real-time system, and the influence is generated on the threads of other waiting events and the thread waiting event.

Description

Thread processing method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of embedded real-time operating systems, and in particular, to a thread processing method, device, electronic device, and storage medium.
Background
The general event uses (32/64) bit to shape the data storage (32/64) event states, when some event is triggered by a sending thread, the bit corresponding to the event is set, a receiving thread can wait for a plurality of events or any event in the plurality of events, when the event trigger detects that the set event meets the condition of some receiving thread, the receiving thread wakes up, and the receiving thread continues to run after being waken up. If the waiting thread sets the clearing mark, the bit corresponding to the waiting event is cleared after the waiting event is satisfied.
Because the same shared event data object is used for recording the states of a plurality of events, any thread waiting for the event can affect other threads after meeting the operation of the event, and the plurality of threads can often make different operations on the event according to different purposes, so that the existing event mechanism can not meet the requirements.
In view of the above problems, no effective solution has been proposed at present.
Disclosure of Invention
The embodiment of the application provides a thread processing method, a device, electronic equipment and a storage medium, which at least solve the technical problem that after a certain thread waiting event is met due to a shared event set in a real-time system, an event is cleared, and other waiting events are influenced by threads overlapped with the thread waiting event.
According to an aspect of an embodiment of the present application, there is provided a method for processing a thread, including: acquiring event state information issued by a common event set; synchronizing event state information to a subscription event set, wherein the event state information comprises event states of a plurality of events; and operating the target thread under the condition that the event state information in the subscription event set meets the operation condition of the target thread, wherein the target thread and the subscription event set have a mapping relation.
Optionally, synchronizing the event state information to the subscription event set includes: identifying whether event state information in the common event set is changed; under the condition that the event state information in the common event set is changed, updated event state information in the common event set is acquired, and the updated event state information is synchronized to the subscription event set.
Optionally, synchronizing the event state information to the subscription event set includes: judging whether event state information in a common event set is changed in a preset time interval or not; under the condition that the event state information in the common event set is not changed within a preset time interval, acquiring the event state information in the common event set; and synchronizing the event state information in the common event set to the subscription event set.
Optionally, determining that the event state information in the subscription event set satisfies the running condition of the target thread is determined in the following cases: acquiring a target event and operation logic indicated by the operation condition of a target thread; determining the event state of a target event in event state information in a subscription event set; under the condition that the operation logic is first logic and the event states of the target events are triggered, determining that the event state information in the subscription event set meets the operation condition of the target thread, wherein the first logic is logic AND; and under the condition that the operation logic is second logic and any event state in the target event is triggered, determining that the event state information in the subscription event set meets the operation condition of the target thread, wherein the second logic is logic OR.
Optionally, running the target thread includes: determining the number of target threads with mapping relation with the subscription event set; under the condition that the number is larger than 1, acquiring a plurality of target threads, and determining the execution sequence of each target thread in a thread queue, wherein the thread queue is used for storing threads associated with a subscription event set; and running the target threads sequentially according to the execution sequence.
Optionally, after running the target thread, the method further comprises: acquiring a target event indicated by the running condition of the target thread, wherein the event state of the target event is the running condition of the target thread; initializing target event state information of target events in a subscription event set, wherein the target event state information is an event state corresponding to the target events.
Optionally, after running the target thread, the method further comprises: and deleting the mapping relation between the target thread and the subscription event set.
Optionally, the method further comprises: identifying whether event state information in a common event set is in a triggered state; and initializing the event state information in the common event set under the condition that the event state information in the common event set is in a triggered state.
According to another aspect of the embodiment of the present application, there is also provided a processing apparatus for a thread, including: the acquisition module is used for acquiring event state information issued by the common event set; the synchronization module is used for synchronizing the event state information to a subscription event set, wherein the event state information comprises event states of a plurality of events; and the operation module is used for operating the target thread under the condition that the event state information in the subscription event set meets the operation condition of the target thread, wherein the target thread and the subscription event set have a mapping relation.
According to still another aspect of the embodiment of the present application, there is also provided an electronic device including: a memory for storing program instructions; a processor coupled to the memory for executing program instructions that perform the following functions: acquiring event state information issued by a common event set; synchronizing event state information to a subscription event set, wherein the event state information comprises event states of a plurality of events; and operating the target thread under the condition that the event state information in the subscription event set meets the operation condition of the target thread, wherein the target thread and the subscription event set have a mapping relation.
According to still another aspect of the embodiment of the present application, there is further provided a nonvolatile storage medium, where the nonvolatile storage medium includes a stored computer program, and a device where the nonvolatile storage medium is located executes the processing method of the thread by running the computer program.
In the embodiment of the application, the event state information issued by the common event set is acquired; synchronizing event state information to a subscription event set, wherein the event state information comprises event states of a plurality of events; under the condition that the event state information in the subscription event set meets the running condition of the target thread, the target thread is run, wherein the target thread and the subscription event set have a mapping relation, the purpose that the event mark in the corresponding subscription event set is only required to be cleared after the event of the thread is met through the association of the subscription event set and the thread is achieved, the technical effect that other threads are not affected is achieved, and the technical problem that the event is cleared after a certain thread waits for the event to be met due to the fact that the event set is shared in a real-time system, and the influence is caused on the threads with the other waiting events overlapped with the thread waiting events is solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this specification, illustrate embodiments of the application and together with the description serve to explain the application and do not constitute a limitation on the application. In the drawings:
FIG. 1a is a schematic diagram of a thread versus event according to an embodiment of the present application;
FIG. 1b is a schematic diagram of an AND-type event trigger mechanism in the related art;
FIG. 1c is a schematic diagram of an OR-type event trigger mechanism in the related art;
FIG. 2 is a block diagram of a hardware architecture of a computer terminal for implementing a processing method for threads according to an embodiment of the application;
FIG. 3 is a flow chart of a method of processing a thread according to an embodiment of the application;
FIG. 4a is a schematic diagram of a logic and type event trigger mechanism according to an embodiment of the present application;
FIG. 4b is a schematic diagram of a logic or type event trigger mechanism according to an embodiment of the present application;
fig. 5 is a block diagram of a processing device for a thread according to an embodiment of the present application.
Detailed Description
In order that those skilled in the art will better understand the present application, a technical solution in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present application without making any inventive effort, shall fall within the scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the application described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
First, partial terms or terminology appearing in the course of explaining the embodiments of the present application are applicable to the following explanation:
an embedded real-time system: when external events or data are generated, the processing results can be accepted and processed quickly enough, and the processing results can control the production process or make quick response to the processing system within the specified events, and control all devices for controlling, monitoring or assisting in operating machines and equipment, wherein the devices are used for controlling, monitoring or assisting in operating in a consistent mode.
Thread synchronization: a mechanism to control ordered access of multiple threads to competing resources.
Events: a mechanism for thread synchronization.
Ready queue: waiting for a set of threads to be run by the CPU.
And (3) issuing: the publisher sends the event to a central point (commonly referred to as a message queue or topic or thread queue).
Subscription: subscribers subscribe to events of interest from the central point.
In the related art, as shown in fig. 1a, a waiting thread is mounted on a waiting queue of an event, each thread internally maintains one waiting event data and a triggering event data, and if the triggering event data is consistent with the waiting event data of some threads in the queue and meets the waiting requirement (including an ' and ' type or ' type waiting requirement type), the thread meeting the event data consistency condition is pushed out of the waiting queue to be added into the thread ready queue and triggered to be scheduled and waiting for the thread to be executed by the CPU. In the AND type event waiting mechanism, if and only if multiple events waiting by a thread are triggered, the thread stops waiting for continued execution and clears the corresponding bit of the event record variable in the event object. As shown in fig. 1b, the thread 1 AND the thread 2 set the bit of the event with the sequence numbers 1, 3 AND 29 in the event set to be 1, AND since the event trigger condition of the thread 3 is an AND type, that is, an AND type, AND the operating condition of the thread 3 is that the bit of the event with the sequence numbers 1, 3 AND 29 is set to be 1, when the thread 3 satisfies the operating condition AND is executed, the bit of the event with the sequence numbers 1, 3 AND 29 in the event set is set to be 0. In the or type event waiting mechanism, when any event of a plurality of events waiting by a thread is triggered, the thread stops waiting for continuous execution and clears the corresponding bit of the event record variable in the event object. As shown in fig. 1c, the bit of the event with the sequence number 29 in the event set is set to 1 by the thread 1, the event triggering condition of the thread 2 is OR, that is, the OR type, when the bit of any event with the sequence number 1 OR 29 in the thread 2 is set to 1, the thread 2 can be executed, because the event with the sequence number 29 is triggered to run by the thread 2 in fig. 1c, and when the thread 2 is executed, the bit of the event with the sequence number 29 in the event set is set to 0.
The problems existing in the related art can be illustrated by the following scenario: thread 1 waits for events 1, 2, 3 and the behavior of waiting to suspend the thread is in the loop body, thread 2 waits for events 1, 2, 4, when the event waiting for thread 1 is satisfied, the corresponding event bit 1, 2, 3 in the event set needs to be cleared, then event 4 is triggered, and thread 2 should be satisfied under normal logic, but since events 1, 2 have been cleared by thread 1, thread 2 needs to continue waiting for events 1, 2 to be triggered again.
In order to solve the problem that the clearing event affects the threads with other waiting events coincident with the thread waiting event after the thread waiting event is satisfied due to the common event set in the real-time system, the embodiment of the application provides an accompanying event synchronization mechanism in the real-time operating system, which is described in detail below.
The embodiment of the method for processing the thread provided by the embodiment of the application can be executed in a mobile terminal, a computer terminal or similar computing devices. Fig. 2 shows a block diagram of the hardware architecture of a computer terminal for implementing a processing method for threads. As shown in fig. 2, the computer terminal 20 may include one or more (shown as 202a, 202b, … …,202 n) processors (which may include, but are not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 204 for storing data, and a transmission module 206 for communication functions. In addition, the method may further include: a display, an input/output interface (I/O interface), a Universal Serial Bus (USB) port (which may be included as one of the ports of the I/O interface), a network interface, a power supply, and/or a camera. It will be appreciated by those of ordinary skill in the art that the configuration shown in fig. 2 is merely illustrative and is not intended to limit the configuration of the electronic device described above. For example, the computer terminal 20 may also include more or fewer components than shown in FIG. 2, or have a different configuration than shown in FIG. 2.
It should be noted that the one or more processors and/or other data processing circuits described above may be referred to herein generally as "data processing circuits. The data processing circuit may be embodied in whole or in part in software, hardware, firmware, or any other combination. Furthermore, the data processing circuitry may be a single stand-alone processing module or incorporated, in whole or in part, into any of the other elements in the computer terminal 20. As referred to in embodiments of the application, the data processing circuit acts as a processor control (e.g., selection of the path of the variable resistor termination connected to the interface).
The memory 204 may be used to store software programs and modules of application software, such as program instruction/data storage devices corresponding to the processing methods of threads in the embodiments of the present application, and the processor executes the software programs and modules stored in the memory 204, thereby executing various functional applications and data processing, that is, implementing the processing methods of threads described above. Memory 204 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 204 may further include memory located remotely from the processor, which may be connected to the computer terminal 20 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission module 206 is used to receive or transmit data via a network. The specific examples of the network described above may include a wireless network provided by a communication provider of the computer terminal 20. In one example, the transmission module 206 includes a network adapter (Network Interface Controller, NIC) that can connect to other network devices through a base station to communicate with the internet. In one example, the transmission module 206 may be a Radio Frequency (RF) module, which is configured to communicate with the internet wirelessly.
The display may be, for example, a touch screen type Liquid Crystal Display (LCD) that may enable a user to interact with a user interface of the computer terminal 20.
It should be noted here that, in some alternative embodiments, the computer terminal shown in fig. 2 described above may include hardware elements (including circuits), software elements (including computer code stored on a computer readable medium), or a combination of both hardware elements and software elements. It should be noted that fig. 2 is only one example of a specific example, and is intended to illustrate the types of components that may be present in the computer terminal described above.
In the above-described operating environment, the embodiments of the present application provide an embodiment of a method of processing threads, it being noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system, such as a set of computer-executable instructions, and that although a logical order is illustrated in the flowcharts, in some cases the steps illustrated or described may be performed in an order other than that illustrated herein.
FIG. 3 is a flow chart of a method of processing a thread according to an embodiment of the application, as shown in FIG. 3, the method comprising the steps of:
step S302, obtaining event state information issued by a common event set.
Step S304, synchronizing the event state information to a subscription event set, wherein the event state information comprises event states of a plurality of events.
Step S306, operating the target thread under the condition that the event state information in the subscription event set meets the operation condition of the target thread, wherein the target thread and the subscription event set have a mapping relation.
In the above steps S302 to S306, the common event set is used to store event state information, so that when the event state in the common event set meets the running condition of a certain thread, the event state information in the common event set is not modified.
In the embodiment of the application, the event state information issued by the common event set is acquired; synchronizing event state information to a subscription event set, wherein the event state information comprises event states of a plurality of events; under the condition that the event state information in the subscription event set meets the running condition of the target thread, the target thread is run, wherein the target thread and the subscription event set have a mapping relation, the purpose that the event mark in the corresponding subscription event set is only required to be cleared after the event of the thread is met through the association of the subscription event set and the thread is achieved, the technical effect that other threads are not affected is achieved, and the technical problem that the event is cleared after a certain thread waits for the event to be met due to the fact that the event set is shared in a real-time system, and the influence is caused on the threads with the other waiting events overlapped with the thread waiting events is solved.
In step S304 in the above thread processing method, the event state information is synchronized to the subscription event set, and specifically includes the following steps: identifying whether event state information in the common event set is changed; under the condition that the event state information in the common event set is changed, updated event state information in the common event set is acquired, and the updated event state information is synchronized to the subscription event set.
In the embodiment of the application, because the event state information in the common event set needs to be synchronized to the subscription event set, the event state information in the common event set needs to be determined, namely, the updated event state information in the common event set is synchronized to the subscription event set under the condition that the event state information in the common event set is changed, so that the subscription event set is ensured to be consistent with the event state information in the common event set in time under the condition that the common event set is updated, and then the threads are operated in time under the condition that the event state in the subscription event set meets the operation conditions of the threads.
In step S304 in the above thread processing method, the event state information is synchronized to the subscription event set, and specifically includes the following steps: judging whether event state information in a common event set is changed in a preset time interval or not; under the condition that the event state information in the common event set is not changed within a preset time interval, acquiring the event state information in the common event set; and synchronizing the event state information in the common event set to the subscription event set.
In some embodiments of the present application, the waiting thread is mounted in a waiting queue, where the waiting queue may include a plurality of waiting threads, when one subscription event set corresponds to one waiting queue, it is determined whether an event state in the subscription event set satisfies an operation condition of a first thread disposed at a forefront in the waiting queue, when the event state in the subscription event set satisfies the operation condition of the first thread, the first thread modifies the event state in the subscription event set after operation, in this case, if the common event state does not change within a preset time interval, other threads having overlapping events with the first thread in the waiting queue cannot operate because the event state of the overlapping events is cleared, so, in order to solve the above problem, in order to ensure a normal operation condition judgment of other threads in the waiting queue, event state information in the common event set needs to be acquired again, and event state information in the common event set is synchronized to the subscription event set.
In step S306 in the above-described thread processing method, it is determined that the event state information in the subscription event set satisfies the running condition of the target thread in the following case: acquiring a target event and operation logic indicated by the operation condition of a target thread; determining the event state of a target event in event state information in a subscription event set; under the condition that the operation logic is first logic and the event states of the target events are triggered, determining that the event state information in the subscription event set meets the operation condition of the target thread, wherein the first logic is logic AND; and under the condition that the operation logic is second logic and any event state in the target event is triggered, determining that the event state information in the subscription event set meets the operation condition of the target thread, wherein the second logic is logic OR.
In the embodiment of the application, when determining whether the event state information in the subscription event set meets the running condition of the target thread, the target event and the running logic indicated by the running condition of the target thread are required to be acquired first.
When the running logic is the first logic, i.e. logical AND, the explanation is given taking FIG. 4a as an example. In fig. 4a, the target thread is thread 3, the running condition of thread 3 is that the bits of the events at the positions of sequence numbers 1, 3 AND 29 are all set to 1, the target events are the events at the positions of sequence numbers 1, 3 AND 29, AND the running logic of thread 3 is logic AND (AND), AND the event states of the target events in the subscription event set are all triggered, at this time, the event state information in the subscription event set meets the running condition of thread 3.
When the operating logic is a second logic, i.e. logical OR, it is illustrated by way of example in FIG. 4 b. In fig. 4b, the target thread is thread 2, the running condition of thread 2 is that the bit of the event at the position of sequence number 1 OR 29 is set to 1, the target event is the event at the position of sequence number 1 OR 29, because the running logic of thread 2 is logic OR (OR), and the event at the position of sequence number 29 in the subscription event set is triggered, at this time, the event state information in the subscription event set satisfies the running condition of thread 2.
In step S306 in the above thread processing method, the target thread is run, which specifically includes the following steps: determining the number of target threads with mapping relation with the subscription event set; under the condition that the number is larger than 1, acquiring a plurality of target threads, and determining the execution sequence of each target thread in a thread queue, wherein the thread queue is used for storing threads associated with a subscription event set; and running the target threads sequentially according to the execution sequence.
In the embodiment of the application, one subscription event set can correspond to a plurality of target threads, the plurality of target threads are in a thread queue, namely, one subscription event set corresponds to one thread queue, under the condition that one subscription event set corresponds to a plurality of target threads, whether the event state information in the subscription event set meets the running condition of the threads in the current execution sequence or not is sequentially determined according to the execution sequence of the threads in the thread queue, if so, the target threads in the current execution sequence are run, and if not, whether the event state information in the subscription event set meets the running condition of the next thread in the thread queue is determined, so that whether the running condition required by the threads in the current execution sequence is met by the subscription event set is sequentially judged in the thread queue according to the execution sequence.
In step S306 in the above-mentioned thread processing method, after the target thread is executed, the method further includes the following steps: acquiring a target event indicated by the running condition of the target thread, wherein the event state of the target event is the running condition of the target thread; initializing target event state information of target events in a subscription event set, wherein the target event state information is an event state corresponding to the target events.
In the embodiment of the application, under the condition that the subscription event set meets the running condition of the target thread, the target thread is run, and the event state information of the subscription event set at the target time corresponding to the running condition of the target thread is initialized. Taking the above fig. 4a as an example for explanation, the bit of the event at the position where the serial numbers 1, 3 and 29 are located in the subscription event set is set to be 1, the operation condition corresponding to the thread 3 is satisfied, and after the thread 3 operates, the event state information at the position where the serial numbers 1, 3 and 29 are located in the subscription event set is initialized, i.e. the bit of the event at the position where the serial numbers 1, 3 and 29 are located in the subscription event set is set to be 0 from 1.
In step S306 in the above-mentioned thread processing method, after the target thread is executed, the method further includes: and deleting the mapping relation between the target thread and the subscription event set.
In the embodiment of the application, as the thread does not need to run repeatedly, the mapping relation between the target thread and the subscribed event set subscribed by the target thread can be deleted after the target thread runs. Thus, when one subscription event set corresponds to one thread queue, a target thread in the current execution sequence in the thread queue is executed and deleted from the thread queue, namely, the mapping relation between the target thread and the subscription event set is deleted, when the common event set and the subscription event set are changed again, whether the operation condition of a subsequent thread in the thread queue is met or not can be judged according to the event state information in the subscription event set, if the mapping relation is not deleted, when the event state information in the subscription event set is changed, whether the operation condition of a first thread in the thread queue is met or not needs to be judged each time, and the execution efficiency of other processes can be influenced.
In step S306 in the above-mentioned thread processing method, the method further includes the following steps: identifying whether event state information in a common event set is in a triggered state; and initializing the event state information in the common event set under the condition that the event state information in the common event set is in a triggered state.
In the embodiment of the present application, in general, 32 or 64 event states are stored using 32 or 64-bit integer data, that is, at most 32 or 64 event state information can be stored in a common event set and a subscription event set, where when all event state information in the common event set is triggered, that is, when bits of events in the common event set are set to 1, after corresponding threads are all run, it is necessary to initialize the event state information in the common event set, that is, bits of events in the common event set are set to 0.
According to the thread processing method provided by the embodiment of the application, the requirements and the operations of each thread are stored through the subscription event set, and after the thread waiting event is satisfied, the satisfied event mark is only required to be cleared from the event data of the subscription event set corresponding to the current thread, so that no influence is generated on the data in the subscription event sets corresponding to other threads.
FIG. 5 is a block diagram of a thread processing apparatus according to an embodiment of the present application, as shown in FIG. 5, the apparatus including:
an obtaining module 52, configured to obtain event status information issued by the common event set;
a synchronization module 54, configured to synchronize event status information to a subscription event set, where the event status information includes event statuses of a plurality of events;
the running module 56 is configured to run the target thread if the event status information in the subscription event set meets the running condition of the target thread, where the target thread has a mapping relationship with the subscription event set.
The synchronization module in the thread processing device is also used for identifying whether the event state information in the common event set is changed or not; under the condition that the event state information in the common event set is changed, updated event state information in the common event set is acquired, and the updated event state information is synchronized to the subscription event set.
In the synchronization module in the thread processing device, the synchronization module is further configured to determine whether the event state information in the common event set is changed within a preset time interval; under the condition that the event state information in the common event set is not changed within a preset time interval, acquiring the event state information in the common event set; and synchronizing the event state information in the common event set to the subscription event set.
In the operation module in the processing device of the thread, the operation module is further configured to determine that the event state information in the subscription event set meets the operation condition of the target thread when: acquiring a target event and operation logic indicated by the operation condition of a target thread; determining the event state of a target event in event state information in a subscription event set; under the condition that the operation logic is first logic and the event states of the target events are triggered, determining that the event state information in the subscription event set meets the operation condition of the target thread, wherein the first logic is logic AND; and under the condition that the operation logic is second logic and any event state in the target event is triggered, determining that the event state information in the subscription event set meets the operation condition of the target thread, wherein the second logic is logic OR.
In the operation module in the thread processing device, the operation module is further used for determining the number of target threads with mapping relation with the subscription event set; under the condition that the number is larger than 1, acquiring a plurality of target threads, and determining the execution sequence of each target thread in a thread queue, wherein the thread queue is used for storing threads associated with a subscription event set; and running the target threads sequentially according to the execution sequence.
In the above-mentioned thread processing device, the thread processing device further includes a processing module 58, where the processing module is configured to obtain a target event indicated by an operation condition of the target thread, where an event state of the target event is the operation condition of the target thread; initializing target event state information of target events in a subscription event set, wherein the target event state information is an event state corresponding to the target events.
In the processing module in the thread processing device, the processing module is further configured to delete a mapping relationship between the target thread and the subscription event set.
In the processing module in the processing device of the thread, the processing module is further used for identifying whether the event state information in the common event set is in a triggered state; and initializing the event state information in the common event set under the condition that the event state information in the common event set is in a triggered state.
Note that, the processing apparatus for a thread shown in fig. 5 is used to execute the processing method for a thread shown in fig. 3, so the explanation of the processing method for a thread is also applicable to the processing apparatus for a thread, and is not repeated here.
The embodiment of the application also provides electronic equipment, which comprises: a memory for storing program instructions; a processor coupled to the memory for executing program instructions that perform the following functions: acquiring event state information issued by a common event set; synchronizing event state information to a subscription event set, wherein the event state information comprises event states of a plurality of events; and operating the target thread under the condition that the event state information in the subscription event set meets the operation condition of the target thread, wherein the target thread and the subscription event set have a mapping relation.
It should be noted that, the electronic device is configured to execute the processing method of the thread shown in fig. 3, so the explanation of the processing method of the thread is also applicable to the electronic device, and will not be repeated here.
The embodiment of the application also provides a nonvolatile storage medium, which comprises a stored computer program, wherein the equipment of the nonvolatile storage medium executes the processing method of the following threads by running the computer program: acquiring event state information issued by a common event set; synchronizing event state information to a subscription event set, wherein the event state information comprises event states of a plurality of events; and operating the target thread under the condition that the event state information in the subscription event set meets the operation condition of the target thread, wherein the target thread and the subscription event set have a mapping relation.
Note that, the above-mentioned nonvolatile storage medium is used to execute the processing method of the thread shown in fig. 3, so the explanation of the processing method of the thread is also applicable to the nonvolatile storage medium, and will not be repeated here.
The foregoing embodiment numbers of the present application are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
In the foregoing embodiments of the present application, the descriptions of the embodiments are emphasized, and for a portion of this disclosure that is not described in detail in this embodiment, reference is made to the related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed technology may be implemented in other manners. The above-described embodiments of the apparatus are merely exemplary, and the division of the units, for example, may be a logic function division, and may be implemented in another manner, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interfaces, units or modules, or may be in electrical or other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in part or all of the technical solution or in part in the form of a software product stored in a storage medium, including instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely a preferred embodiment of the present application and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the principles of the present application, which are intended to be comprehended within the scope of the present application.

Claims (11)

1. A method of processing a thread, comprising:
acquiring event state information issued by a common event set;
synchronizing the event state information to a subscription event set, wherein the event state information comprises event states of a plurality of events;
and operating the target thread under the condition that the event state information in the subscription event set meets the operation condition of the target thread, wherein the target thread and the subscription event set have a mapping relation.
2. The method of claim 1, wherein synchronizing the event state information to a subscription event set comprises:
identifying whether event state information in the common event set is changed;
under the condition that the event state information in the common event set is changed, updated event state information in the common event set is obtained, and the updated event state information is synchronized to the subscription event set.
3. The method of claim 1, wherein synchronizing the event state information to a subscription event set comprises:
judging whether the event state information in the common event set is changed in a preset time interval or not;
under the condition that the event state information in the common event set is not changed within a preset time interval, acquiring the event state information in the common event set;
and synchronizing the event state information in the common event set to the subscription event set.
4. The method of claim 1, wherein the event state information in the set of subscribed events is determined to satisfy the operating condition of the target thread when:
acquiring a target event and operation logic indicated by the operation condition of the target thread;
determining the event state of the target event in the event state information in the subscription event set;
determining that the event state information in the subscription event set meets the operation condition of the target thread under the condition that the operation logic is first logic and the event states of the target events are triggered;
and under the condition that the running logic is second logic and any event state in the target event is triggered, determining that the event state information in the subscription event set meets the running condition of the target thread, wherein the second logic is logic OR.
5. The method of claim 1, wherein running the target thread comprises:
determining the number of target threads having a mapping relation with the subscription event set;
acquiring a plurality of target threads and determining the execution sequence of each target thread in a thread queue under the condition that the number is greater than 1, wherein the thread queue is used for storing threads associated with the subscription event set;
and sequentially running the target threads according to the execution sequence.
6. The method of claim 1, wherein after running the target thread, the method further comprises:
acquiring a target event indicated by the running condition of the target thread, wherein the event state of the target event is the running condition of the target thread;
initializing target event state information of target events in the subscription event set, wherein the target event state information is an event state corresponding to the target events.
7. The method of claim 1, wherein after running the target thread, the method further comprises:
and deleting the mapping relation between the target thread and the subscription event set.
8. The method according to claim 1, wherein the method further comprises:
identifying whether event state information in the common event set is in a triggered state;
and initializing the event state information in the common event set under the condition that the event state information in the common event set is in a triggered state.
9. A thread processing apparatus, comprising:
the acquisition module is used for acquiring event state information issued by the common event set;
the synchronization module is used for synchronizing the event state information to a subscription event set, wherein the event state information comprises event states of a plurality of events;
and the operation module is used for operating the target thread under the condition that the event state information in the subscription event set meets the operation condition of the target thread, wherein the target thread and the subscription event set have a mapping relation.
10. An electronic device, comprising:
a memory for storing program instructions;
a processor, coupled to the memory, for executing program instructions that perform the following functions: acquiring event state information issued by a common event set; synchronizing the event state information to a subscription event set, wherein the event state information comprises event states of a plurality of events; and operating the target thread under the condition that the event state information in the subscription event set meets the operation condition of the target thread, wherein the target thread and the subscription event set have a mapping relation.
11. A non-volatile storage medium, characterized in that the non-volatile storage medium comprises a stored computer program, wherein the device in which the non-volatile storage medium is located performs the method of processing a thread according to any one of claims 1 to 8 by running the computer program.
CN202310715166.0A 2023-06-15 2023-06-15 Thread processing method and device, electronic equipment and storage medium Pending CN116795565A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310715166.0A CN116795565A (en) 2023-06-15 2023-06-15 Thread processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310715166.0A CN116795565A (en) 2023-06-15 2023-06-15 Thread processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116795565A true CN116795565A (en) 2023-09-22

Family

ID=88043137

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310715166.0A Pending CN116795565A (en) 2023-06-15 2023-06-15 Thread processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116795565A (en)

Similar Documents

Publication Publication Date Title
CN110825772A (en) Method and device for synchronizing memory data of multiple service instances and storage medium
CN112416969B (en) Parallel task scheduling system in distributed database
CN109766201A (en) Task distribution method, server, client and system
CN105629926A (en) Event generation management for an industrial controller
CN108959139A (en) A kind of CPLD pin multiplexing method and device
CN114201197A (en) Firmware upgrading method and device, electronic equipment and readable storage medium
CN105607940A (en) Method for transmitting information to UEFI BIOS from BDK in ARM platform
CN110990316A (en) Method and programmable logic circuit for outputting hot-swap device status
CN112069190B (en) Batch data acquisition method, device, equipment and medium
CN111078463A (en) Data backup method, device and system
CN116795565A (en) Thread processing method and device, electronic equipment and storage medium
CN110704198B (en) Data operation method, device, storage medium and processor
CN106569858A (en) Method for updating configuration files and circuit board
CN110096378A (en) A kind of inter-thread communication method and relevant apparatus
CN103176931B (en) A kind of DMA communication means of improvement and device
CN113381880B (en) Internet of things equipment management method, device and system
CN113965915A (en) Data processing method and electronic equipment
CN112286653A (en) Method and device for improving processing efficiency of acquired data and storage medium
CN110417593A (en) A kind of device management method and device
CN117539582B (en) Multi-process interface fusion method and device
CN110688231B (en) Method, device and system for processing read-write request statistical information
CN112866041B (en) Adaptive network system training method
KR100206461B1 (en) The embodiment and visualizing of process administration
CN113762821B (en) Cargo information processing method, device, equipment and storage medium
CN110489013B (en) Touch detection method, touch detection device and display panel

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination