TCPIP Tasks and Priorities
The user application interfaces to µC/TCP-IP via a well known API called BSD sockets (or µC/TCP-IP’s internal socket interface). The application can send and receive data to/from other hosts on the network via this interface.
The BSD socket API interfaces to internal structures and variables (i.e., data) that are maintained by µC/TCP-IP. A binary semaphore (the global lock in the figure µC/TCP-IP Task model) is used to guard access to this data to ensure exclusive access. In order to read or write to this data, a task needs to acquire the binary semaphore before it can access the data and release it when finished. Of course, the application tasks do not have to know anything about this semaphore nor the data since its use is encapsulated by functions within µC/TCP-IP.
The figure µC/TCP-IP Task model shows a simplified task model of µC/TCP-IP along with application tasks.
µC/TCP-IP defines three internal tasks: a Receive task, a Transmit De-allocation task, and a Timer task. The Receive task is responsible for processing received packets from all devices. The Transmit De-allocation task frees transmit buffer resources when they are no longer required. The Timer task is responsible for handling all timeouts related to TCP/IP protocols and network interface management.
When setting up task priorities, we generally recommend that tasks that use µC/TCP-IP’s services be configured with higher priorities than µC/TCP-IP’s internal tasks. However, application tasks that use µC/TCP-IP should voluntarily relinquish the CPU on a regular basis. For example, they can delay or suspend the tasks or wait on µC/TCP-IP services. This is to reduce starvation issues when an application task sends a substantial amount of data.
We recommend that you configure the network interface Transmit De-allocation task with a higher priority than all application tasks that use µC/TCP-IP network services; but configure the Timer task and network interface Receive task with lower priorities than almost other application tasks.
See also Operating System Configuration.