Shared Persistent Heap, logger. For shared memory multi-thread/multi-core applications. This implementation uses atomic operations to implement Lock Free Loggers (SPHLFLogger_t).
More...
|
__C__ SPHLFLogger_t | SPHLFLoggerInit (void *buf_seg, block_size_t buf_size) |
| Initialize a shared storage block as a Lock Free Event Logger.
|
|
__C__ SPHLFLogger_t | SPHLFLoggerInitWithStride (void *buf_seg, block_size_t buf_size, unsigned short entry_stride, unsigned int options) |
| Initialize a shared storage block as a Lock Free Event Logger with a fixed entry stride.
|
|
__C__ SPHLFLogger_t | SPHLFLoggerCreate (block_size_t buf_size) |
| Allocate and initialize a shared storage block as a Lock Free Event Logger.
|
|
__C__ SPHLFLogger_t | SPHLFCircularLoggerCreate (block_size_t buf_size, unsigned short stride) |
| Allocate and initialize a shared storage block as a Lock Free Event Logger. Mark the logger as circular and specify a fixed Stride.
|
|
__C__ void * | SPHLFLoggerAllocRaw (SPHLFLogger_t log, block_size_t alloc_size) |
| Return the address of a (raw) Logger entry allocated from the specified logger.
|
|
__C__ SPHLFLoggerHandle_t * | SPHLFLoggerAllocTimeStamped (SPHLFLogger_t log, int catcode, int subcode, block_size_t alloc_size, SPHLFLoggerHandle_t *handlespace) |
| Allocate and initialize the header, of a timestamped logger entry, from the specified logger.
|
|
__C__ SPHLFLoggerHandle_t * | SPHLFLoggerAllocStrideTimeStamped (SPHLFLogger_t log, int catcode, int subcode, SPHLFLoggerHandle_t *handlespace) |
| Allocate and initialize the header, of a timestamped logger entry, from the specified logger.
|
|
__C__ SPHLFLoggerHandle_t * | SPHLFLoggerAllocTimeStampedNoLock (SPHLFLogger_t log, int catcode, int subcode, block_size_t alloc_size, SPHLFLoggerHandle_t *handlespace) |
| Allocate and initialize the header of a timestamped logger entry from the specified logger, without locking or memory barriers.
|
|
__C__ SPHLFLoggerHandle_t * | SPHLFLoggerAllocStrideTimeStampedNoLock (SPHLFLogger_t log, int catcode, int subcode, SPHLFLoggerHandle_t *handlespace) |
| Allocate and initialize the header, of a timestamped logger entry, from the specified logger, without locking or memory barriers.
|
|
__C__ int | SPHLFLoggerEntryComplete (SPHLFLoggerHandle_t *entryhandle) |
| Marks the entry specified by the entry handle as complete.
|
|
__C__ int | SPHLFLoggerEntryIsComplete (SPHLFLoggerHandle_t *entryhandle) |
| Return the status of the entry specified by the entry handle.
|
|
__C__ int | SPHLFLoggerEntryIsTimestamped (SPHLFLoggerHandle_t *entryhandle) |
| Return the status of the entry specified by the entry handle.
|
|
__C__ SPHLFLoggerHandle_t * | SPHLFLoggerIteratorNext (SPHLFLogIterator_t *iterator, SPHLFLoggerHandle_t *handlespace) |
| For the provided Logger Iterator creates a entry handle for the next sequential Logger entry. The resulting entry handle can be used to read the contents of the Logger entry.
|
|
__C__ SPHLFLogIterator_t * | SPHLFLoggerCreateIterator (SPHLFLogger_t log, SPHLFLogIterator_t *iteratorSpace) |
| Creates a logger Iterator for reading sequential entries from a specific logger.
|
|
__C__ int | SPHLFLoggerEmpty (SPHLFLogger_t log) |
| Return the status of the specified logger.
|
|
__C__ int | SPHLFLoggerWrapped (SPHLFLogger_t log) |
| Return the status of the specified logger.
|
|
__C__ block_size_t | SPHLFLoggerFreeSpace (SPHLFLogger_t log) |
| Returns the amount of free space (in bytes) remaining in the specified logger.
|
|
__C__ int | SPHLFLoggerFull (SPHLFLogger_t log) |
| Return the status of the specified logger.
|
|
__C__ int | SPHLFLoggerResetIfFullSync (SPHLFLogger_t log) |
| Resets the specific logger to empty state synchronously if it is currently full.
|
|
__C__ int | SPHLFLoggerResetAsync (SPHLFLogger_t log) |
| Resets the specific logger to empty state asynchronously (without locking or atomic updates).
|
|
__C__ int | SPHLFLoggerPrefetch (SPHLFLogger_t log) |
| Prefetch pages from the specific logger.
|
|
__C__ int | SPHLFLoggerSetCachePrefetch (SPHLFLogger_t log, int prefetch) |
| Set the cache-line prefetch options for entry allocate.
|
|
__C__ int | SPHLFLoggerDestroy (SPHLFLogger_t log) |
| Destroys the logger and frees the SAS storage for reuse.
|
|
Shared Persistent Heap, logger. For shared memory multi-thread/multi-core applications. This implementation uses atomic operations to implement Lock Free Loggers (SPHLFLogger_t).
This Logger API supports atomic allocation of storage for event entries for zero copy persistence and sharing. Only the allocation of the entry is serialized. If there are multiple threads or processes generating log entries, on a multi-core processor, hardware threads can fill in Log entries in parallel with other threads.
The API support simple loggers and circular loggers. Simple loggers stop allocating entries when the log buffer is full. Circular loggers wrap to the beginning of the log buffer when the log buffer fills. This overwrites the oldest log entries. but allows logging on a continuous basis. Circular loggers use a fixed entry stride to insure the oldest entry can be found easily. A stride that matches the cache line size can improve performance by avoiding "false sharing" of cache lines containing multiple logger entries across cores/sockets.
For example:
if ( logger )
{
if (context)
{
}
}
__C__ int SASJoinRegion()
Join this process to a SAS Region.
__C__ int SPHContextAddName(SPHContext_t contxt, char *name, void *value)
Add a name/address mapping to this context.
__C__ SPHContext_t SPHSetupProjectContext(char *project_name)
Setup the root and named project contexts. A project context is just a second level context named in ...
void * SPHContext_t
Handle to an instance of SPH Context.
Definition sphcontext.h:48
void * SPHLFLogger_t
Handle to an instance of SPH Lock Free Logger.
Definition sphlflogger.h:173
__C__ SPHLFLogger_t SPHLFCircularLoggerCreate(block_size_t buf_size, unsigned short stride)
Allocate and initialize a shared storage block as a Lock Free Event Logger. Mark the logger as circul...
As an option the logger allocator will fill in a 16 byte
entry header with: \n Entry status and length. \n Entry identifying
Category and SubCategory codes. \n Process and Thread Ids. \n High
resolution timestamp.
if (context)
{
...
if (logger)
{
...
}
}
__C__ SPHContext_t getProjectContextByName(char *project_name)
return the address of the named project context.
__C__ void * SPHContextFindByName(SPHContext_t contxt, char *name)
Find the address value associated with a name within a specific context.
__C__ SPHLFLoggerHandle_t * SPHLFLoggerAllocStrideTimeStamped(SPHLFLogger_t log, int catcode, int subcode, SPHLFLoggerHandle_t *handlespace)
Allocate and initialize the header, of a timestamped logger entry, from the specified logger.
Instance of a Lock Free Logger Entry Handle.
Definition sphlflogger.h:244
Any additional storage allocated to the entry
is available for application specific data.
The sphlflogentry.h API also provides
several mechanisms to store application data including; direct
array or structure overlay, and a streams like mechanism.
The API provides a completion function (SPHLFLoggerEntryComplete)
which provides any memory barriers required by the platform and
marks the entry complete.
...
if (handex)
{
SPHLFLogEntryAddInt(handlex, int_data1);
SPHLFLogEntryAddInt(handlex, int_data2);
SPHLFLogEntryAddPtr(handlex, ptr_1);
SPHLFLogEntryAddDouble(handlex, double_data1);
SPHLFLogEntryAddString(handlex, "any_c_string");
...
}
static int SPHLFLogEntryComplete(SPHLFLoggerHandle_t *handlespace)
Marks the entry specified by the entry handle as complete. Also executes write memory barries require...
Definition sphlflogentry.h:111
The logger contents are shared and persistent and will not be lost if the logging process crashes. Logger entries can be retrieved at any time after it is marked complete.
The API provides Log Iterator functions that support sequential read-back
of (completed) Logger entries. First create a log iterator
(with SPHLFloggerCreateIterator). Then use the resulting iterator to
sequentially step through log entries (via SPHLFLoggerItertorNext).
The iterator runtime handles both simple and circular loggers and insures
entries are read-out (oldest to newest) in order.
...
if (iter)
{
while (handex)
{
int cat, subcat, PID, TID:
int int_data1, int_data1;
void * ptr_1;
double double_data1;
char * entry_str;
...
int_data1 = SPHLFLogEntryGetNextInt(handlex);
int_data2 = SPHLFLogEntryGetNextInt(handlex);
ptr_1 = SPHLFLogEntryGetNextPtr(handlex);
double_data1 = SPHLFLogEntryGetNextDouble(handlex);
entry_str SPHLFLogEntryGetNextString(handlex);
...
...
}
}
static sphtimer_t SPHLFLogEntryTimeStamp(SPHLFLoggerHandle_t *handlespace)
Return the time stamp value for the entry specified by the entry handle.
Definition sphlflogentry.h:160
static sphpid16_t SPHLFLogEntryTID(SPHLFLoggerHandle_t *handlespace)
Return the thread ID for the entry specified by the entry handle.
Definition sphlflogentry.h:198
static int SPHLFLogEntrySubcat(SPHLFLoggerHandle_t *handlespace)
Return the entry sub-category for the entry specified by the entry handle.
Definition sphlflogentry.h:255
static int SPHLFLogEntryCategory(SPHLFLoggerHandle_t *handlespace)
Return the entry category for the entry specified by the entry handle.
Definition sphlflogentry.h:234
static sphpid16_t SPHLFLogEntryPID(SPHLFLoggerHandle_t *handlespace)
Return the process ID for the entry specified by the entry handle.
Definition sphlflogentry.h:179
__C__ SPHLFLoggerHandle_t * SPHLFLoggerIteratorNext(SPHLFLogIterator_t *iterator, SPHLFLoggerHandle_t *handlespace)
For the provided Logger Iterator creates a entry handle for the next sequential Logger entry....
__C__ SPHLFLogIterator_t * SPHLFLoggerCreateIterator(SPHLFLogger_t log, SPHLFLogIterator_t *iteratorSpace)
Creates a logger Iterator for reading sequential entries from a specific logger.
unsigned long long int sphtimer_t
Value from TB/TSC register (64-bits on all platforms).
Definition sphtimer.h:66
Instance of a Lock Free Logger Iterator.
Definition sphlflogger.h:264