Sylixos under Dbus replacement scheme

Source: Internet
Author: User

1.1 Sylixos Replacement principle

The previous blog introduced the Dbus communication principle and common function interface, this document introduced Sylixos Dbus function replacement scheme.

Sylixos has a variety of interprocess communication methods that enable interprocess communication between classes Dbus. According to the principle of dbus communication, the Sylixos can be designed with replacement scheme 11 as shown.

A replacement scenario requires that a background process be created that receives the messages sent by the process and is processed according to the message type. If the received message is a signal type, it is forwarded to another process, and if the message type is a function call type, it is forwarded to the target process, waiting for the return value of the function call. In the substitution scheme, interprocess communication is implemented through UDP communication, and the functions of dbus function call and signal broadcasting can be realized through the background process forwarding, and different processes are differentiated by different port numbers.

As shown in 1-1, the background process function in the replacement scenario is similar to the bus function in Dbus, and UDP communication replaces the domain socket, thereby implementing the interprocess communication function of the class Dbus.

650) this.width=650; "src=" http://img.blog.csdn.net/20170305171334951 "/>

Figure 1-1 Replacement Scenario

The message types in the replacement scenario can be divided into:

1. Request a connection message

2. Disconnecting the connection message

3. Signal messages

4. Function call Message

5. function return value message

6. Function Registration Message

7. Error messages

The class Dbus functionality needs to be implemented in the replacement scenario, which includes:

1. Process request connection to background process and disconnect

2. Signal transmission

3. Signal Reception

4. Function calls

5. Wait for a function call

6. Providing function calls

2. Technology implementation 2.1 Connect to a background process

Before interprocess communication is required to connect to the background process, Sylixos implements the replacement scenario, which requires the communication process to construct the message, sending a request connection type message to the background process.

As shown in 2-1, the background process determines that the process port number is added to the process management chain list when the message is a request connection. At the end of the program execution, the process needs to disconnect from the background process, send a request to disconnect the message to the background process, and the background process to remove the port number from the management list for that process.

650) this.width=650; "Src=" http://img.blog.csdn.net/20170305173720623?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvbxjfd2fuz25pbmc=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Center "/>

Figure 2-1 Requesting a connection, disconnecting

2.2 Signal Transmission

The signal in the Dbus can implement a broadcasting mechanism, which constructs a signal type message before the process sends the signal, and then sends it to the background process without waiting for a response message.

Sylixos implementation of signal transmission process 2-2, the construction of signal type message, through UDP sent to the background process.

650) this.width=650; "Src=" http://img.blog.csdn.net/20170305173728108?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvbxjfd2fuz25pbmc=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Center "/>

Figure 2-2 Signal Transmission

2.3 Signal Reception

When a background process receives a message of the signal type, it iterates through all the processes that are connected to the background, forwards the signal, and then realizes the broadcast function of the signal.

Processes that are already connected to the background need to inform themselves of the signals of interest and wait for the message, as shown in flowchart 2-3.

650) this.width=650; "src=" http://img.blog.csdn.net/20170305171340691 "/>

Figure 2-3 Signal Reception

2.4 Function calls

A function call is similar to a signal, which constructs a message before the process invokes the function, including the function name, function parameters, and the process port number. The message is then sent to the background process, blocking the return value of the wait function execution, as shown in flowchart 2-4.

650) this.width=650; "src=" http://img.blog.csdn.net/20170305171341295 "/>

Figure 2-4 Function calls

When a background process receives a message of the type of a function call, it first checks that the calling function exists and the function exists to forward the message to the process that corresponds to the provided function, waiting for the result to be executed. If you check that the calling function does not exist, the error message is returned to the process that called the function. The background process is processed as shown in flowchart 2-5.

650) this.width=650; "src=" http://img.blog.csdn.net/20170305171341629 "/>

Figure 2-5 Background processing function call

2.5 Waiting for function calls

Wait for the function call and wait for the message to be called. When a function call message that is forwarded by a background process is received, the parameters in the message are parsed, and then the function is executed, and the construction return message is sent to the background process, as shown in flowchart 2-6.

650) this.width=650; "src=" http://img.blog.csdn.net/20170305171341998 "/>

Figure 2-6 waiting for a function call

2.6 Providing function calls

The process that provides the function call needs to register the function with the background process, and when other processes call the function, the background process checks to see if the function exists and, if it does, sends the message to the target process, or replies to the error message, as shown in flowchart 2-7. The background process receives the message and adds the function to the management chain list.

650) this.width=650; "src=" http://img.blog.csdn.net/20170305171342441 "/>

Figure 2-7 providing a function call

3. Summary

Dbus is an efficient and easy-to-use interprocess communication method. This document introduces the communication principle of dbus and the implementation scheme of replacing this communication mechanism under Sylixos. Based on the signal transceiver and function call module, this paper introduces the concrete implementation steps of replacing Dbus function under Sylixos.


Sylixos under Dbus replacement scheme

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.