Resources | Resources |



Code sharing

For MOD backward compatibility in BREW, the code is shared by objects within the same process. Brew MP copies the module to every process using the code from the module, as there is no way to determine whether there is any writable data in the MOD file.

Since MOD1 is ELF format, the header of the ELF reveals if there is any writable data in the module. This enables the system to determine whether to maintain only shareable copy in the entire system for module that contains no writable data, or to give every Env its own copy if the module is non-shareable due to writable data.

Mod contains only IShell-based classes, so it can only be used by objects inside the BREW Shell. Each process that uses MOD code receives its own copy. The following diagram shows code sharing for MOD.

Code Sharing for MOD

MOD1 contains IEnv-based classes that can potentially be used anywhere in the system. If there is no writable data in MOD1, the system only maintains one shareable copy of the code in the entire system. If there is writable data in MOD1, it is considered non-shareable, and the system copies the file to each Env. The following diagram shows code sharing for MOD1.

Code sharing for MOD1

For more information on MOD vs. MOD1, see the article MOD vs. MOD1 in Brew MP in on the Brew MP website.