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 />

actor-based language directly to application programs. The main operations<br />

are directly provi<strong>de</strong>d by the instruction set. The send instruction implements<br />

asynchronous message sends to a specified actor, i. e., Erlang process. The<br />

wait and wait_timeout instructions are used to wait for incoming messages<br />

on the message queue. To facilitate Erlang’s pattern matching, messages are<br />

only removed from the message queue when the explicit remove_message instruction<br />

is used. However, new Erlang processes are spawned by a primitive.<br />

For use-cases like the Mnesia database, 12 Erlang also provi<strong>de</strong>s a set of primitives<br />

for mutable concurrent hash-tables (ets, Erlang term storage 13 ) that can<br />

be shared between actors. While this introduces a restricted notion of shared<br />

state, it is not part of the core primitives suggested for general use.<br />

Perl The Perl 14 VM offers support for so-called threads. However, this terminology<br />

is not in line with the commonly accepted notion of threads. Perl’s<br />

threads are more directly comparable to OS processes as they provi<strong>de</strong> a nonshared<br />

memory programming mo<strong>de</strong>l by <strong>de</strong>fault. However, the VM provi<strong>de</strong>s<br />

primitives in the threads::shared module to enable the use of shared data<br />

structures between these threads. Data structures can only be shared between<br />

threads after they have been explicitly prepared for sharing with the share()<br />

primitive. To use this restricted form of shared memory, the VM provi<strong>de</strong>s<br />

the Queue data structure for channel-like communication, as well as a lock<br />

primitive, a Semaphore class, and primitives for condition variables.<br />

Python As discussed in Sec. 3.1.2.1, Python’s main programming mo<strong>de</strong>l is<br />

based on threads and locks with a VM implementation that is constrained<br />

by global interpreter lock (GIL) semantics. Since the GIL hin<strong>de</strong>rs any form of<br />

parallel execution of Python byteco<strong>de</strong>s, VM support for process-based parallelism<br />

was ad<strong>de</strong>d. The standard library provi<strong>de</strong>s the multiprocessing module<br />

to offer an abstraction for parallel programming similar to Perl. Python’s<br />

VM inclu<strong>de</strong>s primitives for channels in the form of a message queue (Queue),<br />

as well as primitives for semaphores on top of which for instance the Lock and<br />

Condition classes are built. These can operate on shared memory that has to<br />

be requested explicitly between communicating processes and is restricted<br />

to certain data structures. Value and Array are the shareable data structure<br />

primitives directly exposed by the library. Value is by <strong>de</strong>fault a synchronized<br />

12 http://www.erlang.org/doc/apps/mnesia/<br />

13 http://www.erlang.org/doc/man/ets.html<br />

14 http://perldoc.perl.org/perl.html<br />

52

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

Saved successfully!

Ooh no, something went wrong!