⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 objectcache.hxx

📁 C++ 编写的EROS RTOS
💻 HXX
字号:
#ifndef __OBJECTCACHE_HXX__#define __OBJECTCACHE_HXX__/* * Copyright (C) 1998, 1999, Jonathan S. Shapiro. * * This file is part of the EROS Operating System. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2, * or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#include "ObjectHeader.hxx"class VCPU;struct Depend;struct ObjectSource;struct PmemInfo;class ObjectCache {  static uint32_t nNodes;  static Node *nodeTable;  static uint32_t nPages;  static ObjectHeader *coreTable;  static uint32_t nFreeNodeFrames;  static uint32_t nFreePageFrames;  static uint32_t nReservedIoPageFrames;  static uint32_t nCommittedIoPageFrames;    static Node *firstFreeNode;  static ObjectHeader *firstFreePage;  static void AllocateUserPages();public:  /* Initialization */  static void Init();  /* Page management: */  static ObjectHeader *PhysPageToObHdr(kpa_t pagepa);  static kva_t ObHdrToPage(const ObjectHeader *pHdr)    {      return pHdr->pageAddr;    }  static ObjectHeader *OIDtoObHdr(uint32_t oidLo, uint16_t oidHi);      static void AgeNodeFrames();  static void WaitForAvailableNodeFrame();  static void RequireNodeFrames(uint32_t n);  static Node *GrabNodeFrame();  static void AgePageFrames();  static void WaitForAvailablePageFrame();  static ObjectHeader *GrabPageFrame();  static bool GrabThisFrame(ObjectHeader *);  static void AddDevicePages(PmemInfo *);public:  static uint32_t TotalPages()  {    return nPages;  }  static uint32_t TotalNodes()  {    return nNodes;  }  #if 0  /* For an explanation of why this particular set of calls is needed,   * see kern_Persist.cxx   */  static void ReserveIoPageFrame()  {    WaitForAvailablePageFrame();    nReservedIoPageFrames++;  }  static void CommitIoPageFrame()  {    nCommittedIoPageFrames = nReservedIoPageFrames;  }  static void ReleaseUncommittedIoPageFrames()  {    nReservedIoPageFrames = nCommittedIoPageFrames;  }    static void RequirePageFrames(uint32_t n);  static ObjectHeader *IoCommitGrabPageFrame();	/* must be prompt! */#endif  /* This is used for copy on write processing, and also for frame   * eviction. The copy becomes current, and is initially clean. The   * original is no longer current, but may still be the checkpoint   * version. */  static ObjectHeader *ObjectCache::CopyObject(ObjectHeader *pObj);  /* Evict the current resident of the node/page frame. This is called   * when we need to claim a particular object frame in the object   * cache. It is satisfactory to accomplish this by grabbing some   * other frame and moving the object to it.    */  static bool EvictFrame(ObjectHeader *pObj);  /* Clean out the node/page frame, but do not remove it from memory. */  static bool CleanFrame(ObjectHeader *pObj, bool invalidateProducts = true);  /* Releases node/page frame to free list */  static void ReleaseFrame(ObjectHeader *);  static Node *ContainingNode(void *);  /* For use by the consistency checker: */  static uint32_t NumCorePageFrames()  {    return nPages;  }  static uint32_t NumCoreNodeFrames()  {    return nNodes;  }    /* FIX: These need to be replaced when we go to the more flexible   * core allocator, but for now they are still needed.   */  static ObjectHeader *GetCorePageFrame(uint32_t ndx);  static Node *GetCoreNodeFrame(uint32_t ndx);#ifdef USES_MAPPING_PAGES  static void ReleaseMappingFrame(ObjectHeader *pObj);#endif#ifndef NDEBUG  static bool ValidNodePtr(const Node *pNode);  static bool ValidPagePtr(const ObjectHeader *pObj);  static bool ValidKeyPtr(const struct Key *pKey);#endif#ifdef OPTION_DDB  static void ddb_dump_pinned_objects();  static void ddb_dump_pages();  static void ddb_dump_nodes();#endif  /*************************************************************   *   * Interaction with ObjectSource(s):   *   *************************************************************/  static bool AddSource(ObjectSource *);  static bool HaveSource(OID oid);  static void WaitForSource();  static bool DetachSource(ObjectSource *);#ifdef OPTION_DDB  static void ddb_DumpSources();#endif  static void InitObjectSources();  static ObjectHeader *  GetObject(OID oid, ObType::Type obType, ObCount count, bool useCount);  /* Return true if object can be removed from the object cache. */  static bool IsRemovable(ObjectHeader *);    /* Write a page to backing store. Note that the "responsible"   * ObjectSource can refuse, in which case the page will not be   * cleanable and will stay in memory. WritePage() is free to yield.   *   * Returns true on success.   */  static bool WriteBack(ObjectHeader *, bool inBackground = false);    /* Unconditionally remove an object from the object cache.    *   * Returns true on success.   */  static bool Invalidate(ObjectHeader *);    static void FindFirstSubrange(OID start, OID end, 				OID& subStart, OID& subEnd);};#endif /* __OBJECTCACHE_HXX__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -