05.08.2014 Views

here - Stefan-Marr.de

here - Stefan-Marr.de

here - Stefan-Marr.de

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3. Which Concepts for Concurrent and Parallel Progr. does a VM need to Support?<br />

STM based on mutable TVars [Harris et al., 2005]. TVars, i. e., transaction variables,<br />

are shared memory locations that support atomic memory transactions.<br />

It is implemented as part of the GHC runtime system, i. e., it is supported<br />

directly by the VM. One of the provi<strong>de</strong>d STM-implementation strategies uses<br />

fine-grained locking of TVars to minimize serialization of execution during<br />

commits.<br />

In<strong>de</strong>pen<strong>de</strong>ntly from the STM system, GHC supports explicit spawning of<br />

parallel executing sparks, which are lightweight threads. Haskell’s par eventually<br />

results in a call to the corresponding newSpark primitive in the runtime.<br />

With the support for MVars, GHC enables additional communication patterns,<br />

for instance channel-based communication, building on the i<strong>de</strong>as of M-<br />

Structures [Barth et al., 1991; Peyton Jones et al., 1996]. MVars are synchronization<br />

variables that can store values. Their basic operations are takeMVar and<br />

putMVar. When an MVar is empty, a takeMVar will block. Similarly, putMVar<br />

will block when it is full. MVars are implemented in the runtime (StgMVar).<br />

The standard library provi<strong>de</strong>s a semaphore construct on top of MVars. Furthermore,<br />

the library inclu<strong>de</strong>s proper channels and various abstractions to<br />

perform map/reduce and data parallel operations.<br />

Mozart The data-flow variables of Oz, and their direct support in the Mozart<br />

VM enable algorithm <strong>de</strong>signs that are significantly different from algorithms<br />

based on threads and locks. An OzVariable represents these data-flow variables<br />

insi<strong>de</strong> the VM and for instance keeps track of all threads that are<br />

suspen<strong>de</strong>d on unresolved data <strong>de</strong>pen<strong>de</strong>ncies. The directly exposed VM support<br />

for channels (OzPort) enriches the choice for programmers even further.<br />

T<strong>here</strong>fore, we conclu<strong>de</strong> that the Mozart VM provi<strong>de</strong>s abstractions for Communicating<br />

Threads in addition to the Threads and Locks-based ones.<br />

3.1.2.3. Communicating Isolates (ComI)<br />

As <strong>de</strong>fined in Sec. 2.4.1, the main concept introduced by communicating isolates<br />

is the strong state encapsulation between concurrent entities. This breaks<br />

with the typical shared memory mo<strong>de</strong>l and enforces clear separation between<br />

components. Communication has to be performed either via value-based messaging<br />

or by using explicitly introduced and constrained shared memory data<br />

structures.<br />

Common Language Infrastructure In addition to Threads and Locks-based<br />

abstractions, the CLI specifies so-called application domains that provi<strong>de</strong> a no-<br />

50

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!