  Clock configuration takes a key role in tuning constrained general-purpose
microcontrollers for performance, timing accuracy, and energy efficiency.
Configuring the underlying clock tree, however, involves a large parameter
space with complex dependencies and dynamic constraints. We argue for clock
configuration as a generic operating system module that bridges the gap between
highly configurable but complex embedded hardware and easy application
development. In this paper, we propose a method and a runtime subsystem for
dynamic clock reconfiguration on constrained Internet of Things (IoT) devices
named ScaleClock. ScaleClock derives measures to dynamically optimize clock
configurations by abstracting the hardware-specific clock trees. The ScaleClock
system service grants portable access to the optimization potential of dynamic
clock scaling for applications. We implement the approach on the popular IoT
operating system RIOT for two target platforms of different manufacturers and
evaluate its performance in static and dynamic scenarios on real devices. We
demonstrate the potential of ScaleClock by designing a platform-independent
dynamic voltage and frequency scaling (DVFS) mechanism that enables RIOT to
autonomously adapt the hardware performance to requirements of the software
currently executed. In a use case study, we manage to boost energy efficiency
of constrained network communication by reducing the MCU consumption by 40 % at
negligible performance impact.
