1. A method for invoking a service on a host processor in a computer-controlled system, the method comprising: providing a single callback function having multiple cases, each such case corresponding to a state of the service; creating a stack in a memory of the host processor, the stack containing one or more state descriptors indicative of the state of the service; calling the function on the host processor in order to invoke the service; responsive to calling the function, popping one of the state descriptors from the stack so as to determine the state of the service; and running the case in the callback function that corresponds to the determined state.