Summary of Some Exercises
- Read the slides on
periodic tasks.
Download the example programs, try them, and
try to modify them to understand how they work.
- Modify
periodic-4.c
to remove global variables. A possible solution is
here.
- Now, implement a cyclic executive scheduler (see last three slides)
for three tasks with periods 50ms, 100ms, and 150ms
- Note: the last two slides are a copy of the slides from
lesson II.
The numbers in such slides are not referring to this exercise.
- First hint: compute the minor cycle and the major cycle
- Second hint: so, you need a periodic timer every ... ms
- Third hint: write down a table showning which tasks should
execute in every minor cycle
- Question: how big must this table be?
- Last hint: remember that in cyclic executive tasks are
non-preemptable... They are not real tasks, but you can
``simulate'' them through function calls...
- Solution
- Repeat the exercise with the new periods written in slide 21
(60, 80, and 120)
- Now, read the slides on
POSIX processes.
Again, download the examples, and try them.
- You should now be able to rewrite the previous example (three
periodic tasks, with periods 50ms, 100ms, and 150ms) using three
real processes instead of a cyclic executive scheduler.
- Use the same task bodies as in the previous example (download
them from
here)
- You now need to create three processes... You can reuse
code from
the fork() example
- Each one of the three processes must be periodic... Reuse
some code from one of the previous periodic-?.c examples
- A possible Solution
- To finish the exercises on POSIX processes, download the
Real-Time Signals
example, read it, try it, and try to understand how it works.
- Read the slides on
POSIX Threads.
Download the examples
(ex_create.c
and
(thread.c),
read them, and try them. Compare thread.c with the fork() example.
- Now you know how to create, join, and cancel a thread, and you
should be able to rewrite the "periodic tasks" example (three
periodic tasks, with periods 50ms, 100ms, and 150ms) using three
POSIX threads instead of three processes.
- Use the same task bodies as in the previous examples (download
them from
here)
- You now need to create three threads... You can reuse
code from
the thread creation example
- Each one of the three threads must be periodic... Reuse
some code from some previous examples.
- Now, you should be able to see why global variables are evil...
- Warning! If you use POSIX timers generating a signal, you must
be careful...
- Of course, the "posix_nanosleep()-based solution" is simpler...
- A possible Solution
- Read the slides on
pthread Synchronisation.
Download the example on mutexes
(ex_mutex.c),
read it, and try it.
- Now, look at the
message passing
example, about condition variables.
Here are some
possible modifications
at the previous program.
- Read the slides about
cross-compiling
for ARM. Download the cross-compiler, try it, and compile
some simple program (using static linking).
- Try to execute the compiled programs with qemu (as explained in the
slides)
- Try to compile dynamic executables, and execute them with qemu
- Now, you are ready to generate a filesystem for an embeded device.
See these notes
for more details. Download
busybox,
and try to reproduce the steps described in the slides. You will need
to download this kernel.
- These scripts can be used to automate the
process.
- Look at this example about
Linux Kernel Modules
- Some experiments with the
xenomai kernel
- You can repeat similar experiments with
RTAI: read the documentation
(and work with x86: RTAI for ARM is currently unusable)
- For performing experiments with RTAI on x86, you might need:
- Have a look at this example RT application,
try to fix it, and transform it in a Xenomai application
- In case you do not know how to use the
Linux Kernel Modules or you cannot
test them because you have no root powers, have a look at these
instructions.