 
 
 
 
 
   
/* スレッドオブジェクト */
pthread_t task;
int init_module(void){
  /* スレッド属性オブジェクト */
  pthread_attr_t attr;
  /* スケジューリングパラメータ */
  struct sched_param sched_param;
  /* スレッド属性オブジェクトattrの初期化 */
  pthread_attr_init (&attr);
  /* スケジューリングパラメータにプライオリティ値を設定 */
  sched_param.sched_priority = 4; 
  /* プライオリティ値をスレッド属性オブジェクトに設定する */
  pthread_attr_setschedparam (&attr, &sched_param);
            
  /* thread_code という関数をスレッドとして生成
     最後の(void *)1 はスレッドに渡す引数.*/
  ret = pthread_create (&task, &attr, 
                        thread_code, (void *)1);
}
void *thread_code(void t){
  /* 実行周期を第三引数でナノ秒単位で指定 */
  pthread_mask_periodic(pthread_self(), gethrtime, 
                        500000)
  while (done){
    /* 次の実行周期まで待つ.
       実行周期はpthread_make_periodic_np で指定する.*/
    pthread_wait_np()
    /* 周期実行を一次停止する.*/
    pthread_suspend_np(pthread_self())
  }
}
int my_handler(unsigned int fifo){
  /* pthread_wait_np() しているスレッドを起こす.*/
   pthread_wakeup_np()
}