User`s guide
KwikNet Overview
K
A
DAK
11
Single Threaded Operation
Single threaded operation is only supported by KwikNet if you are using the KwikNet
Porting Kit.
In a single threaded system, there is a single application task which, for reference
purposes, is called the App-Task.
The App-Task starts in your
main() function and executes in what will be referred to as
the user domain. Once the App-Task starts, the thread of execution is sequential,
flowing back and forth between your application and
KwikNet. When KwikNet (or Treck)
code is being executed, your application is said to be in the KwikNet domain.
An interrupt can occur while executing in either the user domain or the KwikNet domain.
When an interrupt occurs, an interrupt service routine (ISR) begins execution in what is
called the interrupt domain. All interrupts, even if nested, are serviced in the interrupt
domain. When service of an interrupt is finished, execution resumes in the domain which
was in effect when the interrupt occurred.
Operation of the TCP/IP stack is controlled by a single body of KwikNet code which, by
definition, executes in the KwikNet domain. This body of code is called the KwikNet Task,
to distinguish it from your App-Task.
Your App-Task controls the flow of execution within your application. The KwikNet Task
can only execute when your App-Task permits. The KwikNet Task does not begin until
your application calls procedure kn_enter() to start KwikNet.
Once KwikNet has been started, your App-Task must regularly call KwikNet procedure
kn_yield() to let the KwikNet Task service the TCP/IP stack. Procedure kn_yield() is
included in the KwikNet Library and is described in Chapter 4.6.
The KwikNet Task receives timer ticks from the clock ISR through the KwikNet OS
interface. These ticks, KwikNet's fundamental timing source, occur at the frequency which
you specify when you configure your KwikNet Library. For best performance, your App-
Task should yield to the KwikNet Task at this frequency or higher.
KwikNet uses its Ethernet, SLIP or PPP network driver to interact with a particular
network's device driver. The
KwikNet Task and the device driver cooperate to ensure that
network packet transmission and reception occur in a timely fashion. Interrupts
generated by the device's hardware interface are serviced by an interrupt service routine
(ISR) which calls the device driver's interrupt handler.
Warning
Your application MUST regularly yield to the KwikNet Task
by calling procedure kn_yield(). Failure to yield at least
at the defined KwikNet clock frequency may result in poor
performance of the TCP/IP stack.