Writing a multi-stack application that runs on multiple stacks with semaphores

From ErikaWiki

Revision as of 09:44, 10 December 2009 by Erikadds (Talk | contribs)
Jump to: navigation, search

Reference test

examples/s12xs/porting_examples/multistack/EEtest5

examples/s12xs/porting_examples/multistack/EEtest6

Description

  • The goal of the two tests is to activate two tasks that run on different stacks and use semaphores. To configure the task set we change the files eecfg.h and eecfg.c located inside the Debug folder (the basic structure is inspired to the Microchip PIC30 port) and the makefile.

examples/s12xs/porting_examples/multistack/EEtest5

  • The demo is a classical producer/consumer problem implemented with two semaphores P and V. The demo is used to test the following features of ERIKA Enterprise OS:
    • Multistack configuration: The Producer and the Consumer task need a separate stack because they block calling the WaitSem primitive.
    • Semaphores: ERIKA Enterprise supports counting semaphores. The demo show how to initialize the semaphores, and how to use the main semaphore primitives (PostSem and WaitSem).


examples/s12xs/porting_examples/multistack/EEtest6

  • The demo can be used to test the internal function: EE_s12xs_hal_stkchange. The low priority task Task1 is activated in the main function. Task1 then activates the high priority task Task2. At this point Task1 is preempted (and the stack change inside the EE_s12xs_hal_ready2stacked) and Task2 begins to execute. Task2 then is blocked on a semaphore and Task1 is resumed with a call to the internal funtion EE_s12xs_hal_stkchange.
  • Please note that this small application shows a particular case where a stack is saved inside the EE_s12xs_hal_ready2stacked function and resumed inside the EE_s12xs_hal_stkchange function. This can help to better understand the stack change mechanism.

Expected output

When everything is done in the right way, with the following commands we can have the executable file:

  • open a Cygwin shell
  • cd into the Debug directory
  • the commands make clean and make all should work correctly producing an executable inside the Debug directory.

To simulate the application we can use directly the hardware or a "good" software debugger.

Personal tools