Saturday, 9 January 2016

Ruby Memory Model

Ruby memory model

The Ruby memory model is a framework allowing to reason about programs in concurrent and parallel environment. It defines what variable writes can be observed by a particular variable read, which is essential to be able to determine if a program is correct. It is achieved by defining what subset of all possible program execution orders is allowed.

A memory model sources:
Concurrent behavior sources of Ruby implementations:
A similar document for MRI was not found. Key fact about MRI is GVL (Global VM lock) which ensures that only one thread can interpret a Ruby code at any given time. When the GVL is handed from one thread to another a mutex is released by first and acquired by the second thread implying that everything done by first thread is visible to second thread. See thread_pthread.c and thread_win32.c.

This memory model was created by: comparing MRI, JRuby, JRuby+Truffle, Rubinius; taking account limitations of the implementations or their platforms; inspiration drawn from other existing memory models (Java, C++11). This is not a formal model.

No comments:

Post a Comment