对Postmaster 中 bufmgr.c 的 BgBufferSync.c 中静态变量的学习理解---saved_info_valid

简介:

开始

复制代码
bool                    
BgBufferSync(void)                    
{                    
    ……                
                    
    /*                
     * Information saved between calls so we can determine the strategy                
     * point's advance rate and avoid scanning already-cleaned buffers.                
     */                
    static           bool       saved_info_valid = false;                
    static           int        prev_strategy_buf_id;        
    static          uint32         prev_strategy_passes;        
    static          int        next_to_clean;        
    static     uint32     next_passes;        
                    
                    
    /* Moving averages of allocation rate and clean-buffer density */                
    static     float     smoothed_alloc = 0;        
    static     float     smoothed_density = 10.0;        
                    
    ……                
                    
    /*                
     * If we're not running the LRU scan, just stop after doing the stats                
     * stuff.  We mark the saved state invalid so that we can recover sanely                
     * if LRU scan is turned back on later.                
     */                
    if (bgwriter_lru_maxpages <= 0)                
    {                
        saved_info_valid = false;            
        return true;            
    }                
                    
    if (saved_info_valid)                
    {                
        ……            
    }                
    else                
    {                
        ……            
    }                
                    
    /* Update saved info for next time */                
    prev_strategy_buf_id = strategy_buf_id;                
    prev_strategy_passes = strategy_passes;                
    saved_info_valid = true;                
                    
    ……                
    /* Return true if OK to hibernate */                
    return (bufs_to_lap == 0 && recent_alloc == 0);                
}                    
复制代码

一开始 :saved_info_valid 是 false的。

运行一次后,就会变成 true。(bgwriter_lru_maxpages <=0 的情形除外)

结束





本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/11/02/2751316.html,如需转载请自行联系原作者

目录
相关文章
|
9月前
|
Ubuntu 数据安全/隐私保护
All data created during this guest session will be deleted when you log out 问题的解决
All data created during this guest session will be deleted when you log out 问题的解决
|
网络安全 开发工具
【解决方案】A session ended very soon after starting. Check that the command in profile “XXX” is correct.
【解决方案】A session ended very soon after starting. Check that the command in profile “XXX” is correct.
790 0
【解决方案】A session ended very soon after starting. Check that the command in profile “XXX” is correct.