20 #ifndef MANAGEDFILESWAP_H
21 #define MANAGEDFILESWAP_H
30 #include <unordered_map>
31 #include <sys/types.h>
36 class managedFileSwap_Unit_SwapAllocation_Test;
37 class managedFileSwap_Integration_RandomAccess_Test;
38 class managedFileSwap_Integration_RandomAccessVariousSize_Test;
39 class managedFileSwap_Unit_SwapPolicy_Test;
122 void setDMA (
bool arg1 );
124 virtual void close();
208 std::unordered_map<struct iocb *, pageFileLocation *>
pendingAios;
212 static void sigStat (
int signum );
240 friend class ::managedFileSwap_Unit_SwapAllocation_Test;
241 friend class ::managedFileSwap_Integration_RandomAccess_Test;
242 friend class ::managedFileSwap_Integration_RandomAccessVariousSize_Test;
243 friend class ::managedFileSwap_Unit_SwapPolicy_Test;
void scheduleCopy(rambrain::pageFileLocation &ref, void *ramBuf, int *tracker, bool reverse=false)
Schedules an elementary pageFileLocation chunk for copying (in or out)
pthread_t io_waiter_thread
void completeTransactionOn(rambrain::pageFileLocation *ref, bool lock=true)
called to finish a transaction when all pending aio on a managedMemoryChunk has completed ...
const unsigned int pageSize
virtual void invalidateCacheFor(managedMemoryChunk &chunk)
tells managedFileSwap that the chunk under consideration might have been changed by user and needs to...
bool cleanupCachedElements(rambrain::global_bytesize minimum_size=0)
throws out cached elements still in ram but also resident on disk. This makes space in situations of ...
std::unordered_map< struct iocb *, pageFileLocation * > pendingAios
Class that serves as a backend to managedMemory to actual write/read managedMemoryChunks to/from hard...
unsigned int aio_max_transactions
bool openSwapFileRange(unsigned int start, unsigned int stop)
opens certain range of swap files according to settings
managedMemoryChunk * chunk
pthread_mutex_t io_submit_lock
virtual bool extendSwap(global_bytesize size)
extend swap by size number of bytes
An implementation of managedSwap that is capable of kernel asynchronousIO.
pthread_cond_t io_submit_cond
pageFileLocation * allocInFree(pageFileLocation *freeChunk, global_bytesize size)
Helper function for pfmalloc.
virtual void close()
Close the swap if not already closed.
pthread_t io_arrive_thread
pageFileLocation determinePFLoc(global_offset g_offset, global_bytesize length) const
generate a pageFileLocation object given a global offset and a length of the data. This maps our "virtual" adress space to physical locations in a certain file
void asyncIoArrived(rambrain::pageFileLocation *ref, struct io_event *aio)
deals with a single asynchronous IO event completion
pthread_mutex_t aioWaiterLock
struct aiotracker * aio_ptr
void copyMem(rambrain::pageFileLocation &ref, void *ramBuf, bool reverse=false)
Schedules copying on level of whole managedMemoryChunks and calls scheduleCopy on the assigned parts...
virtual ~managedFileSwap()
void closeSwapFiles()
closes swap files
bool openSwapFiles()
opens swap files according to settings
pageChunkStatus
the status for pageFileLocations
pageFileLocation * pfmalloc(rambrain::global_bytesize size, rambrain::managedMemoryChunk *chunk)
Tries to find space in the swapFiles to write out an object of size size and returns first pageFileLo...
saves some storage in pageFileLocation
global_bytesize currentSize
std::queue< struct iocb * > io_submit_requests
pthread_t * io_submit_threads
pageFileLocation * glob_off_next
union glob_off_union glob_off_next
pageFileLocation(unsigned int file, global_bytesize offset, global_bytesize size, pageChunkStatus status=PAGE_FREE)
manages all managed Chunks of raw memory
unsigned int pageFileNumber
tracks page file allocations while objects are preferably written continuous to page file...
global_offset determineGlobalOffset(const pageFileLocation &ref) const
maps from physical location to "virtual" adress
virtual global_bytesize swapOut(managedMemoryChunk **chunklist, unsigned int nchunks)
Trigger swap out of the chunks pointed to by chunklist.
struct swapFileDesc * swapFiles
struct io_event * aio_eventarr
void my_io_submit(struct iocb *aio)
size_t getMemoryAlignment() const
If we have any restrictions regarding memory alignment of RAM buffers(DMA), this function tells us ab...
static void sigStat(int signum)
returns some statistics. Typically, we will be sensitive to SIGUSR2 if compiled with -DSWAPSTATS=on ...
managedFileSwap(global_bytesize size, const char *filemask, global_bytesize oneFile=0, bool enableDMA=false)
virtual bool checkForAIO()
gives this class the chance to treat incoming aio events
global_bytesize getFreeDiskSpace()
returns free disk space at file system location specified by filemask
static managedFileSwap * instance
structure to handle swap files
void scheduleCopy(void *ramBuf, pageFileLocation &ref, int *parttracker)
Convenience function for reverse scheduling a copy.
std::map< global_offset, pageFileLocation * > free_space
virtual bool extendSwapByPolicy(global_bytesize min_size)
extend swap by policy
virtual void swapDelete(managedMemoryChunk *chunk)
Mark chunk as deleted.
void copyMem(void *ramBuf, rambrain::pageFileLocation &ref)
Convenience function for reverse copying.
static void * io_submit_worker(void *ptr)
unsigned int io_submit_num_threads
static void * io_arrrive_worker(void *ptr)
datastructure for handling asynchronous events
void pffree(pageFileLocation *pagePtr)
global_bytesize pageFileSize
std::map< global_offset, pageFileLocation * > all_space
virtual global_bytesize swapIn(managedMemoryChunk **chunklist, unsigned int nchunks)
Trigger swap in of the chunks pointed to by chunklist.