什么是写时复制? [英] What is copy-on-write?

查看:1240
本文介绍了什么是写时复制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道写作是什么,它用于什么? Sun JDK教程中多次提到术语写时复制数组,但我不明白这是什么意思。

解决方案

我要写出自己的解释,但这个维基百科的文章



以下是基本概念:


写时复制(有时称为COW)是计算机编程中使用的优化策略。基本思想是,如果多个呼叫者要求最初无法区分的资源,则可以给他们指向同一资源的指针。该函数可以保持,直到调用者尝试修改其资源的副本,此时创建一​​个真正的私有副本,以防止更改变得对其他人都可见。所有这些都对呼叫者透明地发生。主要的优点是如果一个来电者从未进行任何修改,则不需要创建私人副本。


此处还有COW的共同使用的应用:


COW概念也用于维护数据库服务器上的即时快照,如Microsoft SQL Server 2005.即时快照通过在更新底层数据时存储数据的预修改副本来保留数据库的静态视图。即时快照用于测试用途或与时间有关的报告,不应用于替换备份。



I would like to know what copy-on-write is and what it is used for? The term 'copy-on-write array' is mentioned several times in the Sun JDK tutorials but I didn't understand what it meant.

解决方案

I was going to write up my own explanation but this Wikipedia article pretty much sums it up.

Here is the basic concept:

Copy-on-write (sometimes referred to as "COW") is an optimization strategy used in computer programming. The fundamental idea is that if multiple callers ask for resources which are initially indistinguishable, you can give them pointers to the same resource. This function can be maintained until a caller tries to modify its "copy" of the resource, at which point a true private copy is created to prevent the changes becoming visible to everyone else. All of this happens transparently to the callers. The primary advantage is that if a caller never makes any modifications, no private copy need ever be created.

Also here is an application of a common use of COW:

The COW concept is also used in maintenance of instant snapshot on database servers like Microsoft SQL Server 2005. Instant snapshots preserve a static view of a database by storing a pre-modification copy of data when underlaying data are updated. Instant snapshots are used for testing uses or moment-dependent reports and should not be used to replace backups.

这篇关于什么是写时复制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆