kernel.h File Reference

This file contains the complete interface description of the kernel. More...

#include "mkernel_config.h"
#include "typedefs.h"
#include "proc.h"
#include "timer.h"
#include "event.h"
#include "resource.h"
#include "task.h"
#include "alarm.h"
#include "execution.h"
#include "interrupts.h"

Go to the source code of this file.

Functions

void _os_yield (void)
 Initiate a scheduling.
void ENTER_CRITICAL (void)
 Enter a critical section in the code.
void EXIT_CRITICAL (void)
 Exit an critical section.Since the INTCON is stored on the stack, this function can only be used together with ENTER_CRITICAL.
void TaskBeginHook (t_task_id id)
void TaskEndHook (t_task_id id)
void panic (int nbr)
 Panic handler The pnaic handler has to be implemented for a specific hardware but it is used all over the kernel.

Variables

t_task_id _os_my_task_id
 My own task id.


Detailed Description

This file contains the complete interface description of the kernel.

Concepts

Mkernel in inspired by the ideas OSEK/VDX, which means it provides the concept of tasks, alarms and events.

The implementation of a task looks as shown below. The task function may defines some local variables which allocated on the stack of the task. Typically there will be a loop which does something use full until the job is done and the process may terminate.

  void TASK(Receiver) {
                int some_local_data = .... ;

                while( .. not end ...) {

                        ... do some thing usefull ...
                }

                Task_Terminate();
  }

The termination of the process is done by means of the Task_Terminate call which terminates the current process.

Note:
Before terminating the process make sure that all common resources have been released correctly, since mkernel does not keep track of these resources.
In order to create the infra structure around this task, the task needs to be specified in the OIL file as well:

        TASK Receiver {
                PRIORITY = 1;
                STACKSIZE = 128;
                SCHEDULE = FULL;
                AUTOSTART = TRUE;
        };

This section will generate automatically init code which will startup the task Receiver after system startup as a fully preemptive task with a stack of 128 byte.

The application developer has to provide a main function which has to detect the application mode and to startup the operating system with the identified application mode.

  #include "myapp_defs.h"

  int main() {
     AppModeType mode;

     .... determine application mode ....
                mode = Mode_ ..... ;

           StartOS(mode);
  }

Inter Process Communication

In order to communication between different processes events are used. Events are represented as a bit mask, where each bin represents an event.

A task may wait for a single event by means of the WaitEvent service.

Interrupt Priorities

There are two types of interrupt handlers. If an low priority interrupt occures, the kernel will save the context of the interrupted process, check if this interrupt has been caused by the tick timer. If yes the premeption will be called and the context of the next tsak restored. Other wise the device interrupt handler will be invoked. After this has been done the scheduler will be executed and the context of the selected task will be restored. In case of an high priority, the kernel will check if the interrupt is related the dedicated timer T1. If not, the device handler is called to check what kinf of interrupt has occured. After execution of the interrupt handler the execution returns to the interrupted task. No scheduling will take place.

Process control from interrupt handlers

Definition in file kernel.h.


Function Documentation

void _os_yield void   ) 
 

Initiate a scheduling.

This function should _not_ be called by applications. Applications should use Task_Switch(ANY_TASK)

void ENTER_CRITICAL void   ) 
 

Enter a critical section in the code.

All interrupts are disabled till the EXIT_CRITICAL has been executed. Both functions should be used with exterem care.

void panic int  nbr  ) 
 

Panic handler The pnaic handler has to be implemented for a specific hardware but it is used all over the kernel.

Parameters:
nbr - number of the error condtion.


Generated on Mon Sep 29 19:56:48 2008 for mKernel by  doxygen 1.4.6