Now I have to clean up this code and want to know how to use the file As a means of communication instead of inter-process communication like pipes, what are the disadvantages. Opening and reading files that are more expensive than pipes? Are there other disadvantages? How important do you think performance degradation is.
Legacy code runs on Windows and Linux.
>What happens when process (2) finds that process (1) writes to the file? You need special logic to handle this situation.
>What happens if process (1) still wants to send another message while process (2) is still reading from the file? (1) It must somehow detect that the file cannot be written and wait for it to be available.
>Files can become a bottleneck for a large amount of message traffic, especially if you only use a single file for IPC.
To determine if file I/O is a performance bottleneck, we need to know more about the messages you send. Their size, frequency of sending, etc. Otherwise it is difficult to judge how they affect your performance (if any Words).
That is to say, I have used files to transfer information between processes in the past, although usually a new file name is created every time, or the file will be used to transfer a large amount of data, and the smaller IPC The message will be used to signal when the file is ready to be sent.
In my opinion, unless you have a reason to use the file-such as transferring large amounts of data-I prefer traditional IPC mechanisms, such as pipes, sets Sockets, etc. But you have to implement it carefully to make sure everything works on both platforms.
I have legacy code that needs improvement for performance reasons. My app Contains two executable files that need to exchange certain information. In the legacy code, one exe writes to the file (the file name is passed to the exe as a parameter), and the second executable file first checks whether such a file exists; if it does not exist Then check again and when you find it, continue to read the contents of the file. This way of passing information between the two executable files. The way the code is structured, the second executable file succeeded on the first attempt
Now I have to clean up this code and want to know what are the disadvantages of using files as a means of communication instead of inter-process communication like pipes. Opening and reading files that are more expensive than pipes? Are there other disadvantages? How important do you think performance degradation is.
Legacy code runs on Windows and Linux.
Some problems with using IPC files are:
>What happens when process (2) finds that process (1) writes a file? You need special logic to handle this situation.
>What happens if process (1) still wants to send another message while process (2) is still reading from the file? (1) It must somehow detect that the file cannot be written and wait for it to be available.
>Files can become a bottleneck for a large amount of message traffic, especially if you only use a single file for IPC.
To determine if file I/O is a performance bottleneck, we need to know more about the messages you send. Their size, frequency of sending, etc. Otherwise it is difficult to judge how they affect your performance (if any Words).
That is to say, I have used files to transfer information between processes in the past, although usually a new file name is created every time, or the file will be used to transfer a large amount of data, and the smaller IPC The message will be used to signal when the file is ready to be sent.
In my opinion, unless you have a reason to use the file-such as transferring large amounts of data-I prefer traditional IPC mechanisms, such as pipes, sets Sockets, etc. But you have to implement it carefully to make sure everything works on both platforms.