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. The bodies of
the jobs for the three tasks are in cyclic_test.c
- 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
- Solution using a scheduling table
- Try again with periods 60ms, 80ms and 120ms
- Modify the example to remove compilation warnings and to re-use the
periodic timers code in a better way (instead of cut'n'pasting it
in cyclic.c)
- 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 job bodies as in the previous example (download
them from
here).
You can use this header file
describing the prototypes of the three job bodies.
- 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
- A More advanced solution
that tries to set proper real-time priorities (according to
RM)
- Rewrite the example again, this time using threads to implement the
three tasks. You can look at thread.c to
remember how to create a thread.
- 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... WARNING: this program does not
re-use existing code in an appropriate way; this is on purpose, and
fixing the issue is left as an exercise. This is
one possible
solution.
- Look at another example on mutexes
to see how to use Priority Inheritance.
- Finally, here is an example of real-time application