PostgreSQL启动过程中的那些事七:初始化共享内存和信号:四 shmem中初始化subtrans(二)

2014-11-24 08:11:56 · 作者: · 浏览: 6
ount[slotno]= ++cur_lru_count;

* The oldest page is therefore the one withthe highest value of

* cur_lru_count- page_lru_count[slotno]

* The counts will eventually wrap around, butthis calculation still

* works as long as no page's age exceedsINT_MAX counts.

*----------

*/

int cur_lru_count;

/*

* latest_page_number is the page number of thecurrent end of the log;

* this is not critical data, since we use itonly to avoid swapping out

* the latest page.

*/

int latest_page_number;

} SlruSharedData;

typedef SlruSharedData *SlruShared;

下面看看初始化完" SUBTRANS Ctl"相关结构后在内存中的结构图

\

初始化完SUBTRANS相关结构的内存结构图

为了精简上图,把创建shmem的哈希表索引"ShmemIndex"时创建的HCTL结构删掉了,这个结构的作用是记录创建可扩展哈希表的相关信息。增加了左边灰色底的部分,描述共享内存/shmem里各变量物理布局概览,由下往上,由低地址到高地址。其中的"SUBTRANSCtl"即clog的相关结构图下面分别给出,要不上面的图太大太复杂了。

\

SUBTRANS相关结构图