예제 #1
0
/*
 *@function: remove several number of page tables
 *@param pd_entry: list which record entry num of page direcotry , these entries point to page table will be removed 
 */
bool NormalPaging::remove_page_table(entry_list pd_entry)
{
	for( entry_list_ptr it=pd_entry.begin(); it!=pd_entry.end();it++ )
	{
		assert( *it < ENTRY_1024 );
		remove_page_table(*it);
	}
	return true;
}
예제 #2
0
/*
 *@function: allocate page tables
 *@param pd_entry: entry id of page directory 
 */
bool NormalPaging::allocate_page_table(entry_list pd_entry)
{
	for( entry_list_ptr it=pd_entry.begin() ;it!=pd_entry.end(); it++)
	{
		if( !allocate_one_pagetable(*it) )
			return false;
	}
	return true;
}
예제 #3
0
bool LongModePaging::remove_page_directory_pointer(entry_list pml4_entry )
{
	bool succeed = true;
	for( entry_list_ptr it=pml4_entry.begin();it!=pml4_entry.end();it++)
	{
		if( remove_page_directory_pointer(*it))
			succeed = false;
	}
	return succeed;
}
예제 #4
0
bool LongModePaging::allocate_page_directory_pointer(entry_list pml4_entry)
{
	bool succeed = true;
	for( entry_list_ptr it=pml4_entry.begin(); it!=pml4_entry.end();it++)
	{
		if( allocate_page_directory_pointer(*it)==false)
		{
			succeed = false;
			debug_printf("allocate page directory pointer for entry %d of pml4 table failed",*it);
		}
	}
	return succeed;
}
예제 #5
0
/*
 *@function: allocate page directory table according to input
 *%attention: number of page directory must no more than 4
 *@param pdpt_entry: list of page directory pointer entry id
 */
bool PAEPaging::allocate_pdt(entry_list pdpt_entry)
{
	bool succeed = true;
	for( entry_list_ptr it=pdpt_entry.begin() ; it!=pdpt_entry.end() ; it++)
	{
		if( !(allocate_pdt(*it)))
		{
			succeed = false;
			debug_printf("allocate page directory for %d entry of page directory pointer failed",*it);
		}
	 }
	return succeed;
}
예제 #6
0
/*
 *@function:
 *@param pdpt_entry:
 */
bool PAEPaging::remove_pdt( entry_list pdpt_entry)
{
	bool succeed = true;
	for( entry_list_ptr it=pdpt_entry.begin(); 
		 it!= pdpt_entry.end();it++ )
	{
		if( remove_pdt(*it)==false)
		{
			debug_printf("remove page directory pointed by entry %d of page directory pointer failed", *it);
			succeed = false;
		}
	}
	return succeed;
}
예제 #7
0
void tx_watch::do_display()
{
    // Sort entries by count. Highest numbers at the top.
    std::sort(entries_.begin(), entries_.end(),
        [](const entry_count& entry_a, const entry_count& entry_b)
        {
            return entry_a.count > entry_b.count;
        });
    // Display the first 20 entries.
    for (size_t i = 0; i < 20 && i < entries_.size(); ++i)
    {
        const entry_count& entry = entries_[i];
        log_info() << entry.tx_hash << " " << entry.count;
    }
}
예제 #8
0
void tx_watch::do_cleanup()
{
    // Erase entries where timest is older than (now - timeout_) seconds.
    time_t current_time = time(nullptr);
    auto erase_pred =
        [&](const entry_count& entry)
        {
            return (current_time - entry.timest) > timeout_;
        };
    auto erase_begin =
        std::remove_if(entries_.begin(), entries_.end(), erase_pred);
    // If we have old entries to delete then erase them.
    if (erase_begin != entries_.end())
        entries_.erase(erase_begin);
}
예제 #9
0
void tx_watch::do_push(const hash_digest& tx_hash)
{
    // If tx_hash is found then increment count...
    bool is_found = false;
    for (entry_count& entry: entries_)
        if (entry.tx_hash == tx_hash)
        {
            ++entry.count;
            is_found = true;
        }
    // Else create a new entry with a count of 1.
    if (!is_found)
        entries_.push_back({tx_hash, 1, time(nullptr)});
}