DS80C400 Silicon Software: Task Scheduler Information

The DS80C400 Silicon Software provides a task scheduler to simplify the implementation of applications such as Serial-to_ethernet. The implementation is optimized for size and a small number of tasks. To allow for customization, the task scheduler supports hooks. To summarize the features:

  1. Full task support
  2. Hooks for threads (user can supply save/restore state functions)
  3. Preemptive
  4. Priority-based, supports an Idle Task

The tasks are organized as a ring of Task Control Blocks (TCBs). Each TCB has attributes such as Priority and the Task ID. The following picture shows a configuration with 4 tasks:

A TCB consists of...

System Timer

Timer 0 runs as the system timer for the silicon software. The reload for timer 0 can be set using the task library function task_settickreload. The default reload equates to a time of roughly 1 millisecond on a 14.7456 MHz crystal. This interval is referred to as a timer tick. Timer 0 runs as a high priority interrupt.

Task Scheduler

Every four timer ticks (or if the need_sched bit is set), the task scheduler is run if:

  1. No low-priority interrupts are in progress
  2. The application is currently in a critical section (wos_crit_count != 0)
If the task scheduler cannot run due to either of these exceptions, the need_sched bit is set so future timer ticks will try to run the scheduler. The task scheduler is also run whenever a task is suspended or put to sleep.

Context Switches

On a context switch, the following are preserved in the TSB:

Critical Sections

Critical sections are intended to protect short tasks that must not be interrupted, such as using the math accelerator unit. Do not create critical sections lasting longer than 100-200us. Doing so may cause unpredictable behavior.