29.12.2012 Views

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

If the module is a device driver or filter, then it was assigned a Device Control Block<br />

when the driver or filter was invoked with the SET command. <strong>The</strong> SET command passes a<br />

pointer <strong>to</strong> this DCB in register pair DE when the initializing program first executes. It<br />

is the responsibility of the initializing program <strong>to</strong> load the DCB pointer in<strong>to</strong> the 2-byte<br />

MODDCB s<strong>to</strong>rage field. <strong>The</strong> system requires this pointer for proper operation of its<br />

character I/O device chains.<br />

<strong>The</strong> last 2-byte field is loaded with a binary zero. It's use is reserved by the operating<br />

system. You may conveniently use the memory region after this address for the s<strong>to</strong>rage of<br />

any data. Thus, the pointer returned from a successful @GTMOD search for the module will<br />

be easily used <strong>to</strong> index the data area.<br />

8.6 INTERRUPT TASK PROCESSOR INTERFACING<br />

<strong>The</strong> operating system is designed <strong>to</strong> function on hardware that can provide a maskable<br />

interrupt (mode 1). This interrupt can be generated either by a standard Clock <strong>Tim</strong>er Chip<br />

(CTC) or it can be derived by other clocking methods (synchronized <strong>to</strong> the AC line<br />

frequency or decoded from some other frequency genera<strong>to</strong>r). An operating system Task<br />

Processor (TP) manages this interrupt <strong>to</strong> perform background tasks neccessary <strong>to</strong> perform<br />

specific functions of the DOS (such as the time clock where a hardware clock is not<br />

provided, blinking cursor where a CRTC blinking cursor is not provided, etc.).<br />

<strong>The</strong> TP provides twelve individual TASK SLOTS that are executed on a "time-sharing" basis.<br />

<strong>The</strong> interrupt rate is software divided in<strong>to</strong> three different timing groups spread across<br />

the task slots. One of these task slots is considered "high priority" and functions<br />

approximately 60 times a second (the exact time period depends on the interrupt rate<br />

provided). Three are considered "medium priority" and execute 30 times a second. <strong>The</strong><br />

remaining eight are considered "low priority" and execute at a rate of 30/8 times a<br />

second (or 15 times every four seconds). <strong>The</strong> task task slots are numbered 0-11 with 0-7<br />

being "low priority" tasks, 8-10 being "medium priority" tasks, and 11 being a "high<br />

priority" task.<br />

<strong>The</strong> DOS maintains a Task Control Block Vec<strong>to</strong>r Table (TCBVT) which contains 12 vec<strong>to</strong>rs -<br />

one for each of the 12 possible task slots numbered from zero through eleven. Five system<br />

SuperVisor Calls that manage the task vec<strong>to</strong>rs are provided. <strong>The</strong>se and their functions<br />

are:<br />

@CKTSK = Check if a task slot is unused or active<br />

@ADTSK = Add a task <strong>to</strong> the TCBVT<br />

@RMTSK = Remove a task from the TCBVT<br />

@KLTSK = Remove the currently executing task<br />

@RPTSK = Replace the TCB address for the current task<br />

<strong>The</strong> next point must be completely unders<strong>to</strong>od since it has caused confusion <strong>to</strong> many<br />

attempting <strong>to</strong> learn how <strong>to</strong> interface <strong>to</strong> the TP. <strong>The</strong> Task Control Block Vec<strong>to</strong>r Table<br />

(TCBVT) contains vec<strong>to</strong>r pointers. <strong>The</strong> TCBVT vec<strong>to</strong>rs POINT TO A 16-BIT LOCATION IN MEMORY<br />

WHICH CONTAINS THE ADDRESS OF THE SERVICING ROUTINE. Thus, the tasks themselves are twice<br />

indirectly addressed (those programmers familiar with C will observe that the TCBVT is an<br />

array of pointers <strong>to</strong> pointers). Make sure you keep this in mind! When you program an<br />

interrupt service routine, the entry point of the routine needs <strong>to</strong> be s<strong>to</strong>red in memory.<br />

If we call this s<strong>to</strong>rage location the beginning of a Task Control Block (TCB), the reason<br />

for the indirect method of addressing interrupt tasks will become more clear. Let's<br />

illustrate an example TCB.<br />

MYTCB DW MYTASK<br />

COUNTER DB 15<br />

TEMPY DS 1<br />

MYTASK RET<br />

8-15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!