Implement pool quota accounting and stub raise functionality
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 33s
Builds / ExectOS (amd64, release) (push) Successful in 31s
Builds / ExectOS (i686, debug) (push) Successful in 41s
Builds / ExectOS (i686, release) (push) Successful in 39s

This commit is contained in:
2026-06-21 01:45:37 +02:00
parent c45b81d345
commit 7526f90759
5 changed files with 107 additions and 0 deletions

View File

@@ -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__

View File

@@ -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

View File

@@ -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 */

View 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
View 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;
}
}