"Multiprocessor" and "uniprocessor multithreading" for software modules interacting via messaging

We need to create a software environment (or middleware) that will provide messaging between various software components (or modules) running on the same machine. This structure will provide such functions:

  • Communication between modules is via messaging.
  • Each module will have its own message queue and message handler thread, which will synchronously process each incoming message.

Given the above requirements, which of the following approaches is correct (with its argument) ?:

  • Implementation of modules as processes and messaging through shared memory
  • The implementation of modules as threads in one process and the exchange of messages by pushing message objects into the message queue of the target module.

From the source there are some obvious cons and pros:

  • In option-2, if one of the modules causes a segmentation error, the process (thus, the entire application) will crash. And one module can directly receive / mutate another module memory, which can lead to difficult debugging of runtime errors.
  • But with Option-1, you need to take care of the states where the module that you need for communication has just worked. If the software has N modules, there may be 2 ^ N many states with active / alarm system states that affect the algorithms running on the modules.
  • Option-1 , , . ( , , , , , ).

-2, , . ?

: :

  • , Linux.
  • , , , , (3-4 ), , / .
  • C/++ .
  • "API " : (1) /, (2) , (3) -- , .
+4
3

:

(1) (2):

  • : (2), , . (1) , , , .
  • : (2) , . (1) .
  • . (2) , . (1) " " .
  • : (2) , (1) , unix, , . .
  • . (2) . ( ) . (1) ( malloc/free) " ".
  • . (2) . (1) , .
+3

, . !

, ; ( Windows, ).

-, ; , . , . , . .

. , ( , Actor, , , CSP), . , . , , (, linux), . .

; , , , . , (, keep-awake ). , , keep-awake . . , , , (, ), . , , .

, , - select() , ( ), .

, Windows. select() Microsoft. select() , .., Unix. Cygwin select(). , ; .

!

0

, "" , , , , .

:

  • , (, , , ..), .
  • , ​​ Python, thread parallelism (- ) Linux, - .

, . , , , ? , , , ( , , ). , parallelism .

tl; dr: :)

0

All Articles