GadgetSeed  0.9.6
dispatch.c
[詳解]
1 /** @file
2  @brief エミュレータ用タスク制御
3 
4  @date 2012.12.08
5  @author Takashi SHUDO
6 */
7 
8 #include "sysconfig.h"
9 #include "task/task.h"
10 #include "tkprintf.h"
11 
12 #include <stdio.h>
13 
14 //#define DEBUG
15 #ifdef DEBUG
16 #define DPPRINTF printf
17 #else
18 #define DPPRINTF(x, ...)
19 #endif
20 
21 #ifdef DEBUG
22 static int dip_cnt = 0;
23 #endif
24 
25 void dispatch(struct st_tcb *otcb, struct st_tcb *tcb)
26 {
27  DPPRINTF("dispatch %d \"%s\" -> \"%s\"\n", dip_cnt,
28  otcb->name, tcb->name);
29 
30  if(otcb != tcb) {
31 #ifdef DEBUG
32  dip_cnt ++;
33 #endif
34  unlock_timer();
35  swapcontext(&(otcb->ctx.uc), &(tcb->ctx.uc));
36  }
37 }
カーネル用機能限定printf
char name[TASK_NAME_LEN+1]
タスク名
Definition: tcb.h:39
タスク制御
struct st_context ctx
CPUコンテキスト(CPUアーキテクチャ依存)
Definition: tcb.h:43
タスクコンテキスト
Definition: tcb.h:32