T-Kernel Specification | Section 1: Core Kernel Architecture
← Return to T-Kernel Index

T-Kernel 2.0 Core Architecture

Core Kernel Subsystems

T-Kernel 2.0 provides deterministic real-time execution for microprocessors, utilizing preemptive priority-based scheduling, static and dynamic task management, counting semaphores, 32-bit eventflags, message mailboxes, priority inversion control mutexes, fixed/variable memory pools, and high-resolution timer services.

1. Task States & Scheduling

A task in T-Kernel 2.0 transitions between five fundamental states during execution:

Task Management Primitives (C99):

/* Task Creation Structure */
typedef struct t_ctsk {
    VP      exinf;      /* Extended Information */
    ATR     tskatr;     /* Task Attributes (TA_HLNG, TA_USERBUF) */
    FP      task;       /* Task Entry Function Pointer */
    PRI     itskpri;    /* Initial Priority (1 to 140) */
    SZ      stksz;      /* Stack Size in Bytes */
    VP      bufptr;     /* User Stack Buffer Pointer */
} T_CTSK;

/* System Calls */
ID tk_cre_tsk( const T_CTSK *pk_ctsk );
ER tk_sta_tsk( ID tskid, VW stacd );
void tk_ext_tsk( void );
ER tk_exd_tsk( void );
ER tk_ter_tsk( ID tskid );
ER tk_slp_tsk( TMO tmout );
ER tk_wup_tsk( ID tskid );

2. Synchronization Primitives

T-Kernel 2.0 includes robust synchronization primitives for inter-task communication and resource lock control:

Counting Semaphores (semaphore.c):

typedef struct t_csem {
    VP      exinf;      /* Extended Information */
    ATR     sematr;     /* Semaphore Attributes (TA_TFIFO, TA_TPRI) */
    INT     isemcnt;    /* Initial Semaphore Count */
    INT     maxsem;     /* Maximum Semaphore Count */
} T_CSEM;

ID tk_cre_sem( const T_CSEM *pk_csem );
ER tk_del_sem( ID semid );
ER tk_sig_sem( ID semid, INT cnt );
ER tk_wai_sem( ID semid, INT cnt, TMO tmout );

Eventflags (eventflag.c):

typedef struct t_flg {
    VP      exinf;
    ATR     flgatr;     /* Eventflag Attributes (TA_WMUL, TA_CLR) */
    UINT    iflgptn;    /* Initial Flag Pattern (32-bit) */
} T_CFLG;

ID tk_cre_flg( const T_CFLG *pk_cflg );
ER tk_set_flg( ID flgid, UINT setptn );
ER tk_clr_flg( ID flgid, UINT clrptn );
ER tk_wai_flg( ID flgid, UINT waiptn, UINT wfmode, UINT *p_flgptn, TMO tmout );

Priority Inversion Control Mutexes (mutex.c):

typedef struct t_cmtx {
    VP      exinf;
    ATR     mtxatr;     /* Mutex Attributes (TA_INHERIT, TA_CEILING) */
    PRI     ceilpri;    /* Ceiling Priority for Priority Ceiling Protocol */
} T_CMTX;

ID tk_cre_mtx( const T_CMTX *pk_cmtx );
ER tk_loc_mtx( ID mtxid, TMO tmout );
ER tk_unl_mtx( ID mtxid );

3. Memory & Subsystem Management

T-Kernel 2.0 provides fixed-size memory pools (mempfix.c) and variable-size memory pools (mempool.c) for dynamic allocation in real-time execution:

/* Fixed-size Memory Pool */
typedef struct t_cmpf {
    VP      exinf;
    ATR     mpfatr;
    INT     mpfcnt;     /* Number of Blocks */
    SZ      blksz;      /* Size of Each Block */
} T_CMPF;

ID tk_cre_mpf( const T_CMPF *pk_cmpf );
ER tk_get_mpf( ID mpfid, VP *p_blk, TMO tmout );
ER tk_rel_mpf( ID mpfid, VP blk );