XINU
clkhandler.c
Go to the documentation of this file.
1 /* clkhandler.c - clkhandler */
2 
3 #include <xinu.h>
4 
5 /*-----------------------------------------------------------------------
6  * clkhandler - high level clock interrupt handler
7  *-----------------------------------------------------------------------
8  */
9 void clkhandler()
10 {
11 
12 
13  volatile struct am335x_timer1ms *csrptr =
14  (struct am335x_timer1ms *)0x44E31000;
15  /* Set csrptr to address of timer CSR */
16 
17  /* If there is no interrupt, return */
18 
19  if((csrptr->tisr & AM335X_TIMER1MS_TISR_OVF_IT_FLAG) == 0) {
20  return;
21  }
22 
23  /* Acknowledge the interrupt */
24 
26 
27  /* Increment 1000ms counter */
28 
29  count1000++;
30 
31  /* After 1 sec, increment clktime */
32 
33  if(count1000 >= 1000) {
34  clktime++;
35  count1000 = 0;
36  }
37 
38  /* check if sleep queue is empty */
39 
40  if(!isempty(sleepq)) {
41 
42  /* sleepq nonempty, decrement the key of */
43  /* topmost process on sleepq */
44 
45  if((--queuetab[firstid(sleepq)].qkey) == 0) {
46 
47  wakeup();
48  }
49  }
50 
51  /* Decrement the preemption counter */
52  /* Reschedule if necessary */
53 
54  if((--preempt) == 0) {
55  preempt = QUANTUM;
56  resched();
57  }
58 }
struct qentry queuetab[]
Definition: queue.c:45
uint32 tisr
割り込みステータスレジスタ
Definition: clock.h:34
qid16 sleepq
スリープ中のプロセスキュー
Definition: clkinit.c:7
全てのシステムヘッダファイルをインクルードする。
void wakeup(void)
Definition: wakeup.c:9
uint32 count1000
最後のクロックチックからのミリ秒
Definition: clkinit.c:6
#define isempty(q)
リストが空かどうかを返す。
Definition: queue.h:89
#define QUANTUM
ミリ秒単位のタイムスライス
Definition: kernel.h:93
#define firstid(q)
リストの最初のプロセスのIDを返す。
Definition: queue.h:70
void clkhandler()
Definition: clkhandler.c:9
#define AM335X_TIMER1MS_TISR_OVF_IT_FLAG
TCRRオーバーフロー発生時の設定
Definition: clock.h:80
void resched(void)
最優先の適切なプロセスにCPU実行権を渡す。
Definition: resched.c:22
uint32 preempt
プリエンプションカウンタ
Definition: clkinit.c:9
uint32 clktime
起動してからの現在の時間[s]
Definition: clkinit.c:5
AM335X SOCのタイマー(1[ms])
Definition: clock.h:23