Microkernel Object Configuration
Microkernel objects are explained fully in the Zephyr Kernel Primer. See Microkernel Services for example MDEF entries.
Procedure
Creating and Configuring an MDEF for a Microkernel Application
Create the MDEF to define microkernel objects used in your application when they apply to the application as a whole. You do not need to define every object before writing code. In some cases, the necessary objects aren’t obvious until you begin writing code. However, all objects used in your code must be defined before your application will compile successfully.
Note
Nanokernel applications do not use an MDEF because microkernel objects cannot be used in applications of this type.
Before you begin
- Confirm your
~/appDir
already exists. - Confirm Zephyr environment variables are set for each console terminal; for instructions, see Common Procedures.
Steps
- Create an MDEF in your application directory
(
~/appDir ~) using the name you specified in your application Makefile. (See :ref:`Creating an Application Makefile
).
$ touch prj.mdef
The default MDEF name is
prj.mdef
.
Open the file using a standard text editor.
Add settings to the file to suit your application.
The syntax for objects that can be defined in
.mdef
is:TASK name priority entry_point stack_size groups
TASKGROUP name
MUTEX name
SEMA name
FIFO name depth width
PIPE name buffer_size
MAILBOX name
MAP name num_blocks block_size
POOL name min_block_size max_block_size numMax
Note
Some microkernel objects, such as Task IRQs, are not
defined in an .mdef
file.
The following example shows the content of the
samples/philosophers/microkernel/proj.mdef
for the Philosophers’ sample application. The sample
uses seven tasks and six mutexes.
Example MDEF
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | % Application : DiningPhilosophers
% TASKGROUP NAME
% ==============
TASKGROUP PHI
% TASK NAME PRIO ENTRY STACK GROUPS
% ==================================================
TASK philTask 5 philDemo 1024 [EXE]
TASK phi1Task0 6 philEntry 1024 [PHI]
TASK philTask1 6 philEntry 1024 [PHI]
TASK philTask2 6 philEntry 1024 [PHI]
TASK philTask3 6 philEntry 1024 [PHI]
TASK philTask4 6 philEntry 1024 [PHI]
TASK philTask5 6 philEntry 1024 [PHI]
% MUTEX NAME
% ================
MUTEX forkMutex0
MUTEX forkMutex1
MUTEX forkMutex2
MUTEX forkMutex3
MUTEX forkMutex4
MUTEX forkMutex5
|