CTL has been supplied with various 1.x releases of CrossWorks, and its revision history is available in the corresponding release notes—such releases are termed CTL V1. CTL is supplied in 2.x releases of CrossWorks and is termed CTL V2. This document explains the differences between CTL V1 and CTL V2.

Scheduling implementation

In CTL V1, the executing task was removed from the task list and then put back on when it was descheduled. In CTL V2, the executing task isn't moved from the task list. This change enables CTL to run on the Cortex-M3, results in smaller code with faster context switching, and reduces the interrupt-lockout period.

In CTL V1, rescheduling would happen on exit from the last nested interrupt service routine. In CTL V2, a reschedule only occurs on exit from the last nested interrupt service routine if the run state of a task has changed.

Mutexes

POSIX thread-style mutexes have been added.

Task restore

The new function ctl_task_restore allows tasks that have been removed from the task list (using ctl_task_remove) to be returned to the task list again.

Suspended task state

The new task state suspended has been added. It can be used instead of removing and restoring a task from the task list.

Thread-specific data pointer

The new member data has been added to the task structure. It can be used to store thread-specific data.

Task execution time

The new global variable ctl_last_schedule_time has been added, and a new field execution_time has been added to the task structure to hold the cumulative number of timer ticks since the task began executing.

Change to global interrupt functions

The functions ctl_global_interrupts_disable and ctl_global_interrupts_enable no longer return the previous interrupt-enables state. If you need that, use ctl_global_interrupts_set instead.

Other API changes

The function ctl_task_set_priority returns the old task priority.

Header file changes

In CTL V1, the file ctl/include/ctl_api.h contained CTL declarations and board-support declarations. In CTL V2, the file ctl/include/ctl.h contains CTL declarations. In CTL V2, the file ctl/include/ctl_api.h includes ctl/source/ctl.h and has board-support declarations for backwards compatibility.

Removed support for interrupt re-enabling

The following functions have been removed from CTL V2:

These are defined in ctl_api.h to use their libarm equivalents. Rather than use these functions, it is recommended to re-enable interrupts in the irq_handler.

Removed support for programmable interrupt handler

The following functions have been removed from CTL V2:

These functions are now declared in ctl_api.h and are implemented in board- and CPU-support packages.

Removed CPU-specific timer functions

The following functions have been removed from CTL V2:

These functions are now declared in ctl_api.h and are implemented in support packages for the board and CPU.

Removed board-specific functions

The following functions have been removed from CTL V2:

These functions are now declared in ctl_api.h and are implemented in board-support packages.

Moved libc mutex

The declaration of the event set ctl_libc_mutex has been moved into the implementation of the libc multi-threading helper functions.

Byte-queue and message-queue additions

Functions to post and receive multiple bytes/messages.

Functions to query the state of byte/message queues.

Function to associate events that are set when byte or message queues are not empty or not full.

Usage of ctl_global_interrupts_set

In CTL V2.1, the usage of ctl_global_interrupts_set has been replaced with usage of ctl_global_interrupts_disable and ctl_global_interrupts_enable. These functions are now implemented using compiler intrinsics in the default CTL build. You can rebuild with the C preprocessor symbol __NO_USE_INTRINSICS__ defined if your application requires ctl_global_interrupts_set to be used.