     /***********************************************************************
                   Copyright (c) 2007-2008 SKY Computers, Inc.
    
     Redistribution and use in source and binary forms are permitted
     provided that this notice is preserved and that due credit is given to
     SKY Computers, Inc. The name of SKY Computers, Inc. may not be used to
     endorse or promote products derived from this software without
     specific prior written permission. This software is provided ``as is''
     without express or implied warranty.
    ************************************************************************/

/*
 *--------------------------------------------------------------------------
 *
 >++
 *
 *   File:  lk_tcb.h 
 *
 *   Function:  To define the common structures and parameters used in the
 *       "lock" example.
 *
 *   Calling Sequence: N.A.
 *
 *   Implementation Details:
 *       1. See below.
 *
 *   Restrictions:
 *       1. None
 *
 >**
 *   Revision Information:
 *    Date       By    Rev   Changes Made....
 *    07/30/08   bwj   0.0   New Module, in process.
 >--
 *--------------------------------------------------------------------------
 */

#ifndef _TH_TCB_H_
#define _TH_TCB_H_

/* Some Time_Trac parameters. */
#define  TT_MAX_EVENTS       (10000)
#define  V_SIZE              (1024*64)

#define NUMMAIN_THREADS      (1)                    /* this one starts the others */
#define NUM_CO_THREADS       (4)                    /* main thread counts as one */
#define NUM_SUM_THREADS      (1)                    /* used to collec results */
#define NUM_THREADS          (1+NUM_CO_THREADS+1)   /* main thread, post thread each count as one */
#define MAX_RANK             (NUM_THREADS)

#define LK_WAITING           (1)             /* waiting for others */
#define LK_TH_GO             (2)             /* no longer waiting */

/* For the thread control block ... */
struct thread_control_block
{
  int Rank;                   /* starting from 0 for the main, never changes */
  int Comm;                   /* see COMM_*, below, set by main thread */
  int Status;                 /* set by the compute thread */
  int Pass;                   /* pass count from the main thread */
  int Wdog;                   /* watchdog flag */
  int Faults;                 /* unused */
  int Stuff[2];               /* unused */
};

typedef struct thread_control_block TCB;

/* For the parameter block ... */
struct ex_param_block
{
    int Block_size;           /* starting from 0 for the main */
    int Out_size;             /* see COMM_*, below */
    int Stuff;
};

typedef struct ex_param_block EPB;

/* ???? */
#define WDOG_RST    (1)       /* watchdog reset  */
#define WDOG_CLR    (2)       /* watchdog clear */

/* NOTE: The names array just below in EX_MAIN must match these values. */
#define COMM_NONE   (0)       /* unused */
#define COMM_INIT   (1)
#define COMM_COMP   (2)
#define COMM_EXIT   (3)

#ifdef EX_MAIN
const char *task_name[] = {
    "No State",               /* 0 */
    "Init",                   /* 1 */
    "Compute",                /* 2 */
    "Exit",                   /* 3 */
    "Unknown"
};
#else
extern const char *task_name[];
#endif

#define STAT_NONE   (0)       /* unused */
#define STAT_WAIT   (1)       /* thread is waiting for a command */
#define STAT_RUN    (2)       /* thread is computing */
#define STAT_DONE   (3)       /* thread is done computing */
#define STAT_EXIT   (4)       /* thread exiting */

#ifdef EX_MAIN
const char *stat_name[] = {
    "None",                   /* 0 */
    "Waiting",                /* 1 */
    "Running",                /* 2 */
    "Done",                   /* 3 */
    "Exiting",                /* 4 */
    "Unknown"               
};
#else
extern const char *stat_name[];
#endif

extern void *ex_mem_alloc (int rank, int bytes, int align, char *str);
 
#endif

/* --------------------------- End of Module ---------------------------- */

