Asynchronous procedure call
   HOME

TheInfoList



OR:

Asynchronous procedure call is a unit of work in a computer. Usually a program works by executing a series of synchronous procedure calls on some thread. But if some data are not ready (for example, a program waits user to reply), then keeping thread in wait state is impractical, as a thread allocates considerable amount of memory for procedure stack, and this memory is not used. So such a procedure call is formed as an object with small amount of memory for input data, and this object is passed to the service which receive user inputs. When the user's reply is received, the service puts it in the object and passes that object to an execution service. Execution service consists of one or more dedicated worker threads and a queue for tasks. Each worker thread reads in a loop task queue and, when a task is retrieved, executes it. When there is no tasks, worker threads are waiting and so their memory is not used, but the number of worker threads is small enough (no sense to have more threads than there are processors on the machine). So life cycle of an asynchronous procedure call consists of 2 stages: passive stage, when it passively waits for input data, and active state, when that data is calculated in the same way as at usual procedure call. The object of the asynchronous procedure call can be reused for subsequent procedure calls with new data, received later. This allows to accumulate computed output data in that object, as it is usually done in objects, programmed with Object-oriented programming paradigm. Special care should be paid to avoid simultaneous execution of the same procedure call in order to keep computed data in consistent state. Such reusable asynchronous procedure is named Actor. Programming using Actors is described in Actor model and
Dataflow programming In computer programming, dataflow programming is a programming paradigm that models a program as a directed graph of the data flowing between operations, thus implementing dataflow principles and architecture. Dataflow programming languages share s ...
. The difference is that Actor in the Actor model has exactly two ports: one port to receive input data, and another (hidden) port to provide serial handling of input messages, while Actor in
Dataflow programming In computer programming, dataflow programming is a programming paradigm that models a program as a directed graph of the data flowing between operations, thus implementing dataflow principles and architecture. Dataflow programming languages share s ...
can have many, and goes to execution service when all inputs contain data or permissions.


Some specific implementations

In
Windows Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for ser ...
, an asynchronous procedure call (abbreviated APC) is a function that executes asynchronously in the context of a specific thread. APCs can be generated by the system (kernel-mode APCs) or by an application (user mode APCs).


References

{{compu-prog-stub Computer programming