1. A method for allowing an application to invoke a function on a device, wherein the device includes at least two operating modes comprising a privileged mode and a non-privileged mode, and the function executes in the privileged mode, the method comprising: receiving a request from the application to invoke the function; determining the operating mode of the application; invoking the function using an interrupt, if the application is executing in the non-privileged mode, wherein the function is executed within the same task as the application; and invoking the function directly, if the application is executing in the privileged mode.