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

📄 task.h

📁 在ARM7和UC/OSII的平台上实现了GPS自动报站的功能,涉及GPS模块LEA_4S的驱动,位置速寻算法,语音芯片ISD4004的录放音驱动,LED页面管理等等.从启动代码到操作系统的移植以及到业
💻 H
字号:
/*
 * FILENAME: task.h
 *
 * Copyright 1999- 2000 By InterNiche Technologies Inc. All rights reserved
 *
 * This file contains definitions for the multi-tasking package.
 *
 * MODULE: TCP
 *
 *
 * PORTABLE: yes
 */

/* Additional Copyrights: */
/* Portions Copyright 1983 by the Massachusetts Institute of Technology */


#ifndef _TASK_H_
#define  _TASK_H_    1


/* Pattern written into the stack area */
#ifdef   SEG16_16
#define  GUARDWORD   0x5354      /* hex for ST */
#else
#define  GUARDWORD   0x53544143  /* hex for STAC */
#endif

typedef  int   stack_t;       /* type of data in task stacks */

/* NOTE: if you change this, be sure to change all the assebly which 
 * depends on it too!!!
 */
struct task
{ 
   struct task *  tk_next;    /* pointer to next task */
   stack_t *   tk_fp;         /* task's current frame ptr */
   char *      tk_name;       /* the task's name */
   int         tk_flags;      /* flag set if task is scheduled */
   u_long      tk_count;      /* number of wakeups */
   stack_t *   tk_guard;      /* pointer to lowest guardword */
   unsigned    tk_size;       /* stack size */
   stack_t *   tk_stack;      /* base of task's stack */
   void *      tk_event;      /* event to wake blocked task */
   u_long      tk_waketick;   /* tick to wake up sleeping task */
};

typedef struct task task;

/* tk_flags bits */
#define  TF_AWAKE       0x0001   /* task is ready to run */
#define  TF_MAIN        0x0002   /* task is using system stack */

extern   struct task *  tk_cur;  /* currently running task */

extern   unsigned TDEBUG;        /* tasking debugging */
extern   u_long   tk_wakeups;

/* entry points to tasking system */
task *   tk_init(stack_t * base, int st_size);
task *   tk_new(task*, int(*)(int), int, char*, int);    /* fork a new task */
void     tk_block(void);            /* switch to next runnable task */
void     tk_exit(void);             /* kill & delete current task */ 
void     tk_kill(task * tk_to_die); /* mark any task for death */
void     tk_wake(task * tk);        /* mark a task to run */
void     tk_sleep(long ticks);      /* sleep for number of ticks */
void     tk_ev_block(void * event); /* block until event occurs */
void     tk_ev_wake(void * event);  /* wake tasks waiting for event */


/* non-portable task utility routines */
stack_t * tk_frame(task *, int(*)(int), unsigned);
void      tk_switch(task *);        /* run the next task */
stack_t * tk_getsp(void);     /* get current stack pointer */

/* the yield() macro */
#define  tk_next()      {  tk_wake(tk_cur);  tk_block(); }

#endif   /* _TASK_H_ */


⌨️ 快捷键说明

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