/* 根据LFU算法进行页面替换 */ void do_LFU(Ptr_PageTableItem ptr_pageTabIt) { unsigned int i, min, page; printf("没有空闲物理块,开始进行LFU页面替换...\n"); /*for (i = 0, min = 0xFFFFFFFF, page = 0; i < BLOCK_SUM; i++) { if (actualMemory[i]->count < min) { min = actualMemory[i]->count; page = i; } }*/ page=clear(); printf("选择第%u页进行替换\n", page); if (actualMemory[i]->edited) { /* 页面内容有修改,需要写回至辅存 */ printf("该页内容有修改,写回至辅存\n"); do_page_out(actualMemory[page]); } actualMemory[i]->filled = FALSE; actualMemory[i]->count = 0; /* 读辅存内容,写入到实存 */ do_page_in(ptr_pageTabIt,page); /* 更新页表内容 */ ptr_pageTabIt->blockNum=page; ptr_pageTabIt->filled=TRUE; ptr_pageTabIt->edited=FALSE; ptr_pageTabIt->count=0; blockStatus[page]=TRUE; printf("页面替换成功\n"); }
/* 根据LFU算法进行页面替换 */ void do_LFU(Ptr_PageTableItem ptr_pageTabIt) { unsigned int i, min, page; printf("没有空闲物理块,开始进行LFU页面替换...\n"); for (i = 0, min = 0xFFFFFFFF, page = 0; i < PAGE_SUM; i++) { if (pageTable[i].count < min) { min = pageTable[i].count; page = i; } } printf("选择第%u页进行替换\n", page); if (pageTable[page].edited) { /* 页面内容有修改,需要写回至辅存 */ printf("该页内容有修改,写回至辅存\n"); do_page_out(&pageTable[page]); } pageTable[page].filled = FALSE; pageTable[page].count = 0; /* 读辅存内容,写入到实存 */ do_page_in(ptr_pageTabIt, pageTable[page].blockNum); /* 更新页表内容 */ ptr_pageTabIt->blockNum = pageTable[page].blockNum; ptr_pageTabIt->filled = TRUE; ptr_pageTabIt->edited = FALSE; ptr_pageTabIt->count = 0; printf("页面替换成功\n"); }
void do_switch(Ptr_PageTableItem ptr_pageTabIt) { unsigned int rec = 0, i; unsigned char min = 255; printf("没有空闲物理块,开始进行老化页面替换...\n"); for (i = 0; i < PAGE_SUM; i++) { if (pageTable[i].filled && pageTable[i].count < min){ min = pageTable[i].count; rec = i; } } printf("选择第%u页进行替换\n", rec); if (pageTable[rec].edited) { /* 页面内容有修改,需要写回至辅存 */ printf("该页内容有修改,写回至辅存\n"); do_page_out(pageTable + rec); } pageTable[rec].filled = FALSE; pageTable[rec].count = 0; /* 读辅存内容,写入到实存 */ do_page_in(ptr_pageTabIt, pageTable[rec].blockNum); /* 更新页表内容 */ ptr_pageTabIt->blockNum = pageTable[rec].blockNum; ptr_pageTabIt->filled = TRUE; ptr_pageTabIt->edited = FALSE; printf("页面替换成功\n"); }
void do_LRU(Ptr_PageTableItem ptr_pageTabIt)//LRU算法 { unsigned int i, page; int max; printf("没有空闲物理块,开始进行LRU页面替换...\n"); for (i = 0, max=-1, page = 0; i < PAGE_SUM; i++) { if (pageTable[i].filled&&pageTable[i].count_LRU > max) { max= pageTable[i].count_LRU; page = i; }//选择计数值最大的页面替换 } printf("选择第%u页进行替换\n", page); if (pageTable[page].edited) { /* 页面内容有修改,需要写回至辅存 */ printf("该页内容有修改,写回至辅存\n"); do_page_out(&pageTable[page]); } pageTable[page].filled = FALSE; pageTable[page].count = 0; pageTable[page].count_1=0; pageTable[page].count_LRU=0; /* 读辅存内容,写入到实存 */ do_page_in(ptr_pageTabIt, pageTable[page].blockNum);// /* 更新页表内容 */ ptr_pageTabIt->blockNum = pageTable[page].blockNum; ptr_pageTabIt->filled = TRUE; ptr_pageTabIt->edited = FALSE; ptr_pageTabIt->count_LRU= 0;// printf("页面替换成功\n"); }
/////jm void do_OldPage(Ptr_PageTableItem ptr_pageTabIt)//页面老化算法 { unsigned int i, min, page; printf("没有空闲物理块,开始进行页面老化替换...\n"); for (i = 0, min = 0xFFFFFFFF, page = 0; i < PAGE_SUM; i++) { if (pageTable[i].filled&&pageTable[i].count_1<min)//修改源码中的bug { min = pageTable[i].count_1; page = i; }//选择计数值最小的页面替换 } printf("选择第%u页进行替换\n", page); if (pageTable[page].edited) { /* 页面内容有修改,需要写回至辅存 */ printf("该页内容有修改,写回至辅存\n"); do_page_out(&pageTable[page]); } pageTable[page].filled = FALSE; pageTable[page].count = 0; pageTable[page].count_1=0; pageTable[page].R=0; /* 读辅存内容,写入到实存 */ do_page_in(ptr_pageTabIt, pageTable[page].blockNum); /* 更新页表内容 */ ptr_pageTabIt->blockNum = pageTable[page].blockNum; ptr_pageTabIt->filled = TRUE; ptr_pageTabIt->edited = FALSE; ptr_pageTabIt->count = 0; ptr_pageTabIt->count_1=0; ptr_pageTabIt->R=1; printf("页面替换成功\n"); }
static void finish_page_section( doc_section ds, bool eject ) { if( eject ) { g_skip = 0; // ignore remaining skip value } new_section( ds ); do_page_out(); }
void text_page_out( void ) { while( n_page.col_main != NULL ) { do_page_out(); update_t_page(); } return; }
void full_page_out( void ) { while( (n_page.col_top != NULL) || (n_page.col_main != NULL) || (n_page.col_bot != NULL) || (n_page.col_fn != NULL) ) { do_page_out(); update_t_page(); } return; }
void gml_exmp( const gmltag * entry ) { tag_cb * wk; entry = entry; scr_process_break(); if( !ProcFlags.xmp_active ) { // no preceding :XMP tag g_err_tag_prec( "XMP" ); scan_start = scan_stop + 1; return; } g_curr_font = font_save; ProcFlags.xmp_active = false; ProcFlags.justify = justify_save; wk = nest_cb; nest_cb = nest_cb->prev; add_tag_cb_to_pool( wk ); /* place the accumulated xlines on the proper page */ ProcFlags.group_elements = false; if( t_doc_el_group.first != NULL ) { t_doc_el_group.depth += (t_doc_el_group.first->blank_lines + t_doc_el_group.first->subs_skip); } if( (t_doc_el_group.depth + t_page.cur_depth) > t_page.max_depth ) { /* the block won't fit on this page */ if( t_doc_el_group.depth <= t_page.max_depth ) { /* the block will be on the next page */ do_page_out(); reset_t_page(); } } while( t_doc_el_group.first != NULL ) { insert_col_main( t_doc_el_group.first ); t_doc_el_group.first = t_doc_el_group.first->next; } t_doc_el_group.depth = 0; t_doc_el_group.last = NULL; scan_start = scan_stop + 1; return; }
/* 根据页面老化算法进行页面替换 */ void do_PA(Ptr_PageTableItem ptr_pageTabIt) { unsigned int i,k,s, min, page,index,processNum, c, temp_count; printf("没有空闲物理块,开始进行页面老化算法页面替换...\n"); for(s=0,min=0xFFFFFFFF,page=0,index=0,processNum=0;s<Process_SUM;s++) for(k=0;k<INDEX_SUM;k++) for (i = 0; i < INDEX_PAGE; i++) { for(c = 0, temp_count = 0;c < 8;c++){ temp_count = temp_count * 10 + pageIndex[s][k].index[i].count[c] - '0'; } if (temp_count < min && pageIndex[s][k].index[i].filled==TRUE) { min = temp_count; processNum=s; page = i; index=k; } } printf("选择第%u个目录第%u页进行替换\n",index,page); if (pageIndex[processNum][index].index[page].edited) { /* 页面内容有修改,需要写回至辅存 */ printf("该页内容有修改,写回至辅存\n"); do_page_out(&pageIndex[processNum][index].index[page]); } pageIndex[processNum][index].index[page].filled = FALSE; pageIndex[processNum][index].index[page].visited = 0; for(c = 0;c < 8;c++){ pageIndex[processNum][index].index[page].count[c] = '0'; } /* 读辅存内容,写入到实存 */ do_page_in(ptr_pageTabIt,pageIndex[processNum][index].index[page].blockNum); /* 更新页表内容 */ ptr_pageTabIt->blockNum =pageIndex[processNum][index].index[page].blockNum; ptr_pageTabIt->filled = TRUE; ptr_pageTabIt->edited = FALSE; ptr_pageTabIt->visited = 0; for(c = 0;c < 8;c++){ ptr_pageTabIt->count[c] = '0'; } printf("页面替换成功\n"); }
void do_LRU (Ptr_PageTableItem ptr_pageTabIt){ unsigned int i,page,popagenum; unsigned int popage[PAGE_SUM]; printf("没有空闲物理块,开始进行LRU页面替换...\n"); for (i = 0,page = 0,popagenum=0; i < PAGE_SUM ; i++){ if (pageTable[i].filled && pageTable[i].LRU_flag ==0){ popage[popagenum++] = i; } } if(popagenum>0){ page = popage[random()%popagenum] ; } else if (popagenum==0){ //没有找到未被使用的,随机选择一个 for (i = 0; i < PAGE_SUM; i++){ if (pageTable[i].filled){ popage[popagenum++] = i; } } page = popage[random()%popagenum]; } //随机选择一个 printf("选择第%u页进行替换\n", page); //该页面对应的物理块修改了 if (pageTable[page].edited) { /* 页面内容有修改,需要写回至辅存 */ printf("该页内容有修改,写回至辅存\n"); do_page_out(&pageTable[page]); } pageTable[page].filled = FALSE; pageTable[page].LRU_flag = 0; /* 读辅存内容,写入到实存 */ do_page_in(ptr_pageTabIt, pageTable[page].blockNum); /* 更新页表内容 */ ptr_pageTabIt->blockNum = pageTable[page].blockNum; ptr_pageTabIt->filled = TRUE; ptr_pageTabIt->edited = FALSE; ptr_pageTabIt->LRU_flag = 0; printf("页面替换成功\n"); }
//和LFU差不多,就是判断条件变了;怎么知道什么是最早最久使用的呢,建立一个链表,一旦使用了哪个 void do_LRU(Ptr_PageTableItem ptr_pageTabIt){ unsigned int i,j, pagei = 0,pagej = 0,blockNum; int flag = 0; printf("没有空闲物理块,开始进行LRU页面替换...\n"); while(flag==0){ //如果一直没有找到,说明当前的第一个已经被挪走了,再取一个; blockNum = LRU_get(); for (i = 0; i < ROOT_PAGE_SUM; i++) { for(j = 0; j<CHILD_PAGE_SUM; j++) { if (pageTable[i][j].blockNum==blockNum && pageTable[i][j].filled==TRUE) //在所有的被装入的页表中查找呦;谁最久没有被使用过了;找到在物理内存中的并且最早最久没被使用过的; { flag = 1; pagei = i; pagej = j; //如何跳出两个循环?设置一个标示位; break; } if(flag==1) break; } } } printf("选择第%u页目录进行替换,选择选择第%u页号进行替换\n", pagei,pagej); if (pageTable[pagei][pagej].edited)//被改写过了 { /* 页面内容有修改,需要写回至辅存 */ printf("该页的内容有修改,写回至辅存\n"); do_page_out(&pageTable[pagei][pagej]); } pageTable[pagei][pagej].filled = FALSE;//没有被装入; pageTable[pagei][pagej].count = 0; /* 将辅存内容写入实存 */ do_page_in(ptr_pageTabIt, pageTable[pagei][pagej].blockNum);//这个位置的被取代了; /* 更新页表内容 */ ptr_pageTabIt->blockNum = pageTable[pagei][pagej].blockNum; ptr_pageTabIt->filled = TRUE; ptr_pageTabIt->edited = FALSE; ptr_pageTabIt->count = 0; LRU_ChangeAdd(blockNum); printf("页面替换成功\n"); }
/* 根据LFU算法进行页面替换 */ void do_LFU(Ptr_PageTableItem ptr_pageTabIt) { unsigned int i, j, k,min, firstpage, page; int whichprogress=0; printf("没有空闲物理块,开始进行LFU页面替换...\n"); for(k=0;k<VIRTUAL_PROGRESSES;k++) for (i = 0, min = 0xFFFFFFFF, firstpage = 0, page = 0; i < LV1_PAGE_SUM; i++) { for (j = 0; j < LV2_PAGE_SUM; j++) { if (pageTable[k][i][j].count < min) { whichprogress=k; min = pageTable[k][i][j].count; firstpage = i; page = j; } } } printf("选择第%u页进行替换\n", firstpage * LV1_PAGE_SUM + page); if (pageTable[whichprogress][firstpage][page].edited) { /* 页面内容有修改,需要写回至辅存 */ printf("该页内容有修改,写回至辅存\n"); do_page_out(&pageTable[whichprogress][firstpage][page]); } pageTable[whichprogress][firstpage][page].filled = FALSE; pageTable[whichprogress][firstpage][page].count = 0; for(i=0;i<8;i++) { actmemcount[whichprogress][firstpage * LV1_PAGE_SUM + page][i]=0; } /* 读辅存内容,写入到实存 */ do_page_in(ptr_pageTabIt, pageTable[whichprogress][firstpage][page].blockNum); /* 更新页表内容 */ ptr_pageTabIt->blockNum = pageTable[whichprogress][firstpage][page].blockNum; ptr_pageTabIt->filled = TRUE; ptr_pageTabIt->edited = FALSE; ptr_pageTabIt->count = 0; printf("页面替换成功\n"); }
//修改了, void do_LFU(Ptr_PageTableItem ptr_pageTabIt) { unsigned int i,j, min = 0xFFFFFFFF, pagei = 0,pagej = 0; printf("没有空闲物理块,开始进行LRU页面替换...\n"); for (i = 0, min = 0xFFFFFFFF; i < ROOT_PAGE_SUM; i++) { for(j = 0; j<CHILD_PAGE_SUM; j++) { if (pageTable[i][j].count < min&&pageTable[i][j].filled==TRUE)//在所有的被装入的页表中查找呦; { min = pageTable[i][j].count; pagei = i; pagej = j; } } } printf("选择第%u页目录进行替换,选择选择第%u页号进行替换\n", pagei,pagej); if (pageTable[pagei][pagej].edited)//被改写过了 { /* 页面内容有修改,需要写回至辅存 */ printf("该页的内容有修改,写回至辅存\n"); do_page_out(&pageTable[pagei][pagej]); } pageTable[pagei][pagej].filled = FALSE;//没有被装入; pageTable[pagei][pagej].count = 0; /* 将辅存内容写入实存 */ do_page_in(ptr_pageTabIt, pageTable[pagei][pagej].blockNum);//这个位置的被取代了; /* 更新页表内容 */ ptr_pageTabIt->blockNum = pageTable[pagei][pagej].blockNum; ptr_pageTabIt->filled = TRUE; ptr_pageTabIt->edited = FALSE; ptr_pageTabIt->count = 0; printf("页面替换成功\n"); }
/* 根据LFU算法进行页面替换 */ void do_LFU(Ptr_PageTableItem ptr_pageTabIt) { unsigned int i,k, min, page2 ,page1; printf("没有空闲物理块,开始进行LFU页面替换...\n"); for (k = 0, min = 0xFFFFFFFF, page1 = 0,page2 = 0; k < PAGE_SUM2; k++) { for(i = 0;i< PAGE_SUM1; i++){ if (pageTable[k][i].count < min&&pageTable[k][i].filled) //修改4:加上filled的判断 { min = pageTable[k][i].count; page1 = i; page2 = k; } } } printf("选择第%u页中的第%u页进行替换\n", page2 , page1 ); if (pageTable[page2][page1].edited) { /* 页面内容有修改,需要写回至辅存 */ printf("该页内容有修改,写回至辅存\n"); do_page_out(&pageTable[page2][page1]); } pageTable[page2][page1].filled = FALSE; pageTable[page2][page1].count = 0; /* 读辅存内容,写入到实存 */ do_page_in(ptr_pageTabIt, pageTable[page2][page1].blockNum); /* 更新页表内容 */ ptr_pageTabIt->blockNum = pageTable[page2][page1].blockNum; ptr_pageTabIt->filled = TRUE; ptr_pageTabIt->edited = FALSE; ptr_pageTabIt->count = 0; printf("页面替换成功\n"); }
void do_LRU_aging(Ptr_PageTableItem ptr_pageTabIt){ unsigned int i,j,page,popagenum; unsigned int popage[PAGE_SUM] = {0}; unsigned int Mincount = AgingCountBit+1; unsigned int Pagecount; printf("没有空闲物理块,开始进行老化算法页面替换...\n"); for (i = 0,page = 0,popagenum=0; i < PAGE_SUM ; i++){ Pagecount = 0; if (pageTable[i].filled && pageTable[i].LRU_flag ==0){ for(j=0;j<AgingCountBit;j++){ Pagecount += Aging_counter[pageTable[i].blockNum][j]; } if (Pagecount<Mincount) { popagenum = 0; popage[popagenum++] = i; Mincount = Pagecount; } else if(pageTable == Mincount){ popage[popagenum++] = i; } } } if(popagenum>0){ page = popage[random()%popagenum]; } else if (popagenum==0){ //没有找到未被使用的,随机选择一个 Mincount = AgingCountBit+1; for (i = 0; i < PAGE_SUM; i++){ if (pageTable[i].filled){ for(j=0;j<AgingCountBit;j++){ Pagecount += Aging_counter[pageTable[i].blockNum][j]; } if (Pagecount<Mincount){ popagenum = 0; popage[popagenum++] = i; Mincount = Pagecount; } else if(pageTable == Mincount){ popage[popagenum++] = i; } } } page = popage[random()%popagenum]; } //随机选择一个 printf("选择第%u页进行替换\n", page); //该页面对应的物理块修改了 if (pageTable[page].edited) { /* 页面内容有修改,需要写回至辅存 */ printf("该页内容有修改,写回至辅存\n"); do_page_out(&pageTable[page]); } pageTable[page].filled = FALSE; pageTable[page].LRU_flag = 0; /* 读辅存内容,写入到实存 */ do_page_in(ptr_pageTabIt, pageTable[page].blockNum); /* 更新页表内容 */ ptr_pageTabIt->blockNum = pageTable[page].blockNum; ptr_pageTabIt->filled = TRUE; ptr_pageTabIt->edited = FALSE; ptr_pageTabIt->LRU_flag = 0; printf("页面替换成功\n"); }
void scr_pa( void ) { char * pa; char * p; int len; char cwcurr[4]; cwcurr[0] = SCR_char; cwcurr[1] = 'p'; cwcurr[2] = 'a'; cwcurr[3] = '\0'; p = scan_start; while( *p && *p != ' ' ) { // over cw p++; } while( *p && *p == ' ' ) { // next word start p++; } pa = p; while( *p && *p != ' ' ) { // end of word p++; } len = p - pa; switch( len ) { case 7 : if( strnicmp( "NOSTART", pa, 7 ) ) { xx_opt_err( cwcurr, pa ); break; } /* fallthru for NOSTART */ case 0 : last_page_out(); // default action reset_t_page(); break; case 3 : if( !strnicmp( "ODD", pa, 3 ) ) { last_page_out(); reset_t_page(); if( (page & 1) ) { // next page would be even do_page_out(); reset_t_page(); } } else { xx_opt_err( cwcurr, pa ); } break; case 4 : if( !strnicmp( "EVEN", pa, 4 ) ) { last_page_out(); reset_t_page(); if( !(page & 1) ) { // next page would be odd do_page_out(); reset_t_page(); } } else { xx_opt_err( cwcurr, pa ); } break; default: xx_opt_err( cwcurr, pa ); break; } scan_restart = scan_stop +1; return; }
static void gml_hx_common( gml_tag gtag, int hx_lvl ) { char * p; char * headp; bool idseen; bool stitleseen; int rc; int k; size_t headlen; size_t txtlen; char hnumstr[64]; ref_entry * re; ref_entry * rwk; static char hxstr[4] = ":HX"; static char htextx[8] = "$htextX"; static char headx[7] = "$headX"; gtag = gtag; *(hxstr + 2) = '0' + hx_lvl; htextx[6] = '0' + hx_lvl; hnumx[5] = '0' + hx_lvl; headx[5] = '0' + hx_lvl; switch( hx_lvl ) { case 0: if( !((ProcFlags.doc_sect == doc_sect_body) || (ProcFlags.doc_sect_nxt == doc_sect_body)) ) { g_err( err_tag_wrong_sect, hxstr, ":BODY section" ); err_count++; file_mac_info(); } break; case 1: if( !((ProcFlags.doc_sect >= doc_sect_body) || (ProcFlags.doc_sect_nxt >= doc_sect_body)) ) { g_err( err_tag_wrong_sect, hxstr, ":BODY :APPENDIX :BACKM sections" ); err_count++; file_mac_info(); } break; default: if( !((ProcFlags.doc_sect >= doc_sect_abstract) || (ProcFlags.doc_sect_nxt >= doc_sect_abstract)) ) { g_err( err_tag_wrong_sect, hxstr, ":ABSTRACT section or later" ); err_count++; file_mac_info(); } break; } if( layout_work.hx[hx_lvl].number_form != num_none ) { layout_work.hx[hx_lvl].headn++; } idseen = false; stitleseen = false; p = scan_start; re = NULL; /***********************************************************************/ /* Scan attributes for :Hx */ /* id= */ /* stitle= */ /***********************************************************************/ for( ;; ) { while( *p == ' ' ) { p++; } if( *p == '\0' || *p == '.' ) { break; // tag end found } if( !strnicmp( "stitle=", p, 7 ) ) { p += 6; stitleseen = true; /***************************************************************/ /* Although unsupported scan stitle='xxx' */ /***************************************************************/ g_warn( wng_unsupp_att, "stitle" ); wng_count++; file_mac_info(); p = get_att_value( p ); scan_start = p; if( !ProcFlags.tag_end_found ) { continue; } break; } /*******************************************************************/ /* ID='xxxxxxxx' */ /*******************************************************************/ if( !strnicmp( "id=", p, 3 ) ) { p += 2; p = get_refid_value( p ); if( val_len > 0 ) { idseen = true; // valid id attribute found *(val_start + val_len) = '\0'; if( re == NULL ) { // prepare reference entry re = mem_alloc( sizeof( ref_entry ) ); init_ref_entry( re, val_start, val_len ); } else { fill_id( re, val_start, val_len ); } } scan_start = p; if( !ProcFlags.tag_end_found ) { continue; } break; } /*******************************************************************/ /* no more valid attributes, process remaining input as header text*/ /*******************************************************************/ break; } if( *p == '.' ) { // tag end ? p++; } /************************************************************************/ /* set the global vars $headx, $headnumx, $htextx */ /* perhaps text translated to upper or lower case */ /************************************************************************/ while( *p == ' ' ) { // ignore leading blanks p++; } if( *p ) { // text exists if( layout_work.hx[hx_lvl].cases == case_lower ) { strlwr( p ); } else if( layout_work.hx[hx_lvl].cases == case_upper ) { strupr( p ); } } rc = add_symvar( &global_dict, htextx, p, no_subscript, 0 ); update_headnumx( hx_lvl, hnumstr, sizeof( hnumstr ) ); txtlen = strlen( p ); headlen = strlen( hnumstr) + txtlen + 2; headp = mem_alloc( headlen ); if( layout_work.hx[hx_lvl].number_form != num_none ) { strcpy( headp, hnumstr); // numbered header strcat( headp, " " ); } else { *headp = '\0'; } strcat( headp, p ); rc = add_symvar( &global_dict, headx, headp, no_subscript, 0 ); out_msg( " %s\n", headp ); // always verbose output ? TBD mem_free( headp ); /***********************************************************************/ /* if id specified add it to reference dict */ /***********************************************************************/ if( idseen ) { rwk = find_refid( ref_dict, re->id ); if( !rwk ) { // new entry if( txtlen > 0 ) { // text line not empty re->u.info.text_cap = mem_alloc( txtlen + 1 ); strcpy( re->u.info.text_cap, p ); } add_ref_entry( &ref_dict, re ); re = NULL; // free will be done via dictionary } else { /***************************************************************/ /* test for duplicate id */ /* it is done with comparing line no only, in the hope that */ /* two identical ids are not specified in different files on */ /* the same line no. */ /***************************************************************/ if( re->lineno != rwk->lineno ) { g_err( wng_id_xxx, re->id ); g_info( inf_id_duplicate ); file_mac_info(); err_count++; } if( re->u.info.text_cap != NULL ) { mem_free( re->u.info.text_cap ); } mem_free( re ); } } if( layout_work.hx[hx_lvl].number_reset ) { for( k = hx_lvl + 1; k < 7; k++ ) { layout_work.hx[k].headn = 0;// reset following levels if( layout_work.hx[k].headnsub != NULL ) { *(layout_work.hx[k].headnsub->value) = '\0'; } } } /***********************************************************************/ /* creation of actual heading */ /***********************************************************************/ /***********************************************************************/ /* eject page(s) if specified */ /***********************************************************************/ if( layout_work.hx[hx_lvl].page_eject != ej_no ) { if( ProcFlags.page_started ) { do_page_out(); reset_t_page(); } if( !ProcFlags.start_section ) { start_doc_sect(); } set_headx_banners( hx_lvl ); // set possible banners reset_t_page(); // and adjust page margins if( (layout_work.hx[hx_lvl].page_eject == ej_odd) && (page & 1) ) { do_page_out(); // next page would be even reset_t_page(); } else if( (layout_work.hx[hx_lvl].page_eject == ej_even) && !(page & 1) ) { do_page_out(); // next page would be odd reset_t_page(); } } if( layout_work.hx[hx_lvl].display_heading ) { hx_header( hx_lvl, hnumstr, p ); } scan_start = scan_stop; return; }
void do_LRU(Ptr_PageTableItem ptr_pageTabIt) { unsigned int i,j,k,min,page,firstpage; int flag=0; int count[VIRTUAL_PROGRESSES][PAGE_SUM]={0}; int Whichprogress=0; for(k=0;k<VIRTUAL_PROGRESSES;k++) for(i=0;i<PAGE_SUM;i++) { for(j=0;j<8;j++) count[k][i]=count[k][i]*2+actmemcount[k][i][j]; //printf("%d\n",count[i]); } printf("没有空闲物理块,开始进行LRU页面替换...\n"); for(k=0;k<VIRTUAL_PROGRESSES;k++) for (i = 0, firstpage = 0, page = 0; i < LV1_PAGE_SUM; i++) { for (j = 0; j < LV2_PAGE_SUM; j++) { if (pageTable[k][i][j].filled) { Whichprogress=k; firstpage = i; page = j; flag=1; } break; } if(flag==1) { break; } } for(k=0;k<VIRTUAL_PROGRESSES;k++) for (i = 0, min = 0xFFFFFFFF; i < LV1_PAGE_SUM; i++) { for (j = 0; j < LV2_PAGE_SUM; j++) { if (count[k][i*LV1_PAGE_SUM+j] < min &&pageTable[k][i][j].filled) { Whichprogress=k; min = count[k][i*LV1_PAGE_SUM+j]; firstpage = i; page = j; } } } printf("选择第%u个进程页表的第%u页进行替换\n", k, firstpage * LV1_PAGE_SUM + page); if (pageTable[Whichprogress][firstpage][page].edited) { /* 页面内容有修改,需要写回至辅存 */ printf("该页内容有修改,写回至辅存\n"); do_page_out(&pageTable[Whichprogress][firstpage][page]); } for(i=0;i<8;i++) { actmemcount[Whichprogress][firstpage * LV1_PAGE_SUM + page][i]=0; } whichprogress[pageTable[Whichprogress][firstpage][page].blockNum]=ptr_memAccReq->FromProgress; pageTable[Whichprogress][firstpage][page].filled = FALSE; pageTable[Whichprogress][firstpage][page].count = 0; pageTable[Whichprogress][firstpage][page].blockNum = 0; /* 读辅存内容,写入到实存 */ do_page_in(ptr_pageTabIt, pageTable[Whichprogress][firstpage][page].blockNum); /* 更新页表内容 */ ptr_pageTabIt->blockNum = pageTable[Whichprogress][firstpage][page].blockNum; ptr_pageTabIt->filled = TRUE; ptr_pageTabIt->edited = FALSE; ptr_pageTabIt->count = 0; //ptr_pageTabIt->progressNum=ptr_memAccReq->FromProgress; printf("页面替换成功\n"); }
void last_page_out( void ) { full_page_out(); do_page_out(); // last page return; }
void start_doc_sect( void ) { bool first_section; bool header; bool page_r; doc_section ds; font_number font; spacing_line spacing_ln; page_ej page_e; su *p_sk; su *top_sk; uint32_t ind; xx_str *h_string; if( ProcFlags.start_section ) { return; // once is enough } if( !ProcFlags.fb_document_done ) { // the very first section/page do_layout_end_processing(); } first_section = (ProcFlags.doc_sect == doc_sect_none); header = false; // no header string (ABSTRACT, ... ) output page_r = false; // no page number reset page_e = ej_no; // no page eject ProcFlags.start_section = true; ProcFlags.keep_left_margin = false; ds = ProcFlags.doc_sect_nxt; // new section if( ds == doc_sect_none ) { ds = doc_sect_body; // if text without section start assume body } /***********************************************************************/ /* process special section attributes */ /***********************************************************************/ switch( ds ) { case doc_sect_body: page_r = layout_work.body.page_reset; page_e = layout_work.body.page_eject; if( layout_work.body.header ) { header = true; h_string = layout_work.body.string; top_sk = &layout_work.body.pre_top_skip; p_sk = &layout_work.body.post_skip; font = layout_work.body.font; spacing_ln = g_spacing_ln; // standard spacing } break; case doc_sect_titlep: // for preceding :BINCLUDE/:GRAPHIC page_e = ej_yes; init_nest_cb( true ); nest_cb->gtag = t_TITLEP; nest_cb->p_stack->lineno = titlep_lineno; // correct line number break; case doc_sect_abstract: page_r = layout_work.abstract.page_reset; page_e = layout_work.abstract.page_eject; if( layout_work.abstract.header ) { header = true; h_string = layout_work.abstract.string; top_sk = &layout_work.abstract.pre_top_skip; p_sk = &layout_work.abstract.post_skip; font = layout_work.abstract.font; spacing_ln = layout_work.abstract.spacing; } break; case doc_sect_preface: page_r = layout_work.preface.page_reset; page_e = layout_work.preface.page_eject; if( layout_work.preface.header ) { header = true; h_string = layout_work.preface.string; top_sk = &layout_work.preface.pre_top_skip; p_sk = &layout_work.preface.post_skip; font = layout_work.preface.font; spacing_ln = layout_work.preface.spacing; } break; case doc_sect_appendix: page_r = layout_work.appendix.page_reset; page_e = layout_work.appendix.page_eject; if( layout_work.appendix.header ) { header = true; h_string = layout_work.appendix.string; top_sk = &layout_work.appendix.pre_top_skip; p_sk = &layout_work.appendix.post_skip; font = layout_work.appendix.font; spacing_ln = layout_work.appendix.spacing; } break; case doc_sect_backm: page_r = layout_work.backm.page_reset; page_e = layout_work.backm.page_eject; if( layout_work.backm.header ) { header = true; h_string = layout_work.backm.string; top_sk = &layout_work.backm.pre_top_skip; p_sk = &layout_work.backm.post_skip; font = layout_work.backm.font; spacing_ln = g_spacing_ln; // standard spacing } break; case doc_sect_index: page_r = layout_work.index.page_reset; page_e = layout_work.index.page_eject; if( layout_work.index.header ) { header = true; h_string = layout_work.index.index_string; top_sk = &layout_work.index.pre_top_skip; p_sk = &layout_work.index.post_skip; font = layout_work.index.font; spacing_ln = layout_work.index.spacing; } break; default: new_section( ds ); break; } if( first_section ) { // nothing precedes the first section if( page_e == ej_even ) { do_page_out(); // apage of first page is odd page = 0; // restart page for first text page } new_section( ds ); reset_t_page(); document_new_position(); // first text page ready for content } else { full_page_out(); // ensure are on last page switch( page_e ) { // page eject requested case ej_yes : finish_page_section( ds, true );// emit last page in old section if( page_r ) { page = 0; } reset_t_page(); break; case ej_odd : if( !(apage & 1) ) { // first page would be even do_page_out(); // emit last page in old section reset_t_page(); } finish_page_section( ds, true );// emit last page in old section if( page_r ) { page = 0; } reset_t_page(); break; case ej_even : if( (apage & 1) ) { // first page will be odd do_page_out(); // emit last page in old section reset_t_page(); } finish_page_section( ds, true );// emit last page in old section if( page_r ) { page = 0; } reset_t_page(); break; default: // ej_no new_section( ds ); /****************************************************/ /* set page bottom banner/limit for new section */ /****************************************************/ ind = !(page & 1); t_page.bottom_banner = sect_ban_bot[ind]; if( sect_ban_bot[ind] != NULL ) { if( bin_driver->y_positive == 0 ) { g_page_bottom = g_page_bottom_org + sect_ban_bot[ind]->ban_depth; } else { g_page_bottom = g_page_bottom_org - sect_ban_bot[ind]->ban_depth; } } else { g_page_bottom = g_page_bottom_org; } break; } } g_cur_left = g_page_left_org; g_cur_h_start = g_page_left_org + g_indent; if( header ) { doc_header( p_sk, top_sk, h_string, font, spacing_ln, page_e == ej_no ); } ProcFlags.doc_sect = ds; }
void start_doc_sect( void ) { bool first_section; bool header; bool page_r; char * h_text; doc_section ds; hdsrc hds_lvl; int k; page_ej page_e; uint32_t page_c; uint32_t page_s; if( ProcFlags.start_section ) { return; // once is enough } if( !ProcFlags.fb_document_done ) { // the very first section/page do_layout_end_processing(); } scr_process_break(); // commit any prior text first_section = (ProcFlags.doc_sect == doc_sect_none); ProcFlags.start_section = true; ProcFlags.keep_left_margin = false; page_c = layout_work.defaults.columns; ds = ProcFlags.doc_sect_nxt; // new section if( ds == doc_sect_none ) { ds = doc_sect_body; // if text without section start assume body } /***********************************************************************/ /* process special section attributes */ /***********************************************************************/ switch( ds ) { case doc_sect_titlep : page_c = layout_work.titlep.columns; page_e = ej_yes; page_r = false; // no page number reset header = false; // no header string (ABSTRACT, ... ) output init_nest_cb(); nest_cb->p_stack = copy_to_nest_stack(); nest_cb->c_tag = t_TITLEP; nest_cb->p_stack->lineno = titlep_lineno; // correct line number break; case doc_sect_abstract : page_c = layout_work.abstract.columns; page_e = layout_work.abstract.page_eject; page_r = layout_work.abstract.page_reset; page_s = layout_work.hx.hx_sect[hds_abstract].spacing; header = layout_work.hx.hx_sect[hds_abstract].header; if( header ) { h_text = &layout_work.abstract.string; hds_lvl = hds_abstract; } break; case doc_sect_preface : page_c = layout_work.preface.columns; page_e = layout_work.preface.page_eject; page_r = layout_work.preface.page_reset; page_s = layout_work.hx.hx_sect[hds_preface].spacing; header = layout_work.hx.hx_sect[hds_preface].header; if( header ) { h_text = &layout_work.preface.string; hds_lvl = hds_preface; } break; case doc_sect_body : page_c = layout_work.body.columns; page_e = layout_work.body.page_eject; page_r = layout_work.body.page_reset; page_s = layout_work.hx.hx_sect[hds_body].spacing; header = layout_work.hx.hx_sect[hds_body].header; if( header ) { h_text = &layout_work.body.string; hds_lvl = hds_body; } break; case doc_sect_appendix : page_c = layout_work.appendix.columns; page_e = layout_work.appendix.section_eject; page_r = layout_work.appendix.page_reset; page_s = layout_work.hx.hx_sect[hds_appendix].spacing; header = false; // no section header string output, as such if( page_e != ej_no ) { page_e = ej_yes; // "even" and "odd" act like "yes" } for( k = 1; k < hds_appendix; k++ ) { // reset heading levels hd_nums[k].headn = 0; if( hd_nums[k].headnsub != NULL ) { *(hd_nums[k].headnsub->value) = '\0'; } } break; case doc_sect_backm : page_c = layout_work.backm.columns; page_e = layout_work.backm.page_eject; page_r = layout_work.backm.page_reset; page_s = layout_work.hx.hx_sect[hds_backm].spacing; header = layout_work.hx.hx_sect[hds_backm].header; if( header ) { h_text = &layout_work.backm.string; hds_lvl = hds_backm; } break; case doc_sect_index : page_c = layout_work.index.columns; page_e = layout_work.index.page_eject; page_r = layout_work.index.page_reset; page_s = layout_work.hx.hx_sect[hds_index].spacing; header = layout_work.hx.hx_sect[hds_index].header; if( header ) { h_text = &layout_work.index.index_string; hds_lvl = hds_index; } break; case doc_sect_gdoc : case doc_sect_etitlep : case doc_sect_frontm : page_c = layout_work.defaults.columns; page_e = ej_no; // no page eject page_r = false; // no page number reset page_s = layout_work.defaults.spacing; // default spacing header = false; // no section header break; case doc_sect_egdoc : page_c = layout_work.defaults.columns; page_e = ej_yes; page_r = false; // no page number reset page_s = layout_work.defaults.spacing; // default spacing header = false; // no section header break; default: internal_err( __FILE__, __LINE__ ); break; } if( first_section ) { // nothing precedes the first section if( page_e == ej_even ) { do_page_out(); // apage of first page is odd page = 0; // restart page for first text page ProcFlags.page_ejected = true; } set_section_banners( ds ); reset_t_page(); document_new_position(); // first text page ready for content } else if( page_e == ej_no ) { full_page_out(); // ensure are on last page ProcFlags.page_ejected = false; set_section_banners( ds ); reset_bot_ban(); } else { last_page_out(); // ensure last page output ProcFlags.page_ejected = true; // only first section has nothing to output if( page_e == ej_odd ) { if( (page & 1) ) { // first page will be odd do_page_out(); // emit blank page } } else if( page_e == ej_even ) { if( !(page & 1) ) { // first page will be even do_page_out(); // emit blank page } } else if( page_e != ej_yes ) { internal_err( __FILE__, __LINE__ ); } g_skip = 0; // ignore remaining skip value set_section_banners( ds ); reset_t_page(); } ProcFlags.doc_sect = ds; t_page.col_count = page_c; set_cols(); if( page_r ) { page = 0; } spacing = page_s; g_cur_left = g_page_left_org; if( header ) { line_position = pos_center; concat_save = ProcFlags.concat; ProcFlags.concat = true; justify_save = ProcFlags.justify; ProcFlags.justify = ju_off; gen_heading( h_text, NULL, 0, hds_lvl ); g_indent = 0; // reset for section body ProcFlags.concat = concat_save; ProcFlags.justify = justify_save; } g_curr_font = layout_work.defaults.font; g_cur_h_start = g_page_left_org + g_indent; ProcFlags.doc_sect = ds; }