1. A resource-constrained device comprising: a processor; a memory, coupled to the processor, wherein the memory includes computer programs executable by the processor, wherein the computer programs comprise: an operating system to provide functions to native applications; a virtual machine; and one or more native applications under scheduling control of the virtual machine, wherein each native application is associated with an application context, and each application context at least (i) maps one or more services provided by the associated native application to an interface of the virtual machine and (ii) maintains a state of the associated native application.