## 5 IO Data Management and Data Sharing
### Distributed SQL Databases with RPC
#### 5.1.1. Replicated Data Bases and Tables
Shell worker processes (not worker threads) use named system-level semaphores instead. There is a memory block manager that performs memory block allocation and release (low-level access to SMS), and an object manager that provides high-level access that supports object creation and destruction by using a type interface library or the programmatically provided type signatures of JS objects. The overall SBO architecture is shown in Figure 6. Any SBO can be serialized in one process and deserialized in another process (assuming that the SMS was already shared by the processes). This serialization creates an object descriptor containing memory and object information (like the type signature and object class). SMS/BO are used by multiple worker processes to implement shared buffer objects (SBO) being accessed concurrently. These are used to share input, intermediate, and output data between worker processes of the same class (i.e., web worker or shell worker) and that are running on the same machine (host). The access to SBOs is not synchronized, although each basic read and write access of an SBO is atomic. In contrast to message-based communication, which is only directly possible between a worker and the main process, SBOs can be used for data communication between workers, although there is no synchronization. Programmatical access of SBOs is shown in Example 8. ```
//Createtypeinterfaces vartypesDef={ xy:{x:'int',y:'int',z:'string'}  
Figure 6: Shared buffer objects: architecture and programmatical access.  
} //Createagenericsharedmemorybuffer varsharedBuffer=newSharedArrayBuffer(1E5); //AttachsharedmemorytoSBSinstance varsm=BufferSegment(sharedBuffer,{key:'/shm1'}); sm.create(); //addtypelibrary sm.library(typesDef); //Createandinitializeasharedobject objShared=sm.object('xy'); objShared.x=0;objShared.y=0; //Createworkers varworker=newWorker(...) //ShareSHS awaitworker.share('this.sm1',sm) //ShareBufferObject awaitworker.share('this.objShared',objShared) //Sharedtypedarraymatrix varmatShared=sm.object('MatrixTA-Float32',[1000,1000]); matShared.set(1,1,Math.random()) awaitworker.share('this.matShared',matShared) //Accesssharedobjectinworker avaitworker.evalf(function(x){ this.objShared.x=x; this.matShared.set(1,2, this.matShared.get(2,1))},1) //That'sallfolks! ```

Example 8. Creation and usage of a shared object memory with an initial set of object interfaces and one shared object. Shared objects can be efficiently deployed if there is data interdependency between workers during computation. The access time of a shared object via the proxy monitor access (read/write) is only 2-10 times slower, compared with a native JS object. For example, in a web worker, the read or write access of a native JS object requires about 10 ns, whereas the access of a shared object (using SharedArrayBuffer objects) requires about 100 ns. In a shell worker using node.js, the native object access requires about 2 ns, whereas the shared object access (using OS-level named shared memory segments) requires about 4 ns. Matrix objects that use linear typed array (shared) buffers present similar access times. There is no significant difference in matrix cell access times (about 30 ns in a web-worker and 3 ns in a shell-worker process). The SMS instance automatically manages the memory allocation and release of shared objects using the provided shared memory segment. The SMS method share provides the full logic to map the shared memory to the destination worker (dependent upon the worker class) and to create a copy of the SMS instance on the worker. Note that the \"this\" object is a persistent object in the top-level context scope of the worker and can be shared between successive worker calls. ### Distributed Objects

Using object monitors and proxies, it is possible to distribute objects by message-passing. In contrast to the shared memory objects, an additional organizational layer is required to establish group communication.