I want to write a “embedded control system”, on Linux
In order to make it easy to update in the future, i think multi-process is better than muti-thread
so, this system maybe separate into 3 program
-
“process”, read some input data from others and do some calculation, then save the result to shared memory
-
“display”, read instant data from shared memory and choose some data to display on UI(written by Qt)
-
“database”, read instant data from shared memory and save them in a period, data will be saved in binary files at first, and maybe use sqlite instead in the future
and nore, maybe i will add a web server to read the instant data and show it through the browser
here is the question:
-
is multi-process really better multi-thread?
-
If use multi-process, how about use shared memory, is there any disadvantage.
Depends on what you want to do. Multiprocessing enforces a strict separation between system components, allowing for various parts to run with different credentials. It does require a more complicated communication mechanism than multithreading and incurs some overhead.
The main disadvantage, compared to the obvious alternative of using sockets, is that it limits your entire system to running on a single host. No distributed computing.