SSDsim源码分析之get_ppn_for_pre_process

get_ppn_for_pre_process()介绍

前面我们介绍了SSDsim的读请求预处理函数,其功能就是将IOtrace文件中的所有IO读请求先预先处理,整体上的功能和过程就是为了模拟经过一段IO处理后整个SSD的状态。

其中,在pre_process_for_page()函数中,有一个非常重要的调用子函数get_ppn_for_pre_process(),这个函数是在程序判断当前IOtrace读请求针对当前lsn区域的操作时,根据在内存dram结构中的map_entry[lpn].state中的映射状态来考究:如果映射存在,也就说明此时该lpn对应的子页数据有效,我们可以直接从buffer中进行读取;否则如果map_entry[lpn].state状态位为0说明映射无效,该lpn对应的物理页闪存页面数据尚未成功映射至内存和拷贝至buffer中,因此我们需要重新构建新的lpn<–>ppn的映射关系。所以函数会直接调用get_ppn_for_pre_process()进行一个ppn的获取过程。


源码及注释

接下来我们便针对这个get_ppn_for_pre_process()进行一个详尽的分析。首先我们先直接看源代码和相关注释:

unsigned int get_ppn_for_pre_process(struct ssd_info *ssd,unsigned int lsn)     
{
    unsigned int channel=0,chip=0,die=0,plane=0; 
    unsigned int ppn,lpn;
    unsigned int active_block;
    unsigned int channel_num=0,chip_num=0,die_num=0,plane_num=0;

#ifdef DEBUG
    printf("enter get_psn_for_pre_process\n");
#endif

    channel_num=ssd->parameter->channel_number;
    chip_num=ssd->parameter->chip_channel[0];
    die_num=ssd->parameter->die_chip;
    plane_num=ssd->parameter->plane_die;
    lpn=lsn/ssd->parameter->subpage_page;

    if (ssd->parameter->allocation_scheme==0)                           /*动态方式下获取ppn*/
    {
        if (ssd->parameter->dynamic_allocation==0)                      /*表示全动态方式下,也就是channel,chip,die,plane,block等都是动态分配*/
        {                                                               //全动态下,需要时才进行分配
            channel=ssd->token;
            ssd->token=(ssd->token+1)%ssd->parameter->channel_number;   //
            chip=ssd->channel_head[channel].token;
            ssd->channel_head[channel].token=(chip+1)%ssd->parameter->chip_channel[0];
            die=ssd->channel_head[channel].chip_head[chip].token;
            ssd->channel_head[channel].chip_head[chip].token=(die+1)%ssd->parameter->die_chip;
            plane=ssd->channel_head[channel].chip_head[chip].die_head[die].token;
            ssd->channel_head[channel].chip_head[chip].die_head[die].token=(plane+1)%ssd->parameter->plane_die;
        } 
        else if (ssd->parameter->dynamic_allocation==1)                 /*表示半动态方式,channel静态给出,packagedie,plane动态分配*/                 
        {
            channel=lpn%ssd->parameter->channel_number;
            chip=ssd->channel_head[channel].token;
            ssd->channel_head[channel].token=(chip+1)%ssd->parameter->chip_channel[0];
            die=ssd->channel_head[channel].chip_head[chip].toke
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值