⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unlinkc2.c

📁 实时嵌入式操作系统内部关于定时器的应用
💻 C
字号:
/*
 * timer/unlink_c2.c
 *
 * Copyright (C) SGS-THOMSON Microelectronics Ltd. 1998
 *
 * Unlink a task from a timer.
 */

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#include "task.h"
#include "os20i.h"

void timer_unlink(tdesc_t* tdesc)
{
  descriptor_t wptr, front, pred;

  /* We don't want to have to merge two queues, so prevent any
   * other tasks running while we look at the queue.
   */
  task_lock();

  __asm {
    ldab 1, 0x80000000;
    swaptimer;
    dup;
    st front;
  }

  for ( wptr = front;
	wptr != (descriptor_t)QUEUE_EMPTY; 
	wptr = (descriptor_t)wptr[PW_TLINK])
  {
    if ((tdesc_t*)wptr[PW_TDESC] == tdesc) {
      /* Found it */
      if (wptr == front) {
	front = (descriptor_t)wptr[PW_TLINK];
      } else {
	pred[PW_TLINK] = wptr[PW_TLINK];
      }
      break; /* Can only be on a timer once */
    }
    pred = wptr;
  }

  __asm {
    ldab 1, front;
    swaptimer;
  }

  task_unlock();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -