RKH
Miscellaneous

Files

file  rkhplat.h
 RKH platform abstraction layer.
 
file  rkhtype.h
 Defines the data types that uses RKH.
 

Functions

void rkh_fwk_init (void)
 Initializes the RKH framework. More...
 
void rkh_fwk_enter (void)
 RKH framework is started. More...
 
void rkh_fwk_exit (void)
 Exit the RKH framework. More...
 

Detailed Description

Function Documentation

void rkh_fwk_init ( void  )

Initializes the RKH framework.

A requirement of RKH is that must be called rkh_fwk_init() before call any of its other services. This function initializes all of RKH's variables and data structures.

Note
Platform-dependent function. All RKH ports must be define it in the RKH port file to a particular platform. However, only the ports to the external OS/RTOS usually need some code to bolt the framework to the external OS/RTOS.
Usage
Implementation example for x86, linux emulator of simple cooperative scheduler non-preemptive.
void
{
sem_init(&sma_is_rdy, 0, 0);
}
void rkh_fwk_enter ( void  )

RKH framework is started.

This entry function turns over control to RKH (and does not return!). This function runs the highest priority state machine application (SMA) that is ready to run in run-to-completation model.

Note
The call to this function does not return. Hence, any code after it will never be executed.
Platform-dependent function. All RKH ports must be define it in the RKH port file to a particular platform. However, only the ports to the external OS/RTOS usually need some code to bolt the framework to the external OS/RTOS.
Usage
Implementation example for x86, linux emulator of simple cooperative scheduler non-preemptive.
void
{
rui8_t prio;
RKH_SMA_T *sma;
RKH_HOOK_START();
running = 1;
while (running)
{
if (RKH_RDY_ISNOT_EMPTY(rkhrg))
{
RKH_RDY_FIND_HIGHEST(rkhrg, prio);
sma = rkh_sptbl[prio];
e = rkh_sma_get(sma);
RKH_FWK_GC(e, sma);
}
else
{
}
}
sem_destroy(&sma_is_rdy);
pthread_mutex_destroy(&csection);
}
Here is the basic algorithm for interpreting the listing shown above. A pseudocode description of the procedure is:
infinite loop
{
disable interrupts;
if( is_active_object_ready_to_run )
{
find the active object with highest priority;
enable interrupts;
e = get the event from the active object's queue;
dispatch the 'e' event to the active object's state machine;
}
else
execute the idle processing;
}
void rkh_fwk_exit ( void  )

Exit the RKH framework.

Function invoked by the application layer to exit the RKH application and return control to the underlying OS/Kernel.

Note
This function is strongly platform-dependent. All RKH ports and must be defined in the RKH port to a particular platform. Some RKH ports might not require implementing this function at all, because many embedded applications don't have anything to exit to.
Platform-dependent function. All RKH ports must be defined in the RKH port file to a particular platform. However, only the ports to the external OS/RTOS usually need some code to bolt the framework to the external OS/RTOS.
Usage
Implementation example for x86, linux emulator of simple cooperative scheduler non-preemptive.