home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frostbyte's 1980s DOS Shareware Collection
/
floppyshareware.zip
/
floppyshareware
/
DOOG
/
CTASK.ZIP
/
TSKLOCAL.H
< prev
next >
Wrap
C/C++ Source or Header
|
1989-12-20
|
7KB
|
224 lines
/*
--- Version 2.0 89-12-15 15:08 ---
TSKLOCAL.H - CTask - Internal definitions and prototypes.
Public Domain Software written by
Thomas Wagner
Patschkauer Weg 31
D-1000 Berlin 33
West Germany
CAUTION: Routines defined here may *not* be called from outside the
CTask kernel.
*/
/*
struct task_stack describes the contents of a tasks stack after creation.
The first 2 words are the registers to be restored by the scheduler.
Only the segment register is significant initially.
The next three words contain the function address plus the CPU flags
setup as if an interrupt had occurred at the function's entry address.
This setup is the same as the stack of an interrupted task after
scheduling.
The following two words contain a dummy return address, which points
to the routine "killretn". Thus, if the task main function should ever
return, the task is automatically killed. The last doubleword is
used for the optional argument to the task.
*/
struct task_stack {
word r_bx;
word r_ds;
funcptr retn;
word r_flags;
funcptr dummyret;
farptr arg;
};
#if (CLOCK_MSEC)
extern dword near tsk_timeout (dword tout);
#else
#define tsk_timeout(tout) tout
#endif
extern void near tsk_enqueue (queheadptr head, queptr elem);
extern void near tsk_dequeue (queptr elem);
extern void near tsk_enqtimer (queptr elem, dword tout);
extern void near tsk_deqtimer (queptr elem);
extern void near tsk_putqueue (queheadptr q, queptr elem);
extern void near tsk_install_timer (word divisor, word sys_ticks);
extern void near tsk_remove_timer (void);
extern void near tsk_chain_timer (void);
extern void near tsk_install_dos (void);
extern void near tsk_remove_dos (void);
extern void near tsk_install_kbd (void);
extern void near tsk_remove_kbd (void);
extern void near tsk_install_bios (void);
extern void near tsk_remove_bios (void);
extern void near tsk_install_int17 (void);
extern void near tsk_remove_int17 (void);
extern int near tsk_remove_group (gcbptr group, int freemem);
extern void near tsk_free_mem (word psp);
extern void far tsk_emergency_exit (void);
#if (TURBO)
#define tsk_dseg() _DS
#else
extern word near tsk_dseg (void);
#endif
extern word near tsk_flags (void);
extern void near tsk_runable (tcbptr task);
extern void near tsk_runable_all (queheadptr que);
extern void near tsk_wait (queheadptr que, dword timeout);
extern void near tsk_kill (tcbptr task);
extern void near tsk_kill_queue (queheadptr que);
extern void near tsk_init_qhead (queheadptr head);
#if (TSK_NAMED)
extern void near tsk_copy_name (nameptr elem, byteptr name);
extern void near tsk_add_name (nameptr elem, byteptr name, byte kind,
farptr strucp);
extern void near tsk_del_name (nameptr elem);
#endif
extern void far tsk_int8 (void);
extern void far tsk_timer (void);
/* --------------------------------------------------------------------- */
/*
The global variable block
The task queues:
timer_queue All tasks using a timeout, either through "t_delay"
or an event wait, are enqueued into "timer_queue",
using the "timerq" link.
eligible_queue All tasks eligible for running are enqueued
in "eligible_queue".
current_task Points to the current running task's tcb.
System flags:
preempt is zero if preemption is allowed.
Bit 0 is set if preemption has been disabled globally.
Bit 1 is set for temporary disabling preemption.
Temporary preemption is automatically removed by the
scheduler.
pretick is nonzero if a schedule request from an
interrupt handler was rejected due to
tsk_preempt nonzero. This allows an immediate
scheduling whenever tsk_preempt is set to 0.
var_prior Can be set nonzero to enable variable priority.
Variable priority will increase the priority of
eligible tasks on each scheduler call while they
are waiting to be executed, so that low priority
tasks will slowly get to the head of the eligible
queue, getting a chance to be run. With variable
priority off, lower priority tasks will never be
executed while higher priority tasks are eligible.
System variables:
in_sched is used in the scheduler only. It is nonzero while
the scheduler is active.
tick_factor is undefined if CLOCK_MSEC is 0, otherwise it
contains the clock tick factor in milliseconds.
ticks_per_sec is the approximate number of ticks per second
expressed as an unsigned integer.
l_swap is set by tskdos and used by the scheduler.
It contains the length of the DOS swap area.
(DOS only)
dos_vars contains the address of the DOS swap area.
(DOS only)
curr_group is the current running task's group
groups is the group list head. It points to the most
recently created group.
name_list is only present if TSK_NAMED is nonzero, and
if there are no groups.
It is the head of the name queue.
*/
#define VERSTRING "CTask12" /* 7 Chars + zero */
typedef struct {
char id [8]; /* contains 'VERSTRING' */
tcbptr current_task;
queue_head eligible_queue;
queue_head timer_queue;
queue_head watch_queue;
byte preempt;
byte pretick;
byte var_prior;
byte in_sched;
double tick_factor;
word ticks_per_sec;
tick_ptr ticker_chain;
#if (DOS)
word l_swap;
dword dos_vars;
#endif
#if (GROUPS)
gcbptr curr_group;
gcb group;
#else
#if (TSK_NAMED)
namerec name_list;
#endif
#endif
} ctask_globvars;
typedef ctask_globvars far *globvarptr;
extern counter _Near tsk_timer_counter;
#if (DOS)
extern counter _Near tsk_int8_counter;
#endif
typedef void (cdecl far *funcptr_void)(void);
typedef void (cdecl far *funcptr_void_fp)(farptr);
#if (SINGLE_DATA)
extern ctask_globvars _Near tsk_glob_rec;
#else
extern globvarptr _Near tsk_global;
extern globvarptr near tsk_resident (void);
#endif
#if (SINGLE_DATA)
#define GLOBDATA tsk_glob_rec.
#else
#define GLOBDATA tsk_global->
#endif