Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1664 pj 1
 
2
 
3
#include <kernel/kern.h>
4
#include <drivers/glib.h>
5
#include <drivers/keyb.h>
6
#include <semaphore.h>
7
#include <stdlib.h>
8
#include <math.h>
9
#include <time.h>
10
 
11
 
12
/*PREY & PREDATOR Dimensions*/
13
#define RAD          3 
14
#define PREY_RAD     2 
15
 
16
/*Graphics dimensions*/
17
#define BARSIZE  50
18
#define YMENU    10
19
#define XMIN     20
20
#define XMAX     460
21
#define YMIN     20
22
#define YMAX     460 
23
#define RATIO    20
24
 
25
/*Grid Mapping*/
26
int MAPPING = XMIN/RATIO;
27
int grid[(XMAX-XMIN)/RATIO][(YMAX-YMIN)/RATIO];
28
 
29
 
30
/*Tasks number and id */
31
#define SNAKEGROUP 1
32
#define INITIAl_TASKS 3
33
#define MAXTASKS 18
34
PID pid;
35
int number_of_tasks =0;
36
 
37
/*For Jet Control*/
38
#define SNAKE_R "S_Red"
39
#define SNAKE_B "S_Blue"
40
#define SNAKE_Y "S_Yell"
41
#define BAR     "BarGraph"
42
#define PREY    "Prey"
43
 
44
const char* NAME[]={SNAKE_R,SNAKE_B,SNAKE_Y,PREY,BAR,NULL};
45
 
46
 
47
/* WCET, Periods and Models */
48
 
49
int     sam_red_period = 40000;             /* task period 40000 */
50
int     sam_red_wcet = 1000;               /* task wcet  1000   */
51
 
52
int     sam_blue_period = 60000;           /* task period 60000 */
53
int     sam_blue_wcet = 1500;              /* task wcet  1500  */
54
 
55
int     sam_yellow_period = 80000;     /* task period 80000 */
56
int     sam_yellow_wcet = 2000;        /* task wcet  2000  */
57
 
58
int     prey_period = 50000;     /* task period 50000 */
59
int     prey_wcet = 1500;        /* task wcet  1500  */
60
 
61
int     PERIOD_BARGRAPH = 80000;     /* task period for bargraph 80000 */
62
int     WCET_BARGRAPH = 2000;        /* task wcet for bargraph 2000 */
63
 
64
int      PERIOD_JET =  500000;   /* task period for bargraph 500000 */
65
int      WCET_JET =   1000;            /* task wcet for bargraph 1000 */
66
 
67
/*For grid and graphics semaphore*/
68
 
69
sem_t grx_mutex;
70
sem_t grid_mutex;
71
 
72
/*Prey decalaration*/
73
struct Prey
74
{
75
  int x;
76
  int y;
77
  int isAlive;
78
};
79
 
80
/*Predator decalaration*/
81
struct Saamp
82
{
83
  int x;
84
  int y;
85
  int color;
86
  int number_of_times_killed;
87
};
88
 
89
struct Saamp saamps[MAXTASKS + 1];
90
 
91
/*For score card*/
92
int red_killed = 0,blue_killed=0,yellow_killed=0;
93
 
94
/* Useful colours*/
95
int  GREEN1         =   2;  
96
int  BLACK1         =   0;    
97
int  RED1           =   4;  
98
int  BLUE1          =   1;  
99
int  LIGHTRED1      =  12;  
100
int  YELLOW1        =  14;
101
int  WHITE1         =  15;
102
 
103