## TFE |

**My thesis (made to graduate in computer sciences at the ULg)**- The goal of my thesis was to design a modular and generic embedded system. The hardware would be made of several modules and the software would be as portable as possible. The software architecture had to be the so called "real time operating system" and hence it would have to provide at least two major features:
- a scheduler that would choose the active task with the highest (fixed) priority in the system,
- and a communication scheme between the tasks (semaphores, for example).

The thesis can be downloaded here (in French): PS[PDF]. This document describes, with many details and examples, a possible solution to the problem described above.

Details about the way the kernel works can be found here.

You can also have a look at each of the different files of the project:

The user.c, user.h and dispatch.c files above are given as an example. They define two tasks.

The main function starts the task number 1 (see user.c). This task executes some iterations in a loop and then starts the task 2, which has a higher priority. The scheduler, which has been called by task 1 to start task 2 will then put task 1 in an idle state and make the task 2 run.

Task 2 will also loop a bit and then it will wait on semaphore 0 (WAIT operation on this semaphore which has a value of 0, in this example). Since task 2 is not active anymore, but waiting, task 1 can resume its execution. Task 1 will perform a signal operation on the semaphore 0 and hence unblock task 2. When task 2 will terminate, task 1 will then be able to terminate too.

Task 2 tests also the operation SET_SEM, see explanations above. SET_SEM is used to set the semaphore 0 to 48. Then task 2 performs a WAIT operation to check if the value of the semaphore becomes 47, as it has to. Task 1 will read the value of the semaphore 0 by means of the GET_SEM operation. The execution of this program displays these messages (on a system equipped with a terminal, of course):

task 1 is at pos 0, loop iteration number 0

task 1 is at pos 1, loop iteration number 1

task 1 is at pos 1, loop iteration number 2

task 1 is at pos 1, loop iteration number 3

task 1 is at pos 1, loop iteration number 4

task 2 is at pos 0 0

task 2 is at pos 1 1

task 2 is at pos 1 2

Task 2 is waiting on semaphore 0

task 1 is at pos 1, loop iteration number 5

task 1 is at pos 1, loop iteration number 6

Task 2, previously waiting on semaphore 0, is restarted

task 2 is at pos 1 3

task 2 is at pos 1 4

task 2 is at pos 1 5

task 2 is at pos 1 6

task 2 is at pos 1 7

task 2 is at pos 1 8

Sem 0 value is 47

task 2 is about to exit

task 1 is at pos 1, loop iteration number 7

task 1 is at pos 1, loop iteration number 8

Sem 0 value is 48

task 1 is about to exit

Last modification: january 2004.

Hugues Smeets