[En-Nut-Discussion] RFC: Idle Thread Callback

Harald Kipp harald.kipp at egnite.de
Sun Jun 17 15:20:34 CEST 2012


Hi developers,

Uwe's patch, which I recently applied to the trunk, modified the idle thread. The patch provides an indicator to see, how long the CPU is idle. IIRC, this patch is available for the AVR family only.

Now I have another requirement: I want to see, how often the CPU runs the idle thread within a specific time period. I want to use this as a simple CPU usage indicator.

Both modification might be interesting not only for the AVR platform. But instead of adding more and more patches, I'd suggest to completely remove them all and instead allow the application to register an idle callback.

Definitions:

typedef void (*NutIdleCallback)(void);
extern NutIdleCallback NutRegisterIdleCallback(NutIdleCallback func);

Usage:

static NutIdleCallback next_handler;

void MyIdleHandler(void)
{
  // Do my stuff first.
  ...
  // Call the next handler.
  if (prev_handler)
    prev_handler();
}

next_handler = NutRegisterIdleCallback(MyIdleHandler);


Regards,

Harald




More information about the En-Nut-Discussion mailing list