当前位置: 首页>>代码示例>>C++>>正文


C++ Page::Wire方法代码示例

本文整理汇总了C++中Page::Wire方法的典型用法代码示例。如果您正苦于以下问题:C++ Page::Wire方法的具体用法?C++ Page::Wire怎么用?C++ Page::Wire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Page的用法示例。


在下文中一共展示了Page::Wire方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateArea

Area* AddressSpace::CreateArea(const char name[], unsigned int size, AreaWiring wiring,
	PageProtection protection, PageCache *cache, off_t offset, unsigned int va,
	int flags)
{
	if (size % PAGE_SIZE != 0 || size == 0)
		return 0;

	if (cache != 0 && cache->Commit(offset + size) != offset + size)
		return 0;

	fAreaLock.LockWrite();
	if (va == INVALID_PAGE)
		va = FindFreeRange(size, flags);
	else if (va % PAGE_SIZE != 0 || !fAreas.IsRangeFree(va, va + size - 1))
		va = INVALID_PAGE;

	Area *area = 0;
	if (va != INVALID_PAGE) {
		area = new Area(name, protection, cache, offset, wiring);
		fAreas.Add(area, va, va + size - 1);
		if (wiring & AREA_WIRED) {
			for (unsigned int aroffs = 0; aroffs < size; aroffs += PAGE_SIZE) {
				Page *page = area->GetPageCache()->GetPage(area->GetCacheOffset()
					+ aroffs, false);
				page->Wire();
				fPhysicalMap->Map(va + aroffs, page->GetPhysicalAddress(), protection);
			}
		}
	}

	fChangeCount++;
	fAreaLock.UnlockWrite();
	return area;
}
开发者ID:FFalcon,项目名称:jbushOS,代码行数:34,代码来源:AddressSpace.cpp

示例2: ResizeArea

status_t AddressSpace::ResizeArea(Area *area, unsigned int newSize)
{
	if (newSize == 0)
		return E_INVALID_OPERATION;

	fAreaLock.LockWrite();
	if (newSize > area->GetSize()) {
		// Grow the area.
		if (area->GetPageCache()->Commit(newSize) != newSize) {
			fAreaLock.UnlockWrite();
			return E_NO_MEMORY;
		}

		if (area->GetBaseAddress() + newSize < area->GetBaseAddress()	// wrap
			|| !fAreas.IsRangeFree(area->GetBaseAddress() + area->GetSize(),
			area->GetBaseAddress() + newSize))	{
			fAreaLock.UnlockWrite();
			return E_NO_MEMORY;
		}

		if (area->GetWiring() == AREA_WIRED) {
			for (unsigned int aroffs = area->GetSize(); aroffs < newSize;
				aroffs += PAGE_SIZE) {
				Page *page = area->GetPageCache()->GetPage(area->GetCacheOffset()
					+ aroffs, false);
				page->Wire();
				fPhysicalMap->Map(area->GetBaseAddress() + aroffs, page->GetPhysicalAddress(),
					area->GetProtection());
			}
		}
	} else if (newSize < area->GetSize()) {
		// Shrink the area.
		fPhysicalMap->Unmap(area->GetBaseAddress() + newSize, area->GetSize() - newSize);
		area->GetPageCache()->Commit(newSize);
	}

	fAreas.Resize(area, newSize);
	fChangeCount++;
	fAreaLock.UnlockWrite();
	return E_NO_ERROR;
}
开发者ID:FFalcon,项目名称:jbushOS,代码行数:41,代码来源:AddressSpace.cpp


注:本文中的Page::Wire方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。