[go: up one dir, main page]

CN118093212B - Synchronization method for multi-user task access global variable and related equipment - Google Patents

Synchronization method for multi-user task access global variable and related equipment Download PDF

Info

Publication number
CN118093212B
CN118093212B CN202410486705.2A CN202410486705A CN118093212B CN 118093212 B CN118093212 B CN 118093212B CN 202410486705 A CN202410486705 A CN 202410486705A CN 118093212 B CN118093212 B CN 118093212B
Authority
CN
China
Prior art keywords
target
global variable
value
user
user tasks
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.)
Active
Application number
CN202410486705.2A
Other languages
Chinese (zh)
Other versions
CN118093212A (en
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.)
Beijing Kongda Technology Co ltd
Original Assignee
Beijing Kongda 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 Beijing Kongda Technology Co ltd filed Critical Beijing Kongda Technology Co ltd
Priority to CN202410486705.2A priority Critical patent/CN118093212B/en
Publication of CN118093212A publication Critical patent/CN118093212A/en
Application granted granted Critical
Publication of CN118093212B publication Critical patent/CN118093212B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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 OR CALCULATING; 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/544Buffers; Shared memory; Pipes
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/546Message passing systems or structures, e.g. queues

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)
  • Multi Processors (AREA)

Abstract

The invention relates to the technical field of industrial automation control, in particular to a synchronization method and related equipment for accessing global variables by multi-user tasks, wherein the method comprises the steps of firstly identifying target global variables accessed by at least two user tasks; then, distributing one-to-one corresponding target buffer area addresses to target user tasks needing to access the target global variable; and sending the target global variable to a target buffer address, so that the target global variable is obtained from the corresponding target buffer address when a target user task runs, and after any one target user task modifies the value of the target global variable, updating the values of the target global variable in the target buffer addresses corresponding to other non-running target user tasks, thereby realizing the synchronization of global variables for a plurality of user tasks based on cache efficiency.

Description

Synchronization method for multi-user task access global variable and related equipment
Technical Field
The invention relates to the technical field of industrial automation control, in particular to a synchronization method for accessing global variables by multi-user tasks and related equipment.
Background
In the field of industrial automation control, users often need to create multiple user tasks according to engineering needs to efficiently implement control functions. The global variable is required to be shared by a plurality of user tasks, and aiming at synchronous access of the global variable, the currently adopted methods mainly comprise two types:
The first is the autonomous implementation for the user. Specifically, when a user programs a user task, synchronous access is automatically realized according to the read-write access requirement of the user task to the global variable, and a commonly adopted method comprises a flag bit, event notification and the like. Through the method, users can flexibly process according to actual demands, the access efficiency is high, but the method increases the complexity of user tasks and has higher requirements on users.
Second, the controller program is implemented through a lock mechanism. Specifically, the global variable is locked when being accessed, and the global variable is unlocked after the access is completed. By the method, users do not need to care about the synchronization problem of the global variables, the design difficulty of user tasks is reduced, but the access efficiency to the global variables is low under certain conditions, for example, some global variables can be accessed by only one user task. In addition, the method can only realize synchronous access of a single variable, and cannot meet the scene of the coordination synchronization of a plurality of global variables.
Disclosure of Invention
In view of the above, the present invention aims to provide a synchronization method and related equipment for accessing global variables by multi-user tasks, so as to solve the problems of high complexity of user tasks, low global variable access efficiency and failure to satisfy the coordination synchronization of multiple global variables when the global variables are accessed by multiple user tasks at present.
In order to achieve the above purpose, the invention adopts the following technical scheme:
in a first aspect, an embodiment of the present application provides a method for synchronizing access to global variables by a multi-user task, including:
Determining information of a target global variable, wherein the target global variable is a global variable which needs to be accessed by at least two user tasks, and the information of the target global variable comprises the value of the target global variable;
Determining at least two target buffer area addresses, wherein the target buffer area addresses are in one-to-one correspondence with target user tasks, and the target user tasks are user tasks needing to access the target global variable;
transmitting the value of the target global variable to all the target buffer addresses so that the target user task obtains the value of the target global variable from the corresponding target buffer address when running;
And updating the value of the target global variable in the target buffer addresses corresponding to other non-running target user tasks after any one of the target user tasks changes the value of the target global variable.
Further, the sending the value of the target global variable to all the target buffer addresses includes:
and sending the value of the target global variable positioned in the operation area to the target buffer area address through a preset controller.
Further, after any one of the target user tasks changes the value of the target global variable, updating the value of the target global variable in the target buffer addresses corresponding to other non-running target user tasks, including:
After any one of the target users changes the value of the target global variable, constructing a synchronous message, wherein the synchronous message comprises the value of the target global variable after modification;
and broadcasting the synchronous message to update the value of the target global variable in the target buffer addresses corresponding to other non-running target user tasks.
Further, the synchronization message further includes: and modifying the time information of the target global variable so that other non-running target user tasks modify the value of the target global variable in the corresponding target buffer address based on the latest time.
Further, the method further comprises the following steps:
monitoring the execution state of the target user task;
And updating the value of the target global variable in the operation area based on the value of the target global variable in the target cache area address when all the target user tasks are in the idle state.
Further, the number of the target global variables is a plurality, and the information of the target global variables further includes: the access relation between each target global variable and each target user task;
The sending the value of the target global variable to all the target buffer addresses includes: based on the access relation, sending a plurality of target global variables to target buffer addresses of corresponding target user tasks;
After any one of the target user tasks changes the value of the target global variable, updating the value of the target global variable in the target buffer addresses corresponding to other non-running target users, including: and after any one target user task changes the value of any one target global variable, updating the value of the target global variable in the target buffer addresses corresponding to other non-running target user tasks.
Further, the method further comprises the following steps:
Transmitting the information of the target global variable to a user, and receiving a synchronization method confirmation instruction transmitted by the user;
and confirming the instruction screening target global variables needing to be synchronized based on the synchronization method.
In a second aspect, an embodiment of the present application further provides a synchronization apparatus for accessing global variables by using a multi-user task, including:
The first confirmation module is used for determining information of a target global variable, wherein the target global variable is a global variable which needs to be accessed by at least two user tasks, and the information of the target global variable comprises the value of the target global variable;
The second determining module is used for determining at least two target buffer area addresses, the target buffer area addresses are in one-to-one correspondence with target user tasks, and the target user tasks are user tasks needing to access the target global variable;
The issuing module is used for sending the value of the target global variable to all the target buffer addresses so that the target user task obtains the value of the target global variable from the corresponding target buffer address when running;
And the updating module is used for updating the value of the target global variable in the target buffer addresses corresponding to other non-running target user tasks after any one of the target user tasks changes the value of the target global variable.
In a third aspect, an embodiment of the present application further provides an electronic device, including:
At least one processor; and
A memory communicatively coupled to the at least one processor; wherein,
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of synchronizing multi-user task access global variables of any one of the above.
In a fourth aspect, embodiments of the present application also provide a computer program product comprising a computer program which, when executed by a processor, implements a method of synchronizing multi-user task access global variables as described in any of the above.
The invention provides a synchronization method for accessing global variables by multi-user tasks, which comprises the steps of firstly identifying target global variables accessed by at least two user tasks; then, distributing one-to-one corresponding target buffer area addresses to target user tasks needing to access the target global variable; and sending the target global variable to a target buffer address, so that the target global variable is obtained from the corresponding target buffer address when a target user task runs, and after any one target user task modifies the value of the target global variable, updating the values of the target global variable in the target buffer addresses corresponding to other non-running target user tasks, thereby realizing the synchronization of global variables for a plurality of user tasks based on cache efficiency.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for synchronizing multi-user task access global variables provided by an embodiment of the present invention;
FIG. 2 is a layout diagram of global variables in a memory in a synchronization method for accessing global variables by multi-user tasks according to an embodiment of the present invention;
FIG. 3 is a flow chart of a method for synchronizing multi-user task access global variables according to another embodiment of the present invention;
FIG. 4 is a schematic diagram of a state change of a target global variable in a synchronization method for accessing global variables by a multi-user task according to another embodiment of the present invention;
FIG. 5 is a flow chart of a method for synchronizing multi-user task access global variables according to another embodiment of the present invention;
FIG. 6 is a flow chart illustrating a method for synchronizing multi-user task access global variables according to another embodiment of the present invention;
FIG. 7 is a schematic structural diagram of a synchronization apparatus for accessing global variables by multi-user tasks according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be described in detail below. It will be apparent that the described embodiments are only some, but not all, embodiments of the invention. All other embodiments, based on the examples herein, which are within the scope of the invention as defined by the claims, will be within the scope of the invention as defined by the claims.
Fig. 1 is a flowchart of a synchronization method for accessing global variables by a multi-user task according to an embodiment of the present invention, referring to fig. 1, the embodiment may include the following steps:
S101, determining information of a target global variable.
The target global variable is a global variable which needs to be accessed by at least two user tasks, and the information of the target global variable comprises the value of the target global variable.
In practical application, after a user completes user task programming, configuration software such as IEC 61131 can be used for analyzing the user task programming, identifying global variables accessed by a plurality of user tasks as target global variables, and taking information comprising specific numerical values of the global variables as information of the target global variables.
In practical application, because of the difference of the global variables accessed by different user tasks, there may be a complex access relationship, for example, user task 1, user task 2 and user task 3 need to access global variable a, user task 1, user task 3 and user task 4 need to access global variable B, and because the synchronization principle is the same for each target global variable and the target user task corresponding to access the target global variable in the present application, for convenience of description, if there is no special description, the description is performed for one target global variable, for example, user task 1, user task 2 and user task 3 need to access global variable a, and at this time, global variable a is the target global variable, and user task 1, user task 2 and user task 3 are all target user tasks corresponding to the target global variable.
S102, determining at least two target buffer addresses.
The target buffer addresses are in one-to-one correspondence with the above-mentioned target user tasks, and the target user tasks are the user tasks needing to access the determined target global variable, for example, the target global variable is a, and the target user tasks are the user task 1, the user task 2 and the user task 3.
Specifically, this step is actually relocating the target global variable. For example, by using configuration software such as IEC 61131, a unique target buffer address, that is, a buffer, is allocated to each target user task that is to access the target global variable a by using the task as a unit.
S103, sending the value of the target global variable to all target buffer addresses.
The value of the target global variable is sent to all target buffer addresses (all target buffer addresses are the target user task and the target buffer address are for one target global variable, and it can be understood that when a plurality of target global variables exist, each target global variable is sent to the target buffer address corresponding to the target user task needing to access each target global variable), the initialization process is completed, so that the target user task obtains or accesses the value of the target global variable from the target buffer address corresponding to the target user task when running.
For example, as shown in fig. 2, for the target global variable a, and target user tasks such as user task 1 (whose target buffer address is user task 1 buffer), user task 2 (whose target buffer address is user task 2 buffer), and user task 3 (whose target buffer address is user task 3 buffer) that need to access the target global variable a. The value of the target global variable A in the operation area is sent to a user task 1 buffer area, a user task 2 buffer area and a user task 3 buffer area, so that the value of the target global variable A is obtained from the user task 1 buffer area when the user task 1 runs; obtaining a value of a target global variable A from a user task 2 buffer when the user task 2 runs; the value of the target global variable a is obtained from the user task 3 buffer when user task 3 is running.
S104, after any one target user task changes the value of the target global variable, updating the value of the target global variable in the target buffer addresses corresponding to other non-running target user tasks.
After the initialization process is completed, a subsequent update process is performed. The method specifically comprises the following steps: and after any one target user task modifies the value of the target global variable of the buffer area, updating the value of the target global variable in target buffer addresses corresponding to other target user tasks needing to access the target global variable. For example, in the above example, after the target user task 1 modifies the target global variable a, the value of the target global variable a in the target cache addresses corresponding to the target user task 2 and the target user task 3 is updated.
In order to be able to achieve task-level data integrity, a scenario for multi-global variable coordination synchronization is satisfied. In some embodiments of the present application, the time for updating the target global variable may be limited, for example, after the end of the first user task that modifies the target global variable in its buffer, and before other target user tasks that need to access the global variable run, synchronization and updating of the target global variable (i.e., updating the value of the global variable in the buffer address corresponding to the other target user tasks that need to access the global variable) are performed.
The application provides a synchronization method for accessing global variables by multi-user tasks, which comprises the steps of firstly identifying target global variables accessed by at least two user tasks; then, distributing one-to-one corresponding target buffer area addresses to target user tasks needing to access the target global variable; and sending the target global variable to a target buffer address, so that the target global variable is obtained from the corresponding target buffer address when a target user task runs, and after any one target user task modifies the value of the target global variable, updating the values of the target global variable in the target buffer addresses corresponding to other non-running target user tasks, thereby realizing the synchronization of global variables for a plurality of user tasks based on cache efficiency.
Further, in some embodiments of the present application, the sending of the value of the target global variable to all target buffer addresses, that is, the initialization process, mentioned in the above embodiments, may be implemented by a preset controller or a controller program.
For example, when the value of the target global variable is first sent to the target buffer address, that is, when the initialization is performed, the value of the target global variable located in the operation area may be sent to the corresponding target buffer address by presetting a controller or a controller program.
Further, in some embodiments of the present application, after any one of the target user tasks modifies the value of the target global variable, updating the value of the target global variable in the target buffer address corresponding to the other non-running target user task may specifically include:
after any one of the target user tasks modifies the value of the target global variable, a synchronization message is constructed. Then, the value of the target global variable in the target buffer addresses corresponding to other non-running target user tasks is updated by broadcasting the synchronization message, as shown in fig. 3.
Specifically, the synchronization message includes the modified value of the target global variable. In practical application, after a target user task modifies the value of a target global variable and runs, a synchronization message containing the target global variable value modified by the target user task is generated, and then the synchronization message is sent to other target user tasks needing to access the target global variable in a broadcast mode, so that the target user tasks can synchronously update the value of the target global variable in the corresponding target cache region address. Or the controller program directly updates the value of the target global variable in the target buffer address corresponding to other target user tasks needing to access the target global variable.
Further, in some embodiments of the present application, the synchronization message mentioned in the foregoing embodiments may further include time information for modifying the target global variable, so that other non-running target user tasks update the value of the target global variable in the corresponding target buffer address based on the synchronization message generated by the latest time.
In particular, the synchronization message may further include a timestamp indicating the modification of the target global variable (i.e., the modification time information of the first target user task actively modifying the target global variable). On the basis, after receiving the synchronous message, other target user tasks needing to access the target global variable can update the synchronous message of the latest time in a plurality of synchronous messages according to the time stamp in the synchronous message, or update the synchronous message based on the comparison of the time information in the synchronous message and the time updated last time, thereby ensuring that the synchronous and updated based on the latest modification and ensuring that the target user tasks can access the latest target global variable.
It will be appreciated that in the present application, synchronization messages are only generated or sent when a target user task modifies a global variable, such as when a write operation is involved and the target global variable content is changed.
Further, in some embodiments of the present application, the synchronization method for accessing global variables by multi-user tasks may further include monitoring an execution state of a target user task; and updating the value of the target global variable in the operation area based on the value of the target global variable in the target cache area address when all target user tasks are in the idle state.
As shown in fig. 4, the running state of each target user task may be monitored by the controller or the controller program, when all target user tasks are idle, if all target user tasks are running, and the value of the target global variable is changed, the state of the target global variable is determined to be dirty, and at this time, the value of the global variable is copied from the user task buffer area to the operation area. It can be understood that when the copy refresh is completed or the target user task starts to run, the state of the target global variable is determined to be clean, no operation is needed, and the global variable of the operation area is ensured to be up to date or the user task can normally run.
As mentioned in the above embodiment, in practical application, the number of the global variables and the number of the user tasks involved may be multiple, on the basis that the global variables to be accessed by multiple user tasks are all target global variables, and multiple user tasks to access the same target global variable are used as target user tasks corresponding to the target global variables, the synchronization method for accessing the global variables by multiple user tasks provided by the application is further introduced and perfected from the angles of involving multiple target global variables and multiple target user tasks, and the specific flow is shown in fig. 5.
First, information of global variables is analyzed and extracted.
Specifically, after the user completes user task programming, all user tasks can be analyzed through IEC 61131 configuration software, all global variables accessed by a plurality of user tasks are identified as target global variables, access relations between the user tasks needing to access each target global variable (i.e. the target user tasks aiming at each target global variable) and all target global variables are determined, access modes (such as 'write only', 'read only', and 'read and write') can be simultaneously determined, the information is used as information of the target global variables, and a table is generated, as shown in the following table 1:
TABLE 1 information of target global variables
And then, the information is sent to the user, the instruction of the user is received, and the configuration of the target global variable in a synchronous mode is carried out.
It should be noted that, in the embodiment of the present application, for all global variables, multiple synchronization manners may be provided for the user, and in particular, which global variable adopts which synchronization manner may be selected by the user based on the actual requirement. For example, may include a lock mode in the prior art, and a cache-based mode provided by the present application. The lock method directly accesses the global variable memory, belongs to variable level real-time synchronization, and is suitable for a synchronous control scene based on a single global variable. The caching method is the mode introduced in the above embodiments, accesses the task level cache, belongs to task level real-time synchronization, and is suitable for a control scene requiring task level data integrity.
Specifically, after table 1 is obtained, the table 1 is sent to a user, and the user can configure a synchronization method of a corresponding global variable according to an actual control scenario, so that screening is performed based on a selection instruction of the user, a target global variable synchronized by the user through selecting a caching method is used as a final target global variable (if no special statement is made, all target global variables mentioned later in the application are target global variables finally determined after the user selects), synchronization is performed based on the synchronization method provided by the embodiment of the application, and synchronization is performed by adopting a lock mode in the prior art for the global variable synchronized by the user through selecting a lock, which can be understood by referring to the prior art, and detailed description is omitted in the application.
Further, the global variable of the user selected cache synchronization method is relocated. The synchronous principle is the same as that of the synchronous principle aiming at one target global variable, when facing a plurality of target global variables, the synchronous principle aims at the target user task of each target global variable to determine a target buffer address so as to realize the repositioning of all the target global variables.
And then compiling and downloading. The information and configuration are compiled into binary engineering, for example, by IEC 61131 configuration software, and issued to the controller or controller program.
And when the target user task runs, the synchronous access control of the target global variable is completed through the controller or the controller program.
Specifically, after the controller or the controller program receives the generated project, firstly, taking the target user task as a unit, copying the numerical value of each target global variable from the operation area to the target cache area address of the corresponding target user task, so that each target user task accesses the target global variable which needs to be accessed in the corresponding target cache area address when running.
And after the operation of a certain target user task is finished, modifying the target global variable in the corresponding target buffer address, and constructing and generating a synchronous message by the target user task or the controller program. Wherein, as mentioned in the above embodiments of the present application, the synchronization message may include the timestamp and the modified value of the target global variable. And then informing other target user tasks needing to access the target global variable in a broadcast mode, so that the other target user tasks needing to access the target global variable update the value of the target global variable in the corresponding target buffer address.
Fig. 6 is a schematic diagram of a processing flow of a synchronization message in a synchronization method for accessing global variables by a multi-user task according to an embodiment of the present application, as shown in fig. 6, in some embodiments of the present application:
The synchronization message may be generated by the target user task or a corresponding controller or controller program and sent to other target user tasks. To avoid the influence among multiple target global variables, in some embodiments of the present application, the synchronization message may further include, in addition to a timestamp, an identification or name of the target global variable, a value of the target global variable (e.g., a "variable value" in a "data" column in the following table), an ID of a target user task that modifies the target global variable and sends the synchronization message, that is, a source user task, and an ID of a target user task that needs to receive the synchronization message for updating, that is, a destination user task (that is, other target user tasks that need to access the modified target global variable), as shown in the following table 2:
TABLE 2 synchronization message
In the application, the target user task processes the received synchronous message before running and updates the buffer area. Wherein the target user task that receives the synchronization message updates each target global variable it is to access with the last modified variable value based on the time stamp.
Specifically, as shown in fig. 6, the processing flow of the synchronization message by the target user task receiving the synchronization message may specifically include:
Firstly, determining whether self ID is matched with a target user task ID in a synchronous message, if not, directly ending, if so, checking whether a target global variable which needs to be accessed by the self exists in the synchronous message by looking up a table which contains information of the target global variable and is shown in a table 1, if not, directly ending, and if so, then comparing time stamps; if the timestamp in the synchronous message is the latest (can be relative to other synchronous messages received in the same time or the timestamp of the synchronous message when updated before), adding the synchronous message into a message queue to be processed to wait for processing, updating and deleting the related old message; if not up-to-date, then it ends directly.
In the above process, the action of detecting whether the task of the target user matches and querying the target global variable list, or even performing subsequent updating, may be performed automatically by the task of the target user before other functions of the target user run, or may be performed by a related controller or a controller program.
And when all the target user tasks are in the idle state, the controller or the controller program copies the values of all the target global variables in the target buffer area addresses of all the target user tasks to the operation area based on the states of the target global variables, and completes updating all the target global variables in the operation area.
According to the synchronization method for accessing global variables by multi-user tasks, which is provided by the application, the global variable access information is extracted and provided for users through intelligent analysis of user task programs. The user can more comprehensively know the service condition of the global variable, and is convenient to check and optimize; meanwhile, besides a lock mechanism, a global variable synchronization method based on caching is realized. By sending the synchronous message after the task is completed and processing the synchronous message before the task starts to execute, the method can realize the data integrity of the task level and meet the scene of coordination and synchronization of multiple global variables; and the user can select different synchronization methods for different global variables according to actual requirements. The method can realize multiple synchronous control scenes more flexibly, and is beneficial to improving efficiency and correctness.
Based on a general inventive concept, an embodiment of the present invention further provides a synchronization apparatus for accessing global variables by multi-user tasks, as shown in fig. 7, where the apparatus may at least include:
a first confirmation module 71, configured to determine information of a target global variable, where the target global variable is a global variable that needs to be accessed by at least two user tasks, and the information of the target global variable includes a value of the target global variable;
A second determining module 72, configured to determine at least two target buffer addresses, where the target buffer addresses are in one-to-one correspondence with target user tasks, and the target user tasks are user tasks that need to access the target global variable;
a issuing module 73, configured to send the value of the target global variable to all the target buffer addresses, so that the target user task obtains the value of the target global variable from the corresponding target buffer address when running;
and the updating module 74 is configured to update the value of the target global variable in the target buffer address corresponding to the other non-running target user task after any one of the target user tasks changes the value of the target global variable.
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
Based on a general inventive concept, an embodiment of the present invention also provides an electronic device, as shown in fig. 8, which may include:
At least one processor 81; and
A memory 82 communicatively coupled to the at least one processor 81; wherein,
The memory 82 stores instructions executable by the at least one processor 81 to enable the at least one processor 81 to perform the method of synchronizing multi-user task access global variables as set forth in any one of the method embodiments above.
Based on a general inventive concept, an embodiment of the present invention also provides a computer program product.
The computer program product provided in this embodiment includes a computer program that, when executed by a processor, implements a method for synchronizing access to global variables by multi-user tasks according to any one of the above.
It is to be understood that the same or similar parts in the above embodiments may be referred to each other, and that in some embodiments, the same or similar parts in other embodiments may be referred to.
It should be noted that in the description of the present invention, the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. Furthermore, in the description of the present invention, unless otherwise indicated, the meaning of "plurality" means at least two.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps of the process, and further implementations are included within the scope of the preferred embodiment of the present invention in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present invention.
It is to be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above-described embodiments, the various steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, may be implemented using any one or combination of the following techniques, as is well known in the art: discrete logic circuits having logic gates for implementing logic functions on data signals, application specific integrated circuits having suitable combinational logic gates, programmable Gate Arrays (PGAs), field Programmable Gate Arrays (FPGAs), and the like.
Those of ordinary skill in the art will appreciate that all or a portion of the steps carried out in the method of the above-described embodiments may be implemented by a program to instruct related hardware, where the program may be stored in a computer readable storage medium, and where the program, when executed, includes one or a combination of the steps of the method embodiments.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing module, or each unit may exist alone physically, or two or more units may be integrated in one module. The integrated modules may be implemented in hardware or in software functional modules. The integrated modules may also be stored in a computer readable storage medium if implemented in the form of software functional modules and sold or used as a stand-alone product.
The above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, or the like.
In the description of the present specification, a description referring to terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present invention. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiments or examples. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
While embodiments of the present invention have been shown and described above, it will be understood that the above embodiments are illustrative and not to be construed as limiting the invention, and that variations, modifications, alternatives and variations may be made to the above embodiments by one of ordinary skill in the art within the scope of the invention.

Claims (9)

1. A method for synchronizing access to global variables by a multi-user task, comprising:
Determining information of a target global variable, wherein the target global variable is a global variable which needs to be accessed by at least two user tasks, and the information of the target global variable comprises the value of the target global variable;
Distributing target buffer area addresses corresponding to the target user tasks one by one to the target user tasks, wherein the target user tasks are user tasks needing to access the target global variable;
the value of the target global variable in the operation area is sent to the target buffer area address through a preset controller, so that the target user task obtains the value of the target global variable from the corresponding target buffer area address when running;
And updating the value of the target global variable in the target buffer addresses corresponding to other non-running target user tasks after any one of the target user tasks changes the value of the target global variable.
2. The method for synchronizing access to global variables by multi-user task according to claim 1, wherein updating the value of the target global variable in the target buffer address corresponding to the other non-running target user task after any one of the target user tasks changes the value of the target global variable comprises:
After any one of the target user tasks changes the value of the target global variable, constructing a synchronous message, wherein the synchronous message comprises the value of the target global variable after modification;
and broadcasting the synchronous message to update the value of the target global variable in the target buffer addresses corresponding to other non-running target user tasks.
3. The method for synchronizing multi-user task access global variables according to claim 2, wherein the synchronization message further comprises: and modifying the time information of the target global variable so that other non-running target user tasks modify the value of the target global variable in the corresponding target buffer address based on the latest time.
4. The method for synchronizing multi-user task access global variables according to claim 2, further comprising:
monitoring the execution state of the target user task;
And updating the value of the target global variable in the operation area based on the value of the target global variable in the target cache area address when all the target user tasks are in the idle state.
5. The method for synchronizing multi-user task access global variables according to claim 1, wherein the number of target global variables is a plurality, and the information of the target global variables further comprises: the access relation between each target global variable and each target user task;
The sending the value of the target global variable to all the target buffer addresses includes: based on the access relation, sending a plurality of target global variables to target buffer addresses of corresponding target user tasks;
After any one of the target user tasks changes the value of the target global variable, updating the value of the target global variable in the target buffer addresses corresponding to other non-running target users, including: and after any one target user task changes the value of any one target global variable, updating the value of the target global variable in the target buffer addresses corresponding to other non-running target user tasks.
6. The method for synchronizing multi-user task access global variables according to claim 5, further comprising:
Transmitting the information of the target global variable to a user, and receiving a synchronization method confirmation instruction transmitted by the user;
and confirming the instruction screening target global variables needing to be synchronized based on the synchronization method.
7. A synchronization apparatus for accessing global variables by a multi-user task, comprising:
The first confirmation module is used for determining information of a target global variable, wherein the target global variable is a global variable which needs to be accessed by at least two user tasks, and the information of the target global variable comprises the value of the target global variable;
The second determining module is used for distributing target buffer area addresses corresponding to the target user tasks one by one for the target user tasks, wherein the target user tasks are user tasks needing to access the target global variable;
the issuing module is used for sending the value of the target global variable positioned in the operation area to the target buffer area address through a preset controller so that the target user task can acquire the value of the target global variable from the corresponding target buffer area address when running;
And the updating module is used for updating the value of the target global variable in the target buffer addresses corresponding to other non-running target user tasks after any one of the target user tasks changes the value of the target global variable.
8. An electronic device, comprising:
At least one processor; and
A memory communicatively coupled to the at least one processor; wherein,
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of synchronizing multi-user task access global variables of any one of claims 1-6.
9. A computer program product comprising a computer program which, when executed by a processor, implements a method of synchronizing multi-user task access global variables according to any one of claims 1-6.
CN202410486705.2A 2024-04-23 2024-04-23 Synchronization method for multi-user task access global variable and related equipment Active CN118093212B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410486705.2A CN118093212B (en) 2024-04-23 2024-04-23 Synchronization method for multi-user task access global variable and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410486705.2A CN118093212B (en) 2024-04-23 2024-04-23 Synchronization method for multi-user task access global variable and related equipment

Publications (2)

Publication Number Publication Date
CN118093212A CN118093212A (en) 2024-05-28
CN118093212B true CN118093212B (en) 2024-08-09

Family

ID=91164035

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410486705.2A Active CN118093212B (en) 2024-04-23 2024-04-23 Synchronization method for multi-user task access global variable and related equipment

Country Status (1)

Country Link
CN (1) CN118093212B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110413418A (en) * 2019-06-25 2019-11-05 北京三快在线科技有限公司 Cache synchronization device and method, cache synchronization system, electronic equipment

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6795901B1 (en) * 1999-12-17 2004-09-21 Alliant Techsystems Inc. Shared memory interface with conventional access and synchronization support
US9146746B2 (en) * 2011-03-01 2015-09-29 University Of Washington Through Its Center Of Commercialization Systems and methods for providing deterministic execution
CN103049334B (en) * 2012-12-14 2015-09-30 华为技术有限公司 A kind of method of task process and virtual machine
CN112783674A (en) * 2021-01-29 2021-05-11 北京金山云网络技术有限公司 Configuration management method, device, equipment and medium
CN115309421A (en) * 2022-07-08 2022-11-08 北京天融信网络安全技术有限公司 Static variable synchronization method, device, equipment and storage medium of single-point system

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110413418A (en) * 2019-06-25 2019-11-05 北京三快在线科技有限公司 Cache synchronization device and method, cache synchronization system, electronic equipment

Also Published As

Publication number Publication date
CN118093212A (en) 2024-05-28

Similar Documents

Publication Publication Date Title
CN108932282B (en) Database migration method and device and storage medium
US5319645A (en) Method for debugging and testing the correctness of programs
RU2344468C2 (en) Method of multiple file conditions management for duplicated file
US7243346B1 (en) Customized library management system
US7275236B1 (en) Method for programming a multiple device control system using object sharing
US8495160B2 (en) System for controlling retention of data messages
CN104881494A (en) Method, device and system for performing data synchronization with Redis server
CN113094430B (en) Data processing method, device, equipment and storage medium
CN112163038B (en) Cross-cluster data synchronization method, device, equipment and storage medium
CN102520687B (en) General Interface System and Control Method Based on OPC
WO2018154884A1 (en) Control system, control device, and control program
CN112905696A (en) Multi-computer-room synchronization method based on transaction identifier, computing device and storage medium
US10140166B2 (en) Message oriented middleware with integrated rules engine
JP3319764B2 (en) Method and apparatus for synchronizing software functions between software systems
CN113448977A (en) Distributed cache updating method and device based on database Binlog
CN111736950A (en) Accelerator resource adding method of virtual machine and related device
CN118093212B (en) Synchronization method for multi-user task access global variable and related equipment
CN113312209B (en) Data hot standby method, device, server and storage medium
JP4920567B2 (en) Equipment network system and data access control method
CN101008908B (en) Synchronous data copy system and method
US8214330B2 (en) Information processing apparatus, information processing method, and computer program product
JPWO2020089963A1 (en) Data management systems, programmable displays, and data management programs
US7107404B2 (en) Method and system for data processing for controlling a cache memory
JP5931276B2 (en) Programmable display, its program
CN112765188A (en) Configuration information processing method, configuration management system, electronic device, and storage medium

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
GR01 Patent grant
GR01 Patent grant