基于首次写入优先内存分配策略及空间管理方法.pdfVIP

  • 2
  • 0
  • 约4.7千字
  • 约 6页
  • 2025-10-23 发布于北京
  • 举报

基于首次写入优先内存分配策略及空间管理方法.pdf

考虑存在大小为M的空间,编号从0到M-1。如下图所示:

当需要在该空间中写入数据时,总是查找第一个足够大的连续的空块,并在

其中填写数据。例如:写入的数据大小为2,这些单元被标记为1,因为这是第

一次写入的数据。空间中的布局如下图所示:

如果我们继续向空间中写入大小为3与2的数据。第2-4单元包含了第2

次写入的数据,第5-6单元包含了第3次写入的数据。其布局如下图所示:

继续写入数据,当发现没有足够的连续单元可以数据。那么将最早写入

空间的数据剔除,直到腾出了足够的空间可以写入接下来的数据。假设空间

在写入第8个数据,空间已满,如下图所示:

我们继续写入大小为4的第9个数据,我们需要将第1次写入的数据从空间

中挪出,以便有腾出空间。

ConsiderthatthereisastoragespaceofsizeM,numberedfrom0toM-1.Asshown

below:

Whendataneedstobewritteninthisstoragespace,thefirstcontinuousemptyblockthatislarge

enoughisalwaysfoundandthedataisfilledinit.Forexample:thedatasizewrittenis2,thesecells

aremarkedas1becausethisisthefirsttimethedataiswritten.Thelayoutinthestoragespaceisas

shownbelow:

Ifwecontinuetowritedataofsize3and2tothestoragespace.Units2-4containthedatawrittenforthe

secondtime,andunits5-6containthedatawrittenforthethirdtime.Itslayoutisshownbelow:

Continuewritingdatawhenitisfoundthattherearenotenoughcontiguouscellstostorethedata.

Thentheearliestdatawrittentothestoragespacewillbeeliminateduntilenoughspaceisfreedto

writethenextdata.Assumethatthestoragespaceisfullafterwritingthe8thdata,asshowninthe

followingfigure:

Wecontinuetowritetheninthdataofsize4.Weneedtomovethefirstwrittendataoutofthestorage

spacetomakeroom.

然而还是没有足够的空间用于写入第9次数据,继续把第2次写入的数据

挪出。此时有5个连续单元块,因此将第9次数据写入0-4号单元中。

注:

1.如果有多个足够的连续空间来数据,优先选择起始单元格编号最小的连

续单元格。

2.当第i次写入数据大小时跳过该数据,并按写入顺序输出SKIP:序号

i数据大小

情况包括:数据大小0或超过最长可分配的连续空间长度。

在若干次写入数据后,将

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档