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

📄 task.cc

📁 VRTX 商用嵌入式实时操作系统
💻 CC
字号:
/***************************************************************************
*
*		Copyright (c) 1993 READY SYSTEMS CORPORATION.
*
*	All rights reserved. READY SYSTEMS' source code is an unpublished
*	work and the use of a copyright notice does not imply otherwise.
*	This source code contains confidential, trade secret material of
*	READY SYSTEMS. Any attempt or participation in deciphering, decoding,
*	reverse engineering or in any way altering the source code is
*	strictly prohibited, unless the prior written consent of
*	READY SYSTEMS is obtained.
*
*
*	Module Name:		task.cc
*
*	Identification:		@(#) 1.12 task.cc
*
*	Date:			2/22/94  14:43:16
*
****************************************************************************
*/

#include "task.h"

Task::Task (void (*entry_point) (), int priority, int id)
{
  int err;
  if (id == -1)
    tid = sc_tcreate (entry_point, id, priority, &err);
  else {
    sc_tcreate (entry_point, id, priority, &err);
    tid = id;
  }
}

Task::~Task ()
{
  int err;
  if (tid != 0)
    sc_tdelete (tid, 0, &err);
}

void
Task::suspend ()
{
  int err;
  if (tid != 0)
    sc_tsuspend (tid, 0, &err);
}

void
Task::resume ()
{
  int err;
  if (tid != 0)
    sc_tsuspend (tid, 0, &err);
}

void
Task::delay (unsigned long ticks)
{
  sc_delay(ticks);
}

void
Task::delay (struct timespec seconds)
{
  int err;
  sc_adelay(seconds, &err);
}

void
Task::exit ()
{
  int err;
  sc_tdelete (0, 0, &err);
}

void
Task::yield ()
{
  sc_delay(0);
}

int
Task::id ()
{
  return tid;
}

TCB *
Task::tcb ()
{
  int err, info[3];
  if (tid != 0)
    return sc_tinquiry (info, tid, &err);
  else
    return (TCB *) 0;
}

int
Task::priority ()
{
  int err, info[3];
  if (tid != 0) {
    (void) sc_tinquiry (info, tid, &err);
    return info[1];
  } else
    return 0;
}

int
Task::status ()
{
  int err, info[3];
  if (tid != 0) {
    (void) sc_tinquiry (info, tid, &err);
    return info[2];
  } else
    return 0;
}

void
Task::set_priority (int priority)
{
  int err;
  if (tid != 0)
    sc_tpriority (tid, priority, &err);
}

int
Task::this_id ()
{
  int err, info[3];
  (void) sc_tinquiry (info, 0, &err);
  return info[0];
}

⌨️ 快捷键说明

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