FreeNOS
Data Structures | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
ProcessShares Class Reference

Manages memory shares for a Process. More...

#include <ProcessShares.h>

Data Structures

struct  MemoryShare
 

Public Types

enum  Result {
  Success, InvalidArgument, MemoryMapError, OutOfMemory,
  AlreadyExists, DetachInProgress, NotFound
}
 

Public Member Functions

 ProcessShares (ProcessID pid)
 Constructor. More...
 
virtual ~ProcessShares ()
 Destructor function. More...
 
const ProcessID getProcessID () const
 Get process. More...
 
MemoryContextgetMemoryContext ()
 Get MemoryContext object. More...
 
Result setMemoryContext (MemoryContext *context)
 Set MemoryContext. More...
 
Result createShare (ProcessShares &instance, MemoryShare *share)
 
Result createShare (ProcessID pid, Size coreId, Size tagId, Address virt, Size size)
 Create memory share. More...
 
Result readShare (MemoryShare *share)
 Read memory share by Process, Core and Tag IDs. More...
 
Result removeShares (ProcessID pid)
 Remove all shares for the given ProcessID. More...
 

Private Member Functions

Result releaseShare (MemoryShare *share, Size idx)
 Release one memory share. More...
 
MemorySharefindShare (const ProcessID pid, const Size coreId, const Size tagId)
 Retrieve MemoryShare object. More...
 

Private Attributes

ProcessID m_pid
 ProcessID associated to these shares. More...
 
MemoryContextm_memory
 MemoryContext instance. More...
 
Index< MemoryShare, MaximumMemorySharesm_shares
 Contains all memory shares. More...
 

Static Private Attributes

static const Size MaximumMemoryShares = 32u
 Maximum number of memory shares that a single process can have. More...
 

Detailed Description

Manages memory shares for a Process.

Definition at line 39 of file ProcessShares.h.

Member Enumeration Documentation

◆ Result

Enumerator
Success 
InvalidArgument 
MemoryMapError 
OutOfMemory 
AlreadyExists 
DetachInProgress 
NotFound 

Definition at line 66 of file ProcessShares.h.

Constructor & Destructor Documentation

◆ ProcessShares()

ProcessShares::ProcessShares ( ProcessID  pid)

Constructor.

Definition at line 27 of file ProcessShares.cpp.

References m_memory, m_pid, and ZERO.

◆ ~ProcessShares()

ProcessShares::~ProcessShares ( )
virtual

Member Function Documentation

◆ createShare() [1/2]

ProcessShares::Result ProcessShares::createShare ( ProcessID  pid,
Size  coreId,
Size  tagId,
Address  virt,
Size  size 
)

◆ createShare() [2/2]

ProcessShares::Result ProcessShares::createShare ( ProcessShares instance,
ProcessShares::MemoryShare share 
)

◆ findShare()

ProcessShares::MemoryShare * ProcessShares::findShare ( const ProcessID  pid,
const Size  coreId,
const Size  tagId 
)
private

Retrieve MemoryShare object.

Parameters
pidProcessID value to match
coreIdCoreID value to match
tagIdTagID value to match
Returns
MemoryShare pointer if found or ZERO if not

Definition at line 334 of file ProcessShares.cpp.

References assert, ProcessShares::MemoryShare::coreId, coreId, CoreInfo::coreId, coreInfo, m_shares, ProcessShares::MemoryShare::pid, ProcessShares::MemoryShare::tagId, and ZERO.

Referenced by createShare(), and readShare().

◆ getMemoryContext()

MemoryContext * ProcessShares::getMemoryContext ( )

Get MemoryContext object.

Returns
MemoryContext object pointer.

Definition at line 73 of file ProcessShares.cpp.

References m_memory.

Referenced by createShare().

◆ getProcessID()

const ProcessID ProcessShares::getProcessID ( ) const

Get process.

Definition at line 68 of file ProcessShares.cpp.

References m_pid.

Referenced by createShare().

◆ readShare()

ProcessShares::Result ProcessShares::readShare ( MemoryShare share)

Read memory share by Process, Core and Tag IDs.

Parameters
shareMemoryShare buffer (input/output).
Returns
Result code.

Definition at line 358 of file ProcessShares.cpp.

References MemoryBlock::copy(), ProcessShares::MemoryShare::coreId, findShare(), NotFound, ProcessShares::MemoryShare::pid, Success, ProcessShares::MemoryShare::tagId, and ZERO.

Referenced by VMShareHandler().

◆ releaseShare()

ProcessShares::Result ProcessShares::releaseShare ( MemoryShare share,
Size  idx 
)
private

◆ removeShares()

ProcessShares::Result ProcessShares::removeShares ( ProcessID  pid)

Remove all shares for the given ProcessID.

Parameters
pidProcessID to remove all shares for
Returns
Result code

Definition at line 254 of file ProcessShares.cpp.

References m_shares, ProcessShares::MemoryShare::pid, releaseShare(), Success, and ZERO.

Referenced by VMShareHandler().

◆ setMemoryContext()

ProcessShares::Result ProcessShares::setMemoryContext ( MemoryContext context)

Set MemoryContext.

Parameters
contextMemoryContext object
Returns
Result code.

Definition at line 78 of file ProcessShares.cpp.

References m_memory, and Success.

Referenced by Process::initialize().

Field Documentation

◆ m_memory

MemoryContext* ProcessShares::m_memory
private

◆ m_pid

ProcessID ProcessShares::m_pid
private

ProcessID associated to these shares.

Definition at line 177 of file ProcessShares.h.

Referenced by createShare(), getProcessID(), ProcessShares(), releaseShare(), and ~ProcessShares().

◆ m_shares

Index<MemoryShare, MaximumMemoryShares> ProcessShares::m_shares
private

Contains all memory shares.

Definition at line 183 of file ProcessShares.h.

Referenced by createShare(), findShare(), releaseShare(), removeShares(), and ~ProcessShares().

◆ MaximumMemoryShares

const Size ProcessShares::MaximumMemoryShares = 32u
staticprivate

Maximum number of memory shares that a single process can have.

Definition at line 44 of file ProcessShares.h.


The documentation for this class was generated from the following files: