Colway Solutions
Modbus Member Logo

Using MSPL-C in a multitasking Environment


Two most common types of multitasking environments in use are the process based RTOS and a task based RTOS. They differ in the following characteristics:


Process based RTOS

Task based RTOS

Each process has a dedicated global memory space.

All tasks share a common global memory space.

A global variable with the same name can exist between two processes.

A global variable created in one file is visible to all tasks. So global variables should have unique names.

Functions of a library used by a process need not be re-entrant or thread-safe since a call to it by multiple processes will always act only on the global data of the calling process, if any.

Since function calls by any of the tasks act on shared global data, functions of a library used by multiple tasks simultaneously need be re-entrant or thread-safe.

Examples: WinCE, OS9

Examples: VxWorks, uC/OS II, MQX, embOS


MSPL-C has its set of global variables. So these differences have an impact on how MSPL-C can be used in these multitasking environments. Consider the following guidelines when using MSPL-C in an RTOS:

a.       In a process based RTOS, fork multiple processes to support many Modbus TCP connections with each process handling one connection. However, set MAX_NETWORKS macro in MSPL_UserIf.h to one (1) only. Each process behaves as if it is the only Modbus device in the system.

b.      In a task based RTOS, fork multiple tasks to support many Modbus TCP connections. In this case the MAX_NETWORKS macro should be set to the maximum number of tasks that will simultaneously use the library.


Back to Index

Privacy Policy Site Map FAQ Contact Us