eCosTM Reference Manual
Prev | Chapter 17. Package: eCos kernel | Next

# Component: Counters and clocks

#### Macro name

CYGPKG_KERNEL_COUNTERS

#### Type

Dummy

#### Description

The counter objects provided by the kernel provide an abstraction of the clock facility that is generally provided. Application code can associate alarms with counters, where an alarm is identified by the number of ticks until it triggers, the action to be taken on triggering, and whether or not the alarm should be repeated.

## Option: Provide real-time clock

#### Macro name

CYGVAR_KERNEL_COUNTERS_CLOCK

#### Type

Boolean

#### Description

On all current target systems the kernel can provide a real-time clock. This clock serves two purposes. First it is necessary to support clock and alarm related functions. Second it is needed to implement timeslicing in some of the schedulers including the mlqueue scheduler. If the application does not require any of these facilities then it is possible to disable the real time clock support completely.

## Component: Override default clock settings

#### Macro name

CYGPKG_KERNEL_COUNTERS_CLOCK_OVERRIDE

#### Type

Boolean

#### Description

The kernel has default settings for the clock interrupt frequency. These settings will vary from platform to platform, but typically there will be a 100 clock interrupts every second. It is possible to change this frequency, but it requires some knowledge of the target hardware.

### Option: Clock hardware initialization value

#### Macro name

CYGNUM_KERNEL_COUNTERS_CLOCK_OVERRIDE_PERIOD

#### Type

Count

#### Description

During system initialization this value is used to initialize the clock hardware. The exact meaning of the value and the range of legal values therefore depends on the target hardware, and the hardware documentation should be consulted for further details. In addition the clock resolution numerator and denominator values should be updated. Typical values for this option would be 150000 on the MN10300 stdeval1 board, 15625 on the tx39 jmr3904 board, and 20833 on the powerpc cogent board.

### Option: Clock resolution numerator

#### Macro name

CYGNUM_KERNEL_COUNTERS_CLOCK_OVERRIDE_NUMERATOR

#### Type

Count

#### Description

If a non-default clock interrupt frequency is used then it is necessary to specify the clock resolution explicitly. This resolution involves two separate values, the numerator and the denominator. The result of dividing the numerator by the denominator should correspond to the number of nanoseconds between clock interrupts. For example a numerator of 1000000000 and a denominator of 100 means that there are 10000000 nanoseconds (or 10 milliseconds) between clock interrupts. Expressing the resolution as a fraction should minimize clock drift even for frequencies that cannot be expressed as a simple integer. For example a frequency of 60Hz corresponds to a clock resolution of 16666666.66... nanoseconds. This can be expressed accurately as 1000000000 over 60.

### Option: Clock resolution denominator

#### Macro name

CYGNUM_KERNEL_COUNTERS_CLOCK_OVERRIDE_DENOMINATOR

#### Type

Count

#### Description

If a non-default clock interrupt frequency is used then it is necessary to specify the clock resolution explicitly. This resolution involves two separate values, the numerator and the denominator. The result of dividing the numerator by the denominator should correspond to the number of nanoseconds between clock interrupts. For example a numerator of 1000000000 and a denominator of 100 means that there are 10000000 nanoseconds (or 10 milliseconds) between clock interrupts. Expressing the resolution as a fraction should minimize clock drift even for frequencies that cannot be expressed as a simple integer. For example a frequency of 60Hz corresponds to a clock resolution of 16666666.66... nanoseconds. This can be expressed accurately as 1000000000 over 60.

## Option: Implement counters using a single list

#### Macro name

CYGIMP_KERNEL_COUNTERS_SINGLE_LIST

#### Type

Radio

#### Description

There are two different implementations of the counter objects. The first implementation stores all alarms in a single linked list. The alternative implementation uses a table of linked lists. A single list is more efficient in terms of memory usage and is generally adequate when the application only makes use of a small number of alarms.

## Option: Implement counters using a table of lists

#### Macro name

CYGIMP_KERNEL_COUNTERS_MULTI_LIST

#### Type

Radio

#### Description

There are two different implementations of the counter objects. The first implementation stores all alarms in a single linked list. The alternative implementation uses a table of linked lists, with the size of the table being a separate configurable option. For more complicated operations it is better to have a table of lists since this reduces the amount of computation whenever the timer goes off. Assuming a table size of 8 (the default value) on average the timer code will only need to check 1/8 of the pending alarms instead of all of them.

## Option: Size of counter list table

#### Macro name

CYGNUM_KERNEL_COUNTERS_MULTI_LIST_SIZE

#### Type

Count

#### Description

If counters are implemented using an array of linked lists then this option controls the size of the array. A larger size reduces the amount of computation that needs to take place whenever the timer goes off, but requires extra memory.

## Option: Sort the counter list

#### Macro name

CYGIMP_KERNEL_COUNTERS_SORT_LIST

#### Type

Boolean

#### Description

Sorting the counter lists reduces the amount of work that has to be done when a counter tick is processed, since the next alarm to expire is always at the front of the list. However, it makes adding an alarm to the list more expensive since a search must be done for the correct place to put it. Many alarms are used to implement timeouts, which seldom trigger, so it is worthwhile optimizing this case. For this reason sorted list are disabled by default.

## Option: Measure real-time [clock] interrupt latency

#### Macro name

CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY

#### Type

Boolean

#### Description

Measure the interrupt latency as seen by the real-time clock timer interrupt. This requires hardware support, defined by the HAL_CLOCK_LATENCY() macro.

Prev | Home | Next
Component: Kernel schedulers | Up | Component: Thread-related options