zoukankan      html  css  js  c++  java
  • 对PostgreSQL中 共享内存指针的再认识

    开始

    先给 shmem.c 中增加代码(用来打印全局变量 ShmemIndex)

    void getmemPointer()
    {
        fprintf(stderr,"ShmemIndex  ShmemIndex is %ld \n", ShmemIndex);
        return;
    }

    然后,分别在 bgwriter.c 和 walwriter.c 中,增加如下代码:

    /*
     * Main entry point for bgwriter process
     *
     * This is invoked from AuxiliaryProcessMain, which has already created the
     * basic execution environment, but not enabled signals yet.
     */
    void
    BackgroundWriterMain(void)
    {
            //added by gaojian
            fprintf(stderr,"BackgroundWriterMain........");
            getmemPointer();
    …
    
    }
    /*
     * Main entry point for walwriter process
     *
     * This is invoked from AuxiliaryProcessMain, which has already created the
     * basic execution environment, but not enabled signals yet.
     */
    void
    WalWriterMain(void)
    {
            //added by gaojian
            fprintf(stderr,"WalWriterMain...........");
            getmemPointer();
    ......
    }

    然后,启动运行后,出现:

    [postgres@localhost bin]$ ./postgres -D /usr/local/pgsql/data
    LOG:  database system was shut down at 2012-11-06 16:59:15 CST
    BackgroundWriterMain........ShmemIndex  ShmemIndex is 128175904 
    WalWriterMain...........ShmemIndex  ShmemIndex is 128175904 
    LOG:  autovacuum launcher started
    LOG:  database system is ready to accept connections

    得出的结论是,所有的后台进程,恐怕其拥有的指向共享内存的指针,其中的地址完全相同。也就是它们都指向一个共同的共享内存。

    结束

  • 相关阅读:
    大道至简第四章读后感
    JAVA类与对象
    大道至简第三章读后感
    JAVA语法基础 动手动脑及课后作业
    课程作业01
    大道至简第二章读后感
    大道至简第一章读后感
    swift学习笔记之-自动引用计数
    swift学习笔记之-继承
    swift学习笔记之-闭包
  • 原文地址:https://www.cnblogs.com/gaojian/p/2757383.html
Copyright © 2011-2022 走看看