D
evices are the mechanism by which an application running in the context of a
MASCOT Machine integrates with and accesses services supplied by the underlying
host hardware and software. Devices in MOJO have a factory behavior, ie. they
manufacture and maintain device instances. Opening a device results in the caller
being handed a pair of channels (read and write) by which he may access a specific
instance of a device.
As with other MASCOT entities, device instances are named. The syntax of the open is
as follows:
Object[] open( String deviceName, String deviceInstanceName );
DeviceName is what it says, the device’s MASCOT name. DeviceInstanceName is the
local name by which the caller refers to the instance and can be used as an argument
to resolve(). It is thus possible for activities to share access to a device instance by
name; the first open creates the instance, subsequent opens will receive references to
the channel pair associated with the named instance. The device code manages and
maintains instance names and their associated incarnations.
MOJO devices present some unique coding challenges because, unlike other MASCOT
subsystems, they are conceptually a mix of system and application specific code. As
an aid to writing device handlers, MOJO implements the idea of worker activities which
allow the definition and incarnation of generic system activities. Workers are not part
of the normal SET syntax; developers can use them to implement system activities
that essentially extend the functionality of the MASCOT machine. In many ways,
workers analogous to operating system drivers.
Worker activities are MASCOT activities that do not have a specific subsystem
container and may be incarnated within any subsystem context. Developers can use