Shared heaps

Shared heaps in the Taligent Runtime system provide a convenient method for sharing memory. If an object allocates storage and you want the object in a shared heap, use this form of the new operator:

    new(kSameHeap, this) TFoo(arg)
This form of new is defined as new(EHeapType, void*, size_t), and it allocates the storage in the void* argument's heap. If the argument doesn't point to a heap, the allocation occurs in the default heap. This guarantees that any storage this object refers to is going to be in the same shared heap so that it is accessible from all address spaces. Storage allocated in the default heap is accessible only from the address space in which it was allocated.

As with any shared memory, access to objects in your shared heap must be synchronized, unless they do not change once created. For example, if objects built using MReferenceCounted don't change, you need to synchronize the code that locates them, but not the code that uses them. Do any such synchronization with global rather than local semaphores.

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker