/*
   FILE:							       	
	ft_api_controller.h							       
								       	
   DESCRIPTION:							       	
	RT-Linux side of a sample application using the POSIX trace
	support.

	See README file for details.
					       				
   Copyright (C) 2003
   Agnes   Lanusse
   Patrick Vanuxeem

  This is free software;  you can  redistribute it  and/or modify it under
  terms of the  GNU General Public License as published  by the Free Soft-
  ware  Foundation;  either version 2,  or (at your option) any later ver-
  sion.  It is distributed in the hope that it will be useful, but WITH-
  OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY
  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  for  more details.  You should have  received  a copy of the GNU General
  Public License;  see file COPYING.  If not, write to  the Free Software 
  Foundation,  59 Temple Place - Suite 330,  Boston, MA 02111-1307, USA.

  LAST REVISION:
        April 2003

*/


/******************************************************************************/
/*                                                                            */
/* FT API Controller : Defines                                                */
/*                                                                            */
/******************************************************************************/


/******************************************************************************/
/*                                                                            */
/* FT API Controller  : Types                                                 */
/*                                                                            */
/******************************************************************************/


/******************************************************************************/
/*                                                                            */
/* FT API Controller : Structures                                             */
/*                                                                            */
/******************************************************************************/
// Thread event type
// Necessary for ft_notify_task_created function
typedef enum ft_thread_event_types_t {
  FT_THREAD_CREATED,             // Task and realted threads created
  FT_THREAD_STARTED,             // First activation of a thread
  FT_THREAD_STARTED_NEW_CYCLE,   // Activation of thread on a new period
  FT_THREAD_ENDED_CYCLE,         // End of task cycle (within a period)
  FT_THREAD_ENDED_NORMALLY,      // Normal end of thread on exit or delete
  FT_THREAD_ABORT,               // Abnormal end of thread (abort) 
} FT_threads_event_types_t;

/******************************************************************************/
/*                                                                            */
/* FT API Controller : External API Functions                                 */
/*                                                                            */
/******************************************************************************/

extern int ft_notify_thread_started
 (
  pthread_t thread_id,
  int execution_start_date,
  int deadline
 );

extern int ft_notify_thread_finished
 (
  pthread_t thread_id,
  int execution_end_date,
  int deadline
 );

extern int ft_notify_dedline_miss
 (
  pthread_t thread_id
 );

extern int ft_notify_thread_aborted
 (
  pthread_t thread_id
 );

/******************************************************************************/
/*                                                                            */
/* FT API Controller : Internal API Functions                                 */
/*                                                                            */
/******************************************************************************/

extern int ft_notify_task_created
 (
  int  ft_task_id,
  char *ft_task_name,
  FT_threads_event_types_t ft_task_state,   // argument added !!!
  void (*normal_behavior_routine)(void*),   // argument added !!!
  void (*degraded_behavior_routine)(void*), // argument added !!!
  pthread_t ft_normal_thread_id,
  pthread_t ft_degraded_thread_id
  /*int ft_normal_thread_parameters,        // not used actually
    int ft_degraded_thread_parameters*/     // not used actually
 );

extern int ft_switch_task_mode
 (
  pthread_t thread_id
 );

extern int ft_set_task_status
 (
  pthread_t task_id,
  int task_status
 );

extern int ft_get_task_status
 (
  pthread_t task_id,
  int task_status
 );

extern int ft_get_task_mode
 (
  pthread_t task_id,
  int task_mode
 );
