FW Profile - C1 Implementation
FwRtCore.c File Reference

Implements Core Functions of the RT Container. More...

Go to the source code of this file.

Functions

void * ExecActivThread (void *ptr)
 The Activation Thread of the RT Container. More...
 
void ExecNotifProcedure (FwRtDesc_t rtDesc)
 Execute the loop in the Notification Procedure. More...
 
void ExecActivProcedure (FwRtDesc_t rtDesc)
 Execute the loop in the Activation Procedure. More...
 
void FwRtStart (FwRtDesc_t rtDesc)
 Start a RT Container. More...
 
void FwRtStop (FwRtDesc_t rtDesc)
 Stop a RT Container. More...
 
void FwRtNotify (FwRtDesc_t rtDesc)
 Execute the Notification Procedure of a RT Container. More...
 
void FwRtWaitForTermination (FwRtDesc_t rtDesc)
 Blocking function which returns when the Activation Thread has terminated. More...
 
FwRtBool_t FwRtIsNotifPrStarted (FwRtDesc_t rtDesc)
 Check whether the Notification Procedure is started. More...
 
FwRtBool_t FwRtIsActivPrStarted (FwRtDesc_t rtDesc)
 Check whether the Activation Procedure is started. More...
 
FwRtState_t FwRtGetContState (FwRtDesc_t rtDesc)
 Return the RT Container state. More...
 
int FwRtGetErrCode (FwRtDesc_t rtDesc)
 Return the error code of the RT Container. More...
 
FwRtCounterU2_t FwRtGetNotifCounter (FwRtDesc_t rtDesc)
 Return the value of the notification counter. More...
 

Detailed Description

Implements Core Functions of the RT Container.

Author
Vaclav Cechticky vacla.nosp@m.v.ce.nosp@m.chtic.nosp@m.ky@p.nosp@m.np-so.nosp@m.ftwa.nosp@m.re.co.nosp@m.m
Alessandro Pasetti paset.nosp@m.ti@p.nosp@m.np-so.nosp@m.ftwa.nosp@m.re.co.nosp@m.m

This file is part of the FW Profile.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

For information on alternative licensing, please contact P&P Software GmbH.

Definition in file FwRtCore.c.

Function Documentation

void ExecActivProcedure ( FwRtDesc_t  rtDesc)

Execute the loop in the Activation Procedure.

No check is performed on whether the activation procedure is started because, by design, the Activation Procedure is only ever executed if it is started.

Parameters
rtDescthe descriptor of the RT Container

Definition at line 217 of file FwRtCore.c.

void * ExecActivThread ( void *  ptr)

The Activation Thread of the RT Container.

This function is called by the Activation Thread when it is created.

Parameters
ptrthis parameter is not used
Returns
this function always returns NULL

Definition at line 237 of file FwRtCore.c.

void ExecNotifProcedure ( FwRtDesc_t  rtDesc)

Execute the loop in the Notification Procedure.

Parameters
rtDescthe descriptor of the RT Container

Definition at line 191 of file FwRtCore.c.

FwRtState_t FwRtGetContState ( FwRtDesc_t  rtDesc)

Return the RT Container state.

This function is not thread-safe (but note that it only returns the value of a field of the RT Container descriptor).

Parameters
rtDescthe descriptor of the RT Container.
Returns
the state of the RT Container.

Definition at line 176 of file FwRtCore.c.

int FwRtGetErrCode ( FwRtDesc_t  rtDesc)

Return the error code of the RT Container.

This function is not thread-safe (but note that it only returns the value of a field of the RT Container descriptor).

Parameters
rtDescthe descriptor of the RT Container.
Returns
the state of the RT Container.

Definition at line 181 of file FwRtCore.c.

FwRtCounterU2_t FwRtGetNotifCounter ( FwRtDesc_t  rtDesc)

Return the value of the notification counter.

The value of the notification counter represents the number of pending notifications in the RT Container. This function is not thread-safe (but note that it only returns the value of a field of the RT Container descriptor).

Parameters
rtDescthe descriptor of the RT Container.
Returns
the value of the notification counter.

Definition at line 186 of file FwRtCore.c.

FwRtBool_t FwRtIsActivPrStarted ( FwRtDesc_t  rtDesc)

Check whether the Activation Procedure is started.

This function is not thread-safe (but note that it only returns the value of a field of the RT Container descriptor).

Parameters
rtDescthe descriptor of the RT Container.
Returns
1 if the Activation Procedure is started, 0 otherwise.

Definition at line 171 of file FwRtCore.c.

FwRtBool_t FwRtIsNotifPrStarted ( FwRtDesc_t  rtDesc)

Check whether the Notification Procedure is started.

This function is not thread-safe (but note that it only returns the value of a field of the RT Container descriptor).

Parameters
rtDescthe descriptor of the RT Container.
Returns
1 if the Notification Procedure is started, 0 otherwise.

Definition at line 166 of file FwRtCore.c.

void FwRtNotify ( FwRtDesc_t  rtDesc)

Execute the Notification Procedure of a RT Container.

This function proceeds as follows:

  • It locks the container mutex.
  • It executes the Notification Procedure
  • It releases the mutex
Parameters
rtDescthe descriptor of the RT Container.

Definition at line 137 of file FwRtCore.c.

void FwRtStart ( FwRtDesc_t  rtDesc)

Start a RT Container.

A RT Container can be in two states: STARTED or STOPPED. This function proceeds as follows:

  • It locks the container's mutex
  • If the container is not in state STOPPED, the function releases the mutex and returns without doing anything.
  • If instead the container is in state STOPPED, the function:
    1. puts the container in state STARTED;
    2. resets the Notification Counter
    3. starts the Notification Procedure
    4. starts the Activation Procedure
    5. executes the Notification Procedure (this causes its initialization action to be performed)
    6. executes the Activation Procedure (this causes its initialization action to be performed)
    7. creates the container's Activation Thread (this also releases the thread);
    8. release the mutex and returns

The attributes of the Activation Thread are NULL by default or are those set with function FwRtSetPosixAttr.

If any of the system calls made by this function returns an error, the container is put in an error state (see FwRtState_t) and the error code is stored in the errCode field of the container descriptor.

The Activation Thread is released upon creation and executes the following actions:

while true do {
  lock container's mutex;
   wait until Notification Counter is greater than zero;
   decrement Notification Counter;
  release container's mutex;
  execute Activation Procedure;
  if (Activation Procedure has terminated) then {
    put RT Container in STOPPED state;
    execute Notification Procedure;
    break;
  }
  if (RT Container is in state STOPPED) then {
    execute Activation Procedure;
    execute Notification Procedure;
    break;
  }
}

Use of this function is subject to the following constraint:

  • The function may only be called before the Activation Thread has been created for the first time or after the Activation Thread has terminated execution (function FwRtWaitForTermination can be used to wait for the Activation Thread to have terminated).
Parameters
rtDescthe descriptor of the RT Container.

Definition at line 47 of file FwRtCore.c.

void FwRtStop ( FwRtDesc_t  rtDesc)

Stop a RT Container.

A RT Container can be in two states: STARTED or STOPPED. This function proceeds as follows:

  • It locks the container's mutex.
  • If the container is not in state STARTED, the function releases the mutex and returns.
  • If instead the container is in state STARTED, the function: (a) puts the container in the STOPPED state; (b) sends a notification to the Activation Thread; and (c) releases the mutex.

If any of the system calls made by this function returns an error, the container is put in an error state (see FwRtState_t) and the error code is stored in the errCode field of the container descriptor.

Parameters
rtDescthe descriptor of the RT Container.

Definition at line 97 of file FwRtCore.c.

void FwRtWaitForTermination ( FwRtDesc_t  rtDesc)

Blocking function which returns when the Activation Thread has terminated.

This function uses POSIX's pthread_join to wait until the Activation Thread has terminated.

Use of this function is subject to the following constraints:

  • While this function is waiting on a given container, no other call to the function can be made on the same container.
  • Use of this function assumes that the thread in the argument container is joinable (this will normally be the case if the container's thread has been created with default attributes).
Parameters
rtDescthe descriptor of the RT Container.

Definition at line 154 of file FwRtCore.c.

P&P Software GmbH, Copyright 2011, All Rights Reserved