ProcessContext

Defines the global context of the running system process.  The context contains references to global services shared between system threads.

Summary
ProcessContextDefines the global context of the running system process.
CopyrightThis program is free software.
Files
C-kern/api/context/processcontext.hHeader file ProcessContext.
C-kern/context/processcontext.cImplementation file ProcessContext impl.
Types
struct processcontext_tExport processcontext_t.
Functions
test
unittest_context_processcontextTest initialization context of whole process succeeds.
processcontext_tDefines computing environment / context which is shared between all threads of computation.
valuecachePoints to global read only variables.
sysuserContext for sysuser_t module.
errorData for errorcontext_t module.
errorShared pagecache_blockmap_t used in pagecache_impl_t.
initcountCounts the number of successfull initialized services/subsystems.
constants
processcontext_STATICSIZEDefines the number of bytes needed from processcontext_t.
lifetime
processcontext_INIT_STATICStatic initializer.
init_processcontextInitializes the current process context.
free_processcontextFrees resources associated with processcontext_t.
query
isstatic_processcontextReturns true if pcontext equals processcontext_INIT_STATIC.

Copyright

This program is free software.  You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Author

© 2012 Jörg Seebohn

Files

C-kern/api/context/processcontext.h

Header file ProcessContext.

C-kern/context/processcontext.c

Implementation file ProcessContext impl.

Types

struct processcontext_t

typedef struct processcontext_t processcontext_t

Export processcontext_t.

Functions

Summary
test
unittest_context_processcontextTest initialization context of whole process succeeds.

test

unittest_context_processcontext

int unittest_context_processcontext(void)

Test initialization context of whole process succeeds.  And global variables are set correctly.

processcontext_t

struct processcontext_t

Defines computing environment / context which is shared between all threads of computation.  It contains e.g. services which offfer read only values or services which can be implemented with use of global locks.

Summary
valuecachePoints to global read only variables.
sysuserContext for sysuser_t module.
errorData for errorcontext_t module.
errorShared pagecache_blockmap_t used in pagecache_impl_t.
initcountCounts the number of successfull initialized services/subsystems.
constants
processcontext_STATICSIZEDefines the number of bytes needed from processcontext_t.
lifetime
processcontext_INIT_STATICStatic initializer.
init_processcontextInitializes the current process context.
free_processcontextFrees resources associated with processcontext_t.
query
isstatic_processcontextReturns true if pcontext equals processcontext_INIT_STATIC.

valuecache

struct valuecache_t * valuecache

Points to global read only variables.

sysuser

struct sysuser_t * sysuser

Context for sysuser_t module.

error

struct { uint16_t * stroffset ; uint8_t * strdata ; } error

Data for errorcontext_t module.

initcount

uint16_t initcount

Counts the number of successfull initialized services/subsystems.  This number is can be higher than 1 cause there are subsystems which do not have a reference stored in processcontext_t.

constants

processcontext_STATICSIZE

#define processcontext_STATICSIZE (
   sizeof(sysuser_t) + sizeof(valuecache_t) sizeof(pagecache_blockmap_t)
)

Defines the number of bytes needed from processcontext_t.  Static memory is allocated in init_processcontext.

lifetime

processcontext_INIT_STATIC

#define processcontext_INIT_STATIC { 0, 0, errorcontext_INIT_STATIC, 0, 0 }

Static initializer.

init_processcontext

int init_processcontext(/*out*/processcontext_t *pcontext)

Initializes the current process context.  There is exactly one process context for the whole process.  It is shared by all threads.  Function is called from maincontext_t.init_maincontext.

free_processcontext

int free_processcontext(processcontext_t *pcontext)

Frees resources associated with processcontext_t.  This function is called from maincontext_t.free_maincontext and you should never need to call it.

query

isstatic_processcontext

bool isstatic_processcontext(const processcontext_t *pcontext)

Returns true if pcontext equals processcontext_INIT_STATIC.

Defines the global context of the running system process.
Implements the global context of the running system process.
typedef struct processcontext_t processcontext_t
Export processcontext_t.
struct processcontext_t
Defines computing environment / context which is shared between all threads of computation.
int unittest_context_processcontext(void)
Test initialization context of whole process succeeds.
struct valuecache_t * valuecache
Points to global read only variables.
struct sysuser_t * sysuser
Context for sysuser_t module.
struct { uint16_t * stroffset ; uint8_t * strdata ; } error
Data for errorcontext_t module.
struct errorcontext_t
Stores description of system errors in a string table.
struct pagecache_blockmap_t
A simple shared hash map which maps an index pagecache_block_t.
struct pagecache_impl_t
Allocates and frees virtual memory pages and caches them.
uint16_t initcount
Counts the number of successfull initialized services/subsystems.
#define processcontext_STATICSIZE (
   sizeof(sysuser_t) + sizeof(valuecache_t) sizeof(pagecache_blockmap_t)
)
Defines the number of bytes needed from processcontext_t.
#define processcontext_INIT_STATIC { 0, 0, errorcontext_INIT_STATIC, 0, 0 }
Static initializer.
int init_processcontext(/*out*/processcontext_t *pcontext)
Initializes the current process context.
int free_processcontext(processcontext_t *pcontext)
Frees resources associated with processcontext_t.
bool isstatic_processcontext(const processcontext_t *pcontext)
Returns true if pcontext equals processcontext_INIT_STATIC.
int init_maincontext(const maincontext_e context_type,
int argc,
const char **argv)
Initializes global program context.
int free_maincontext(void)
Frees global context.
Close