📄 tsk.h
字号:
qelem_pri pri;
dword ticks;
} el;
} queue;
typedef struct {
volatile queptr first;
volatile queptr last;
byte kind;
} queue_head;
typedef queue_head far *queheadptr;
typedef struct name_rec far *nameptr;
struct name_rec {
queue_head list; /* Name list */
farptr strucp; /* Top of structure pointer */
char name [NAMELENGTH];
};
typedef struct name_rec namerec;
typedef struct tcb_rec far *tcbptr;
typedef tcbptr far *tqueptr;
typedef struct tlink_rec far *tlinkptr;
struct telem_memwatch {
wordptr address;
word mask;
word compare;
};
struct telem_portwatch {
word port;
word mask;
word compare;
byte in_word;
};
typedef struct {
byte mask;
byte compare;
} kbflag;
struct telem_hotkey {
kbflag flag1;
kbflag flag2;
kbflag flag3;
byte scancode;
};
struct telem_timeout {
dword reload; /* Timeout counter reload value */
};
typedef struct tlink_rec tlink;
struct tlink_rec {
queue link;
tlinkptr next; /* for exclusive use by timer task */
farptr strucp; /* Pointer to control structure */
dword user_parm; /* User defined parameter */
#if (GROUPS)
queue_head chain; /* Timer control block chain */
#endif
union {
struct telem_memwatch mem;
struct telem_portwatch port;
struct telem_timeout time;
struct telem_hotkey key;
} elem;
byte elkind; /* Kind of watch element */
byte struckind; /* Kind of structure pointed to */
byte flags; /* Flags */
};
typedef struct group_rec gcb;
typedef gcb far *gcbptr;
struct tcb_rec {
queue cqueue; /* Current queue link */
queheadptr qhead; /* Queue head pointer */
byteptr stkbot; /* Task stack bottom */
volatile byte state; /* Task state */
byte flags; /* Task flags */
byteptr stack; /* Task register save area */
word t_ax;
word t_cx;
word t_dx;
word t_si;
word t_di;
word t_bp;
word t_es;
word t_ds;
tlink timerq; /* Timer queue link */
volatile farptr retptr; /* Event return pointer */
volatile int retsize; /* Return buffer size for pipes */
funcptr save_func;
funcptr rest_func;
farptr user_ptr; /* User defined parameter */
#if (GROUPS)
gcbptr group; /* Current Group control block pointer */
gcbptr homegroup; /* Creating Group control block pointer */
#endif
#if (DOS)
funcptr sched_ent_func; /* Used by DOS handler */
volatile byte indos; /* Flag for use by DOS handler */
volatile byte t_new; /* New task flag for DOS save */
word base_psp; /* Base PSP segment */
dword psp_sssp; /* Saved PSP SS/SP value */
byte swap_area [DOSSWAPSIZE]; /* DOS vars save area */
#endif
#if (TSK_NAMED)
namerec name;
#endif
#if (EMS)
byte ems_map [EMS_SAVE_SIZE];
#endif
#if (NDP)
ndpsave_t ndpsave; /* 80x87 save area */
#endif
};
typedef struct tcb_rec tcb;
struct group_rec {
gcbptr home; /* Home group */
gcbptr level; /* Next group on level */
gcbptr branch; /* Next group on higher level */
tcbptr creator; /* Task that created this group */
dword exit_addr; /* Exit address */
word create_psp; /* Base PSP addr of this group */
word save_psp; /* PSP addr of this group's creator */
dword save_sssp; /* SS/SP from base PSP of creator */
namerec namelist; /* List of structures in this group */
tcbptr main_ptr; /* Main task for this group */
callchainptr remove; /* Int handler remove chain */
queue_head telem_list; /* Timer element chain */
queue_head ticker_list; /* Timer element chain */
#if (TSK_DYNAMIC)
farptr (Globalfunc *palloc)(word); /* alloc function ptr */
farptr (Globalfunc *pfree)(farptr); /* free function ptr */
#endif
};
typedef struct {
queue_head wait_set;
queue_head wait_clear;
volatile int state;
#if (TSK_DYNAMIC)
byte flags;
#endif
#if (TSK_NAMED)
namerec name;
#endif
} flag;
typedef flag far *flagptr;
typedef struct {
queue_head wait_set;
queue_head wait_clear;
volatile dword state;
#if (TSK_DYNAMIC)
byte flags;
#endif
#if (TSK_NAMED)
namerec name;
#endif
} counter;
typedef counter far *counterptr;
typedef struct {
queue_head waiting;
volatile tcbptr owner;
volatile word count;
#if (TSK_DYNAMIC)
byte flags;
#endif
#if (TSK_NAMED)
namerec name;
#endif
} resource;
typedef resource far *resourceptr;
typedef struct msg_header far *msgptr;
struct msg_header {
volatile msgptr next;
};
typedef struct {
queue_head waiting;
msgptr mail_first;
msgptr mail_last;
#if (TSK_DYNAMIC)
byte flags;
#endif
#if (TSK_NAMED)
namerec name;
#endif
} mailbox;
typedef mailbox far *mailboxptr;
typedef struct {
queue_head wait_read;
queue_head wait_write;
queue_head wait_clear;
word bufsize;
volatile word filled;
volatile word inptr;
volatile word outptr;
byteptr contents;
#if (TSK_DYNAMIC)
byte flags;
#endif
#if (TSK_NAMED)
namerec name;
#endif
} pipe;
typedef pipe far *pipeptr;
typedef struct {
queue_head wait_read;
queue_head wait_write;
queue_head wait_clear;
word bufsize;
volatile word filled;
volatile word inptr;
volatile word outptr;
wordptr wcontents;
#if (TSK_DYNAMIC)
byte flags;
#endif
#if (TSK_NAMED)
namerec name;
#endif
} wpipe;
typedef wpipe far *wpipeptr;
typedef struct {
resource buf_write;
resource buf_read;
wpipe pip;
volatile word msgcnt;
#if (TSK_DYNAMIC)
byte flags;
#endif
#if (TSK_NAMED)
namerec name;
#endif
} buffer;
typedef buffer far *bufferptr;
typedef struct ticker_rec far *tick_ptr;
typedef struct ticker_rec {
volatile tick_ptr next;
volatile dword ticks;
#if (GROUPS)
queue_head chain;
#endif
#if (TSK_DYNAMIC)
byte flags;
#endif
} ticker;
/* --------------------------------------------------------------------- */
#if TSK_NAMEPAR
#define TN(name_def) ,name_def
#else
#define TN(name_def)
#endif
#define CRITICAL int crit_intsav
#define C_ENTER crit_intsav = tsk_dis_int()
#define C_LEAVE tsk_ena_int (crit_intsav)
/* module tskmain */
extern int ctask_active;
extern int Globalfunc install_tasker (byte varpri, int speedup, word flags
TN(byteptr name));
extern void Globalfunc remove_tasker (void);
/* module tskutil */
extern void Globalfunc preempt_off (void);
extern void Globalfunc preempt_on (void);
extern void Globalfunc tsk_ena_preempt (void);
extern void Globalfunc tsk_dis_preempt (void);
extern int Globalfunc t_delay (dword ticks);
extern callchainptr Globalfunc chain_removefunc (funcptr_ccp func, callchainptr chain, farptr user_ptr);
extern void Globalfunc unchain_removefunc (callchainptr chain);
extern word Globalfunc ticks_per_sec (void);
/* module tskasm */
extern void Globalfunc schedule (void);
extern void Globalfunc c_schedule (void);
extern void Globalfunc yield (void);
extern int Globalfunc tsk_dis_int (void);
extern void Globalfunc tsk_ena_int (int);
extern void Globalfunc tsk_nop (void);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -