Friday, April 27, 2007

Message mechanism implementation in POSIX system

The message mechanism is widely used for inter-thread (process) communication. Some implementation mechanisms of message are as follow:


  1. pipe (anonymous or named)
    • Pros:
      • Can be used for inter-process and inter-thread message
      • Can suspend on get message (desired)
      • Support non-block operation
    • Cons:
      • Can not support message priority
  2. Socket (stream or datagram)
    Used by X Window system message system. Almost same as pipe, with following additional pros and cons
    • Pros:
      • Can be used in network environment (not important now)
    • Cons:
      • Need kernel networking support.
  3. POSIX message queue
    • Pros:
      • Can be used for inter-process and inter-thread message
      • Can suspend on get message (desired)
      • Support time out
      • Support message priority
      • Support non-block operation
    • Cons:
      • Need new kernel (> 2.6.6)
  4. SysV message queue
    • Pros:
      • Can be used for inter-process and inter-thread message
      • Can suspend on get message (desired)
      • Support message priority
      • Support non-block operation
    • Cons:

Conclusion:
  • The function of mechanisms above is almost same, the POSIX message queue or SysV message queue is preferred if available because they are more similar to message then need less implementation effort.

No comments: