Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why is it not possible to just adopt the Java memory model?

adopt Java memory model possible
0
Posted

Why is it not possible to just adopt the Java memory model?

0

The Java memory model was heavily motivated by the desire to preserve both type-safety and some other security guarantees, both of which are essential if untrusted code is to be run in the same address space with trusted code. Since this is in any case impossible for ordinary C or C++ code, this is no longer a consideration. Furthermore, it appears that making Java-like guarantees for C++ is potentially expensive, particularly on architectures that provide a weak memory model, or weak atomicity guarantees for ordinary stores. For example, implementations would have to ensure that an object pointer cannot be passed from one thread to another without previously making the objects vtable pointer visible to the other thread. This is likely to require a memory barrier during object construction. And C++ programmers, unlike Java programmers, tend to expect object construction to be a very light-weight operation. It does however appear more and more likely that we will borrow heavily from the

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123