A known problem in computer science involves effective programmability around concurrency. Existing programming paradigms involve such things as threads, mutexes, semaphores, critical sections, and other primitives. Though these have been around for decades, they are hard to use properly without inducing hard-to-find timing bugs, or inadvertently serializing access through code sections via improper locking hierarchies.
In addition, synchronizing protocols associated with concurrent processes has been problematic. For example, in a multi-stage state machine that transmits messages, such as input/output messages to remote entities may need to perform functions without undue interruption. Introduction of locks may lead to deadlocks, which would be detrimental to the operation of the services.
Hence, there is a need for mechanisms to address the problem of concurrency and coordination in a concurrent and potentially distributed operating system. There is also a need for exposing a state of such processes.
The following presents a simplified summary of the disclosure in order to provide a basic understanding to the reader. This summary is not an extensive overview of the disclosure and it does not identify key/critical elements of the invention or delineate the scope of the invention. Its sole purpose is to present some concepts disclosed herein in a simplified form as a prelude to the more detailed description that is presented later.
In one example, a method is described for exposing a state of a process in which a plurality of messages associated with services may be received and posted on one or more queues. Instructions associated with the posted messages and queues may execute with an underlying state. The state may be exposed via an attribute.
In another example, a method is described in which messages of processes run concurrently and semantics and class of the processes or the messages are declared and/or exposed.
In another example, a computer-readable medium is described containing executable code for receiving messages from services and executing messages concurrently based on an underlying state. The underlying state may be exposed via an attribute.
Many of the attendant features will be more readily appreciated as the same becomes better understood by reference to the following detailed description considered in connection with the accompanying drawings.
The present description will be better understood from the following detailed description read in light of the accompanying drawings, wherein:
Like reference numerals are used to designate like parts in the accompanying drawings.
The detailed description provided below in connection with the appended drawings is intended as a description of the present examples and is not intended to represent the only forms in which the present example may be constructed or utilized. The description sets forth the functions of the example and the sequence of steps for constructing and operating the example. However, the same or equivalent functions and sequences may be accomplished by different examples. Systems described herein are provided as examples and not limitations. As those skilled in the art will appreciate, the present examples are suitable for application in a variety of different types of computing systems.
The method or system disclosed herein is operational with numerous other general purpose or special purpose computing system environments or configurations. Examples of well known computing systems, environments, and/or configurations that may be suitable for use with the invention include, but are not limited to, personal computers, server computers, hand-held or laptop devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like.
The method or system may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The method or system may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
With reference to
Computer 102 typically includes a variety of computer readable media. Computer readable media can be any available media that can be accessed by computer 102 and includes both volatile and nonvolatile media, removable and non-removable media. By way of example, and not limitation, computer readable media may comprise computer storage media. Computer storage media includes both volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can accessed by computer 102. Combinations of the any of the above should also be included within the scope of computer readable storage media.
The system memory 106 includes computer storage media in the form of volatile and/or nonvolatile memory such as read only memory (ROM) 110 and random access memory (RAM) 112. A basic input/output system 114 (BIOS), containing the basic routines that help to transfer information between elements within computer 102, such as during start-up, is typically stored in ROM 110. RAM 112 typically contains data and/or program modules that are immediately accessible to and/or presently being operated on by processing unit 104. By way of example, and not limitation,
The computer 102 may also include other removable/non-removable, volatile/nonvolatile computer storage media. By way of example only,
The drives and their associated computer storage media discussed above and illustrated in
The computer 102 may operate in a networked environment using logical connections to one or more remote computers, such as a remote computer. The remote computer may be a personal computer, a server, a router, a network PC, a peer device or other common network node, and typically includes many or all of the elements described above relative to the computer 102. The logical connections depicted in
When used in a LAN networking environment, the computer 102 is connected to the LAN 148 through a network interface or adapter 152. When used in a WAN networking environment, the computer 102 typically includes a modem 154 or other means for establishing communications over the WAN 150, such as the Internet. The modem 154, which may be internal or external, may be connected to the system bus 108 via the user input interface 144, or other appropriate mechanism. In a networked environment, program modules depicted relative to the computer 102, or portions thereof, may be stored in the remote memory storage device. By way of example, and not limitation, remote application programs may reside on a memory device. It will be appreciated that the network connections shown are exemplary and other means of establishing a communications link between the computers may be used.
A method and system is described in which any number of applications or services may be performed or executed either exclusively to itself or concurrently in any node or combination of nodes. Also, any number of services may be associated with processes that may execute and may be performed either exclusively or concurrently with other processes. Also, any of the services may include interfaces through which communication of various components in the performance of a function may occur.
Control of the functions and/or instructions of the functions in any of the devices may be performed such that any of the devices are coordinated according to a desired or predetermined scheme. For example, through execution of an instruction of a process (203, 204, 205) in the first device 201, a message may received at a concurrency module 210. Similarly, additional messages may be received at the concurrency module 210 form any of the processes of any of the devices. Based on the received message, corresponding instructions may be executed concurrently. In this example, a determination as to which process of different devices may be made such that the processes may be accomplished concurrently. Also, any number and any type of entities may be coordinated.
Each component or entity providing a service may be executing substantially simultaneously or concurrently with any number of other instructions, services or messages from any number or type of other components or entities. Also, any of the services may adopt any number of states. The state of a service may describe a condition of the service at any particular point in time. The conditions may vary, for example, based on the activities or any parameters associated with the service.
Control or management of such services may be provided by processes, policies and/or functions underlying the attribute such as a concurrency module.
Input/output (I/O) instructions from any number or type of service may be managed concurrently via any number of ports (e.g., ports 420, 421, 422, 423). The ports may include data or information that may be stored in a queue structure. For example, an asynchronous I/O operation may execute and provide a result item that may post to the port (e.g., port 420). The port (e.g., port 420) may also include a receiver task for processing the result item via an arbiter class method. In one example, the concurrency module 410 may manage concurrency by specifying a multi-stage state machine that may send messages to remote entities. Hence, in this example, I/O is considered messages and some behavior is run exclusive to other behavior. A class and corresponding methods of the type found in the queue may be created.
In yet another example, a message may be specified as state site affecting via semantics of the message. Semantics are used to characterize names of components of the messages where the names may be derived from predetermined operation types in which the concurrency module may enforce. Hence, any application may be considered to be a service sending messages. The application in this illustration may further act as a coordinator for characterizing messages that are posted on the queue.
In another example, the semantics of an attribute may be applied to a variety of coordination mechanisms. For example, an arbiter may implement coordination primitives over queues or execute user code responsive to a variety of events. Many classes of arbiters may be used. For example, a simple arbiter may receive a single item receive. Other arbiters may be more complex and may implement declarative concurrency (e.g., interleave) or may permit nesting. Any arbiter class may also run under the attribute and may further define any number or type of methods. The methods defined by an arbiter class may create any number or type of other objects. Any type of arbiter class may be used. One example of an arbiter class may include a receive arbiter that may indicate a method to process a single item from a single port or a multiple receive arbiter that may indicate a method to process multiple items from a port. These are merely examples as any arbiter class may be used.
One example of a receiver type is the teardown receiver group (receiver group 522,
In another example illustrated in
In another example illustrated in
Multiple interleaves may also be combined to form larger interleaves.
Any service may further include a yield function, IEnumerator function and/or get handler. When a yield function is invoked, a break in execution of instructions may occur without a break in a thread in which execution of the operations may be interrupted, at least temporarily. A breakpoint may be set (e.g., during debugging) such that after a yield, the compiler may continue compiling with no threads blocked. This may permit scaling to many work items while still performing sequential protocols. In a yield, functions may be logically blocked for a logical execution in a logical execution context.
The process may wait for the receipt of a response 1330 (e.g., from partner service 1303) before proceeding to a responding to the client 1302 with a get response 1340. In this example, a message may be sent with a subsequent yield return on a receiver. In this example, no matter how many messages are received, any number of messages or instructions may execute concurrently or asynchronously.
Additionally or alternatively, an interleave may be active containing underlying state. The state corresponding to the interleave may be provided such that other processes that may execute concurrently may be executed. For example, a state of a process or service may execute a concurrent handler corresponding to a concurrent state of the process or service. Other concurrent processes or services may also be executing. Any of the operations associated with the multiplicity of processes or services may be executed concurrently or asynchronously.
In addition, the handler (e.g., service handler) may send an update message. The update message may update a receiver to a new (or updated) state. In one example, the update message may not execute during temporary yields. For example, a process may yield such the execution of the process has been temporarily suspended while waiting for a result from another service or process. In this case, if an update message is received corresponding to the process, the update message may be deferred until the process has completed.
A method and system is described of a declarative attribute for annotating methods for managing concurrency. The attribute may declare corresponding semantics of the process such that a state of the corresponding process or service may be exposed (e.g., if the service is a concurrent service, exclusive service, teardown, etc.). State and behavior may be separated via services. For example, state may be made available by execution of any type of operations in a Decentralized System Services (DSS) implementation, including but not limited to GET, UPDATE, QUERY, etc. The attribute may be used in a handler for any message. One example of such a message is a GET message in which the handler may post the state of a corresponding service to a response port of a message. The attribute may be used in a method to identify member functions as message handlers for messages posted to a main service port. In addition, the attribute may also indicate an iterator to permit a handler to contain a sequence of asynchronous actions without blocking a thread.
In one example, the attribute may expose a state of a service in a method. The following illustrates an example of the attribute used in a Get message. The attribute in this example specifies a message handler as using read-only access to the state of a service and permitting message handlers not modifying state to run concurrently:
In another example, the attribute may also be used in an HTTPGET handler as follows:
In yet another example, the attribute is used in a replace message:
As can be seen above, in this example, the handler is indicated as capable of modifying state. For example, one exclusive handler executes at a time and concurrent handlers may not execute while an exclusive handler is running.
It is understood that aspects of the present description can take many forms and embodiments. The embodiments shown herein are intended to illustrate rather than to limit the description, it being appreciated that variations may be made without departing from the spirit of the scope of the invention. Although illustrative embodiments have been shown and described, a wide range of modification, change and substitution is intended in the foregoing disclosure and in some instances some features may be employed without a corresponding use of the other features. Accordingly, it is appropriate that the appended claims be construed broadly and in a manner consistent with the scope of the invention.