proc.h File Reference

This file contains all definitions and types specific to the scheduling and task control. More...

#include "typedefs.h"
#include "mkernel_config.h"

Go to the source code of this file.

Classes

struct  t_task_descriptor
 the static part of an task. More...
struct  t_tcb
 The task control block. More...

Defines

#define PROC_FREE   0
 The process is free.
#define PROC_COMPUTING   1
 The task is ready for CPU usage.
#define PROC_TERMINATE   2
 Task is terminated.
#define PROC_WAIT_TIMER   3
 Wait for a timer event.
#define PROC_WAIT_EVENT   4
 Wait for an EVENT.
#define PROC_WAIT_RESOURCE   5
 Wait for a resource to become free.
#define PROC_SUSPENDED   6
 OSEK/VDX: suspended state.
#define PROC_NOT_EXIST   8
 Is returned if you enquire the status of an task with an id which is not in the range of the allowes task id's.
#define LOW_PRIORITY   1
 Priority.
#define NORMAL_PRIORITY   2
#define HIGH_PRIORITY   3
#define DADDR   __near byte*
 address of an data area
#define FULL   1
 VDX/OIL: full preemptive scheduling.
#define NON   0
 VDX/OIL: non preemptive scheduling.
#define ANY_TASK   100
 Idle task number. used to address all tasks.
#define NULL_TASK_ID   101
#define STACK_SIZE_KERNEL   150
 The size of the kernel stack.

Typedefs

typedef byte t_task_id
 this type is used to denote tasks.
typedef t_task_id TaskType
 OSEK:VDX task identification.
typedef TaskTypeTaskRefType
typedef void(* t_task_code )(void *)
 NULL reference to the code of the taks.
typedef void * TASK_ARGUMENT
 Task Argument.

Functions

void Schedule (void)
void _os_yield (void)
StatusType _os_task_create (t_task_id id, t_task_descriptor *descr)
StatusType _os_task_switch (t_task_id id)
 Switch to an given task.

Variables

t_tcb _TCB []
const int _os_max_tcb
POINTER _os_kernel_stack
t_tcb_os_current_task
byte _os_mode


Detailed Description

This file contains all definitions and types specific to the scheduling and task control.

Introduction

A task is described by its context which consists of the following elements:

Compiler Stack.
This is the stack which is simulated by the compiler. The implementation of the stack depends on the compiler which is used. The current implmentation supports only stack grwoing from high addess towards low addresses.
Cpu stack.
This is the build in stack of the cpu.
Code section.
The code of the process to be executed. Multiple processes may share the same code.
Data section.
There is no such thing as a data segment. Every process can access every address in the RAM at any time.
CPU registers.
All computing related registers.Hardware and interrupt registers do _not_ belong to the process context including the registers in the access file.

State Model

A process is either computing or waiting. Computing and waiting are comming in different flavours. See the defines PROC_XXXX.

Scheduling

The kernel provides two task control approaches. Coorperative scheduling where the application decides when to pass the control to a different task and premetive schedulung where the current task is interrupted by a clock and the scheduler switches to a different process.

Priority

The kernel supports 3 priorities, HIGH, NORMAL and LOW. High priority tasks will be selected first for scheduling. A task can change its priority at any time.

Processes with HIGH_PRIORITY will not be schedulued premeptive, this means the high priority task has to return the CPU after the actual job has been done (e.g. Task_Delay, Task_Wait etc).

Processes with NORMAL and LOW priority will be prepemted by the scheduler.

After a process becomes active because of an event, e.g. wakeup or a recevied message the scheduler will allow the process to run longer to allow fast processing of the incomming event.

Watchdog timer and scheduling

If the watch doc timer is used and high prio processes are running longer then the watchdog timer, the system will be restarted. There for it might make sense to include the Watchdog_Clear primitive in the main loop of your application.

Definition in file proc.h.


Define Documentation

#define ANY_TASK   100
 

Idle task number. used to address all tasks.

This id may be used if you want to send some events to the idle task. The idle task will consume the event without any side effect.

Definition at line 192 of file proc.h.

#define PROC_COMPUTING   1
 

The task is ready for CPU usage.

Task in this state a subject to execution.

Definition at line 100 of file proc.h.

#define PROC_FREE   0
 

The process is free.

This indicates an unused TCB entry

Definition at line 95 of file proc.h.

#define PROC_TERMINATE   2
 

Task is terminated.

A TCB in this state indicates a task which is in the process of termination. The scheduler will release on the next scheduling of this process all resources which are registered with this process.

Definition at line 107 of file proc.h.

#define PROC_WAIT_EVENT   4
 

Wait for an EVENT.

The scheduler provides a simple event mail box (see kernel.h). The process waits for an event from this mail box for a given time.

Definition at line 121 of file proc.h.

#define PROC_WAIT_TIMER   3
 

Wait for a timer event.

The kernel supports to sorts of timer events. The so called scheduled timer and an auxillary timer (see timer.h). The process encountered by the scheduler is waiting for a given number of CPU ticks a to change in the state PROC_COMPUTING.

Definition at line 115 of file proc.h.

#define STACK_SIZE_KERNEL   150
 

The size of the kernel stack.

When the tick handler is called it runs on the so called kernel stack. This is done to safe stack space for each task, otherwise the space would have been needed on each individial stack.

Definition at line 202 of file proc.h.


Typedef Documentation

typedef void* TASK_ARGUMENT
 

Task Argument.

A task is represented as function which gets one argument of the type TASK_ARGUMENT.

Definition at line 211 of file proc.h.


Function Documentation

StatusType _os_task_switch t_task_id  id  ) 
 

Switch to an given task.

Parameters:
id number of the task to switch to.
This function may also be used to give up control, by calling this function with the argument ANY_TASK.


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