Implement pool quota accounting and stub raise functionality
This commit is contained in:
@@ -55,6 +55,9 @@
|
|||||||
/* Protection field shift */
|
/* Protection field shift */
|
||||||
#define MM_PROTECT_FIELD_SHIFT 5
|
#define MM_PROTECT_FIELD_SHIFT 5
|
||||||
|
|
||||||
|
/* Process Quota Adjustment Thresholds */
|
||||||
|
#define MMNONPAGED_QUOTA_INCREASE (64*1024)
|
||||||
|
#define MMPAGED_QUOTA_INCREASE (512*1024)
|
||||||
|
|
||||||
/* C/C++ specific code */
|
/* C/C++ specific code */
|
||||||
#ifndef __XTOS_ASSEMBLER__
|
#ifndef __XTOS_ASSEMBLER__
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ list(APPEND XTOSKRNL_SOURCE
|
|||||||
${XTOSKRNL_SOURCE_DIR}/mm/pfn.cc
|
${XTOSKRNL_SOURCE_DIR}/mm/pfn.cc
|
||||||
${XTOSKRNL_SOURCE_DIR}/mm/pool.cc
|
${XTOSKRNL_SOURCE_DIR}/mm/pool.cc
|
||||||
${XTOSKRNL_SOURCE_DIR}/mm/pte.cc
|
${XTOSKRNL_SOURCE_DIR}/mm/pte.cc
|
||||||
|
${XTOSKRNL_SOURCE_DIR}/mm/quota.cc
|
||||||
${XTOSKRNL_SOURCE_DIR}/po/idle.cc
|
${XTOSKRNL_SOURCE_DIR}/po/idle.cc
|
||||||
${XTOSKRNL_SOURCE_DIR}/ps/process.cc
|
${XTOSKRNL_SOURCE_DIR}/ps/process.cc
|
||||||
${XTOSKRNL_SOURCE_DIR}/ps/thread.cc
|
${XTOSKRNL_SOURCE_DIR}/ps/thread.cc
|
||||||
|
|||||||
@@ -24,5 +24,6 @@
|
|||||||
#include <mm/pfault.hh>
|
#include <mm/pfault.hh>
|
||||||
#include <mm/pfn.hh>
|
#include <mm/pfn.hh>
|
||||||
#include <mm/pool.hh>
|
#include <mm/pool.hh>
|
||||||
|
#include <mm/quota.hh>
|
||||||
|
|
||||||
#endif /* __XTOSKRNL_MM_HH */
|
#endif /* __XTOSKRNL_MM_HH */
|
||||||
|
|||||||
33
xtoskrnl/includes/mm/quota.hh
Normal file
33
xtoskrnl/includes/mm/quota.hh
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* PROJECT: ExectOS
|
||||||
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
|
* FILE: xtoskrnl/includes/mm/quota.hh
|
||||||
|
* DESCRIPTION: Memory Manager Quota support
|
||||||
|
* DEVELOPERS: Aiken Harris <harraiken91@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __XTOSKRNL_MM_QUOTA_HH
|
||||||
|
#define __XTOSKRNL_MM_QUOTA_HH
|
||||||
|
|
||||||
|
#include <xtos.hh>
|
||||||
|
|
||||||
|
|
||||||
|
/* Memory Manager */
|
||||||
|
namespace MM
|
||||||
|
{
|
||||||
|
class Quota
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
STATIC SIZE_T PagedPoolQuota;
|
||||||
|
STATIC SIZE_T NonPagedPoolQuota;
|
||||||
|
|
||||||
|
public:
|
||||||
|
STATIC XTAPI BOOLEAN RaisePoolQuota(IN MMPOOL_TYPE PoolType,
|
||||||
|
IN SIZE_T CurrentQuotaLimit,
|
||||||
|
OUT PSIZE_T NewQuotaLimit);
|
||||||
|
STATIC XTAPI VOID ReturnPoolQuota(IN MMPOOL_TYPE PoolType,
|
||||||
|
IN SIZE_T ReturnedQuota);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* __XTOSKRNL_MM_QUOTA_HH */
|
||||||
69
xtoskrnl/mm/quota.cc
Normal file
69
xtoskrnl/mm/quota.cc
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/**
|
||||||
|
* PROJECT: ExectOS
|
||||||
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
|
* FILE: xtoskrnl/mm/quota.cc
|
||||||
|
* DESCRIPTION: Memory Manager Quota support
|
||||||
|
* DEVELOPERS: Aiken Harris <harraiken91@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <xtos.hh>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to increase the pool quota limit.
|
||||||
|
*
|
||||||
|
* @param PoolType
|
||||||
|
* Supplies the type of memory pool whose quota limit is being evaluated for an increase.
|
||||||
|
*
|
||||||
|
* @param CurrentQuotaLimit
|
||||||
|
* Supplies the current quota limit, in bytes, for the requested pool.
|
||||||
|
*
|
||||||
|
* @param NewQuotaLimit
|
||||||
|
* Receives the newly established quota limit if the increase was successful.
|
||||||
|
*
|
||||||
|
* @return This routine returns TRUE if the quota limit was successfully raised, or FALSE otherwise.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTAPI
|
||||||
|
BOOLEAN
|
||||||
|
MM::Quota::RaisePoolQuota(IN MMPOOL_TYPE PoolType,
|
||||||
|
IN SIZE_T CurrentQuotaLimit,
|
||||||
|
OUT PSIZE_T NewQuotaLimit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a specified amount of quota back to the global system pool.
|
||||||
|
*
|
||||||
|
* @param PoolType
|
||||||
|
* Supplies the type of memory pool receiving the returned quota.
|
||||||
|
*
|
||||||
|
* @param ReturnedQuota
|
||||||
|
* Supplies the amount of quota, in bytes, being returned to the system.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTAPI
|
||||||
|
VOID
|
||||||
|
MM::Quota::ReturnPoolQuota(IN MMPOOL_TYPE PoolType,
|
||||||
|
IN SIZE_T ReturnedQuota)
|
||||||
|
{
|
||||||
|
/* Route the returned quota to the appropriate pool */
|
||||||
|
switch(PoolType)
|
||||||
|
{
|
||||||
|
case PagedPool:
|
||||||
|
/* Return quota to the paged pool */
|
||||||
|
PagedPoolQuota -= ReturnedQuota;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* Return quota to the non-paged pool */
|
||||||
|
NonPagedPoolQuota -= ReturnedQuota;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user