[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Incremental Data Structures



Philipp Garcia <phil@xxxxxxxxxxxxxxxxx> wrote:
>I was wondering if anyone had considered using a copy-on-write scheme
>for GO data. In such a scheme, several object can share a data structure.
>When an object method is called that requires a change to the data
>structure, then that object first copies the data structure somewhere
>else and then modifies the copy (if the data structure is not shared, no
>copy is necessary). This technique is common in UNIX operating system so
>that if five copies of "who", for example, are running, only one copy
>would actually resigned in physical memory; each process should share
>the memory (see Andrew S. Tanenbaum "Modern Operating Systems for more
>information). Generally this scheme is implemented using reference counting
>and additional (but not required) with smart pointers in C++ (see Scott
>Meyers "More Effective C++" for detailed information and sample code).

My program "gottaGo" uses copy-on-write for some data structures.  Being a  
lazy programmer, gottaGo does lookahead by copying the entire board state  
and working with that (rather than incremental update of data structures).   
This makes it extremely easy to "undo" a move:  simply revert to the  
original data structures.  But it makes for a lot of copying.  Since gottaGo  
is written in C++, it encapsulates member data in access member functions.   
This makes it possibly to add copy-on-write for those data members where it  
matters most for performance.
---
			Eric Pettersen
			pett@xxxxxxxxxxxxxxxxx (NeXTmail capable)