here - Stefan-Marr.de
here - Stefan-Marr.de
here - Stefan-Marr.de
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
3. Which Concepts for Concurrent and Parallel Progr. does a VM need to Support?<br />
or computational intensive operations provi<strong>de</strong>d by the un<strong>de</strong>rlying system or<br />
primitives. T<strong>here</strong>by, it enables a certain <strong>de</strong>gree of parallel execution and latency<br />
hiding. C modules for Python are able to use PyEval_AcquireLock()<br />
and PyEval_ReleaseLock() to release the lock before starting I/O or computational<br />
intensive operations that do not require interpreter intervention and<br />
t<strong>here</strong>by enable other threads to use it.<br />
The threading module provi<strong>de</strong>s threads, locks, recursive locks, barriers,<br />
semaphores, and condition variables. However, only thread operations, locks,<br />
and recursive locks are implemented as primitives. Barriers, semaphores, and<br />
condition variables are built completely on top of them.<br />
Similarly to Mozart, Python’s support for Communicating Isolates is discussed<br />
separately in Sec. 3.1.2.3.<br />
Ruby Similarly to Python, Ruby’s standard implementation is based on a<br />
GIL, called global VM lock (gvl). C modules that want to execute in parallel<br />
can do so by using the high-level rb_thread_blocking_region(..) function,<br />
by which they promise to take care of threading issues by themselves, and<br />
the VM will release the gvl during execution. However, this is of course not<br />
offered at the language level.<br />
To the user, Ruby offers primitives for Threads and Mutexes combined with<br />
the shared memory mo<strong>de</strong>l as part of VM support. The standard library builds<br />
on this basic support by offering for instance condition variables.<br />
Self and Squeak Squeak is based on the i<strong>de</strong>as of Smalltalk-80 [Goldberg and<br />
Robson, 1983] and follows its specification closely (cf. sections 4.3 and 4.4).<br />
Self [Chambers et al., 1989] belongs to the Smalltalk family of languages as<br />
well, but has significant differences in terms of its object mo<strong>de</strong>l. Furthermore,<br />
it pioneered important language implementation techniques such as dynamic<br />
optimization. Both Squeak and Self closely follow the standard Smalltalk<br />
mo<strong>de</strong>l when it comes to concurrent and parallel programming. They offer<br />
the notion of green threads in combination with semaphores.<br />
Squeak implements these concepts based on primitives. It provi<strong>de</strong>s for instance<br />
yield, resume, and suspend primitives to influence the scheduling of<br />
green threads (instances of the Process class). Furthermore, it provi<strong>de</strong>s the<br />
signal and wait primitives to interact with the semaphore implementation<br />
of the VM. Based on these, the libraries provi<strong>de</strong> mutexes, monitors, and concurrent<br />
data structures such as queues.<br />
48