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

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

    结束

  • 相关阅读:
    结对编程之附加题:单元测试
    机器学习第二次作业
    第一次作业
    机器学习第二次作业
    机器学习第一次个人作业
    软工实践个人总结
    第08组 Beta版本演示
    第08组 Beta冲刺(5/5)
    第08组 Beta冲刺(4/5)
    第08组 Beta冲刺(3/5)
  • 原文地址:https://www.cnblogs.com/gaojian/p/2757383.html
Copyright © 2011-2022 走看看