  The emergence of energy harvesting devices creates the potential for
batteryless sensing and computing devices. Such devices operate only
intermittently, as energy is available, presenting a number of challenges for
software developers. Programmers face a complex design space requiring
reasoning about energy, memory consistency, and forward progress. This paper
introduces Alpaca, a low-overhead programming model for intermittent computing
on energy-harvesting devices. Alpaca programs are composed of a sequence of
user-defined tasks. The Alpaca runtime preserves execution progress at the
granularity of a task. The key insight in Alpaca is the privatization of data
shared between tasks. Updates of shared values in a task are privatized and
only committed to main memory on successful execution of the task, ensuring
that data remain consistent despite power failures. Alpaca provides a familiar
programming interface and a highly efficient runtime model. We also present an
alternate version of Alpaca, Alpaca-undo, that uses undo-logging and rollback
instead of privatization and commit. We implemented a prototype of both
versions of Alpaca as an extension to C with an LLVM compiler pass. We
evaluated Alpaca, and directly compared to three systems from prior work.
Alpacaconsistently improves performance compared to the previous systems, by up
to 23.8x, while also improving memory footprint in many cases, by up to 17.6x.
