SECTION 6
Conversions and Interfaces
6-24 PEN*KEY
R
6200/6300 Hand-Held Computer Programmer’s Reference Guide
Multi-tasking Services
Subfunction 1, of Interrupt 15h, is traditionally reserved for cassette interface
control. The 4000 Series BIOS replaced it with a set of multiĆtasking services
informally referred to as INT 15. 4000API.EXE provides this same set of
services for 4000 Series multiĆtasking applications. These services are
nonstandard, but 4000API.EXE may be executed on any PC to provide these
services.
Tasks and Scheduling
INT 15 manipulates two linked lists of task contexts, the ready list and the
pended list. The pended list contains tasks that are waiting for some event. A
task moves from this list to the ready list when its timeout expires or when the
event on which it is waiting occurs.
The ready list is a queue of tasks that are scheduled for execution. Tasks enter
at the tail of the queue and are activated from the head. All tasks have the
same priority and are executed roundĆrobin.
The currently executing task is not on either list. It moves to the pended list if it
issues wait any," pend on mailbox, pend on queue, or delay with timeout
commands. The current task moves to the ready list if its time slice expires
(preemptive only) or if it voluntarily gives up control by issuing a delay with 0
timeout.
Int15 defaults to cooperative multiĆtasking. That means that every task must
occasionally give up control of the processor to let other tasks execute.
By enabling timeĆslicing, int15 becomes a preemptive multiĆtasker. Each task in
the ready list is allocated a 55Ćmillisecond time slice. If the currently executing
task exhausts its time slice before relinquishing control of the processor, it is
forcibly swapped out and placed on the tail of the ready list.
Timeouts
Functions that require timeout values as input expect the register pair DXCX to
contain the number of milliseconds before timeout. The timer resolution is the
same as the system timer ticks: 55 milliseconds. A task that requests a
1 millisecond time out is guaranteed to wait at least 1 millisecond and possibly
up to 55 milliseconds.
Resource Arbitration and Task Communication
Most of the BIOS device handling services are not reentrant. Tasks cannot share
the same device (the display, for example) without an arbitrator that makes sure
that both tasks do not try to use the BIOS at the same time. This resource
arbitration can be handled via the intertask communication provided by
mailboxes and queues.
Mailboxes
A mailbox is a 4Ćbyte variable used for messageĆpassing between tasks. A
mailbox is empty if it contains 0; otherwise, it contains a message. A task can
perform three mailbox operations: post, pend, and accept.
Posting is the action of placing a 4Ćbyte message into a mailbox. Posting to a
mailbox that is not empty overlays the message that was in the mailbox.
When a task pends on an empty mailbox, the task is moved to the pended list
until another task posts a message to the mailbox. When a task pends on a
mailbox with a message in it, the pend request returns without pending.
A task can accept from a mailbox if it wants to retrieve a message from the box
without pending. An accept from an empty box returns 0.
6. Conversions and
Interfaces