public
Description: A small OS for high reliability low memory embeded applications
Clone URL: git://github.com/andrewguy9/kernelpanic.git
Fixed bug in test4. Panic now passing all regression tests.
Andrew Thomson (author)
Wed Sep 03 01:40:53 -0700 2008
commit  d4c906893cd782a5637e93c5ace2c26bd44decaa
tree    058246150c2c339b36159b75f4ea5902481ff03f
parent  20b6a4001bff2b2bb21859ff4df83a556b129288
...
31
32
33
34
35
36
 
 
 
37
38
39
...
41
42
43
44
 
45
46
47
...
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
 
79
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
82
83
84
85
86
87
88
89
...
31
32
33
 
 
 
34
35
36
37
38
39
...
41
42
43
 
44
45
46
47
...
51
52
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
55
 
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
 
 
 
 
 
88
89
90
0
@@ -31,9 +31,9 @@ char SleeperStack[STACK_SIZE];
0
 struct POST_HANDLER_OBJECT Timer;
0
 
0
 //Define Global Flags
0
-BOOL TimerFlag;
0
-BOOL ThreadFlag;
0
-COUNT TimerCycles;
0
+BOOL TimerFlag;//Is TRUE when we have the timer registered. (approx)
0
+BOOL ThreadFlag;//Is TRUE when sleeping, FALSE when awake (approx)
0
+COUNT TimerCycles;//Times we have run the test.
0
 
0
 //TimerFunction
0
 void TimerHandler( void * Argument )
0
@@ -41,7 +41,7 @@ void TimerHandler( void * Argument )
0
   //Clear Flag
0
   TimerFlag = FALSE;
0
   //Check to see if thread is sleeping
0
- if( ThreadFlag == FALSE )
0
+ if( ! ThreadFlag )
0
     KernelPanic( );
0
 }
0
 
0
@@ -51,39 +51,40 @@ void SleeperMain()
0
   INDEX cur=0;
0
   while(1)
0
   {
0
- //Register Timer
0
- InterruptDisable();
0
- TimerFlag = TRUE;
0
- InterruptEnable();
0
-
0
- TimerRegister(
0
- & Timer,
0
- Sequence[cur] - 1,
0
- TimerHandler,
0
- NULL);
0
-
0
- //Go to sleep
0
- InterruptDisable();
0
- ThreadFlag = TRUE;
0
- InterruptEnable();
0
-
0
- Sleep( Sequence[cur] );
0
-
0
- InterruptDisable();
0
- ThreadFlag = FALSE;
0
- InterruptEnable();
0
-
0
- //Check to see timer fired
0
- InterruptDisable();
0
- if( TimerFlag != FALSE )
0
+ for( cur = 0; cur < SEQUENCE_LENGTH; cur++)
0
     {
0
- KernelPanic( );
0
+ //Register Timer: The timer should run before we wake.
0
+ InterruptDisable();
0
+ TimerFlag = TRUE;
0
+ InterruptEnable();
0
+ TimerRegister(
0
+ & Timer,
0
+ Sequence[cur] - 1,
0
+ TimerHandler,
0
+ NULL);
0
+
0
+ //Go to sleep:
0
+ InterruptDisable();
0
+ ThreadFlag = TRUE;
0
+ InterruptEnable();
0
+ Sleep( Sequence[cur] );
0
+
0
+ //Now that we are awake, Clear the thread flag.
0
+ InterruptDisable();
0
+ ThreadFlag = FALSE;
0
+ InterruptEnable();
0
+
0
+ //Check to see if the timer fired before we woke.
0
+ InterruptDisable();
0
+ if( TimerFlag )
0
+ {
0
+ KernelPanic( );
0
+ }
0
+ InterruptEnable();
0
+
0
+ //Increase our iteration count.
0
+ TimerCycles++;
0
     }
0
- InterruptEnable();
0
-
0
- //Move to next sequence
0
- cur = cur+1 % SEQUENCE_LENGTH;
0
- TimerCycles++;
0
   }
0
 }
0
 

Comments

    No one has commented yet.