Specifications
Chapter 1: Using the NicheStack TCP/IP Stack 1–25
Important NicheStack TCP/IP Stack Concepts
June 2011 Altera Corporation Using the NicheStack TCP/IP Stack - Nios II Edition Tutorial
Be careful not to overutilize job distribution among several tasks at the same time, for
the following reasons:
■ Additional tasks require additional CPU execution time to do task
context-switching.
■ Limited number of priorities. Each task must have its own unique priority in
MicroC/OS-II, and you do not want to run out of task priorities.
Task Priorities in the Nios II Simple Socket Server Design
Task priorities in the application directly affect how the application runs, or if the task
functions correctly at all. The MicroC/OS-II operating system uses a unique priority
number scheme for running its tasks, in which tasks assigned a lower priority number
are treated as higher priority tasks. Because the Altera version of the NicheStack
TCP/IP Stack requires the use of the MicroC/OS-II RTOS for operation, all tasks run
on the system must be assigned a unique priority number. For the Nios II Simple
Socket Server demo application, all tasks have been assigned non-conflicting
priorities. For your own application, however, you should verify that all tasks in your
system are assigned unique priority numbers at run-time.
Table 1–4 lists the tasks that might be running in your system, and the mechanism for
configuring the priority of these tasks.
The following sections discuss the priorities of the tasks in the Nios II Simple Socket
Server design:
MicroC/OS-II Internal Tasks
The Nios II Simple Socket Server application has been configured to not use any
MicroC/OS-II internal tasks.
NicheStack TCP/IP Stack Internal Tasks
TK_NETMAIN_TPRIO
, defined in ipport.h, sets the priority to a value of 2 for the main
NicheStack TCP/IP Stack task, launched by
netmain()
. This task implements the core
functionality of the NicheStack TCP/IP Stack. To maximize the TCP/IP packet-
throughput rate, the priority of this task should be higher than application tasks that
use the NicheStack TCP/IP Networking Stack.
Table 1–4. Simple Socket Server Tasks and Configuration Mechanisms
Task Type Configuration Mechanism
MicroC/OS-II internal tasks ucosii settings, located on the Main tab of the Nios II BSP Editor
NicheStack TCP/IP Stack internal tasks ipport.h, located in the iniche/src/h/nios2 directory of your BSP project
Networking initialization task iniche_init.c, located in the <tutorial_files>\nichestack_tutorial directory
User networking tasks (calls to
TK_NEWTASK
)
Created in the user application code
User non-networking tasks (calls to
OSTaskCreate
)
Created in the user application code
PHY monitoring task Created in the user application code