Method and system for providing a state oriented and event driven environment5721920Abstract The present invention discloses a method and system for providing a Finite State Machine (FSM) which is implemented within a telecommunications application program with the ability to transition from one state to another. The control of the transition being implemented by an Input/Output (I/O) Event Manager subsystem of a preemptive multi-tasking operating system. Additionally, the present invention discloses a method and system for providing a FSM which is implemented within a telecommunications application program with event driven control of physical devices having input and output capabilities. The event driven control being implemented by the I/O Event Manager subsystem. Claims What is claimed is: Description BACKGROUND
TABLE I
______________________________________
void sta.fn1( )
/*The computer code which implements state 1 302 would
reside here. */
}
.
.
.
void sta. fn5( )
{
/*The computer code which implements state 5 308 would
reside here. */
}
______________________________________
.COPYRGT. 1993 Telefonaktiebolaget L M Ericsson
It should be noted that although the FSM 104 does not use nested FSMs, the preferred embodiment of the present invention provides support for the nesting of FSMs. Referring back to FIG. 2, the state oriented portion 225 allows a specified process within the OS 106 to transition from one state to another by manipulating an associated TCB data structure. The information required for the state oriented portion 225 to manipulate a specified TCB data structure can be acquired and stored in numerous ways. For example, in the preferred embodiment of the present invention, the required information is stored in a State Control Block (SCB) data structure and a State Vector Table (SVT) data structure. A predetermined number of SCB data structures are dynamically allocated (created) during the initialization of the I/O Event Manager 108. A linked list structure can be used to determine the locations of the dynamically allocated SCB data structures within the memory of an associated computing system. FIG. 3B is a block diagram illustrating such a link list (scb.sub.-- arry) data structure linking the dynamically allocated SCB data structures 326-328 within the I/O Event Manager 108 of FIG. 2 in the preferred embodiment of the present invention. The scb.sub.-- arry includes a header data structure 324 having pointers head 325 and tail 320 which indicate the location of the first SCB 326 and last SCB 328, respectively within the scb.sub.-- arry. An SVT data structure may be, for example, a single dimensional array comprising a plurality of elements. Each element within the array being used to store the physical address of a main state processing function. The storing of the physical addresses is sequenced so that the location of each element within the array has a one-to-one correspondence with a particular state of a specified FSM. For example, the SVT data structure for the FSM 104 of FIG. 1 is illustrated in C++ in Table II below.
TABLE II
______________________________________
SFV SVT› ! = {sta.sub.-- fn1, sta.sub.-- fn2, sta.sub.-- fn3, sta.sub.--
fn4, sta.sub.-- fn5}
______________________________________
.COPYRGT. 1993 Telefonaktiebolaget L M Ericsson
The five state variables sta.sub.-- fn1-sta.sub.-- fn5 within array SVT represent the physical locations (addresses) of state 1 302, state 2 304, state 3 306, state 4 310, and state 5 308, respectively of FSM 104 (FIG. 1). An example of a dynamically allocated SCB data structure according to preferred embodiment is illustrated in C++ in Table III below.
TABLE III
______________________________________
typedef struct
QUE.sub.-- MBS
link; /* SCB linked list structure*/
WORD scb.sub.-- id;
/* SCB ID */
WORD scb.sub.-- sts;
/* status */
WORD sta; /* current state */
WORD pre.sub.-- sta;
/* previous state */
WORD total.sub.-- sta;
/* total number of states */
WORD pid; /* process ID */
WORD *loc.sub.-- tos;
/* local top of stack */
WORD *us.sub.-- reg.sub.-- ptr;
/* user register block */
WORD *svt.sub.-- ptr;
/* state vector table */
}SCB
______________________________________
.COPYRGT. 1993 Telefonaktiebolaget L M Ericsson
The variable link (scb. link) is a component of the scb.sub.-- arry which interconnects the previously allocated list of SCBs together. The variable scb.sub.-- id (scb. scb.sub.-- id) identifies the SCB data structure within the scb.sub.-- arry. Variable scb.sub.-- sts (scb. scb.sub.-- sts) indicates whether the SCB is available for use. Variable sta (scb. sta) contains the current state of an associated FSM. The variable pre.sub.-- sta (scb. pre.sub.-- sta) contains the previous state of the FSM. The variable total.sub.-- sta (scb. total.sub.-- sta) indicates the total number of states within the FSM, and is used for accessing an SVT data structure associated with the FSM. Variable pid (scb. pid) identifies a process associated with the FSM. Variable loc.sub.-- tos (scb. loc.sub.-- tos) is a pointer to the local top of stack for the identified process. Variable us.sub.-- reg.sub.-- ptr (scb. us.sub.-- reg.sub.-- ptr) is a pointer to the user register block associated with the identified process. The variable svt.sub.-- ptr (sub. svt.sub.-- ptr) is a pointer to the SVT data structure, FIG. 4A is a block diagram illustrating in greater detail the functions comprising the state oriented portion 225 of FIG. 2 in a preferred embodiment of the present invention. The state oriented portion 225 comprises the following four functions: get scb (GETSCB), change state (CHSTA), release scb (RELSCB) and get state (GETSTA). The GETSCB, CHSTA, RELSCB, and GETSTA functions are illustrated in greater detail in FIGS. 5, 6, 7 and 8, respectively, and described in detail in connection therewith. The GETSCB function of the state oriented portion of 225 must be invoked before any state transitioning occurs within a FSM. If an SCB data structure is available, the GETSCB function retrieves the SCB from the scb.sub.-- arry and then initializes it with information received from FSM 104 and the OS 106. The following information is provided by FSM 104: the total number of states in the FSM, any default parameter required to be passed to a transitioned state, the top of stack for a parent FSM if the current FSM is nested, and a way to access the SVT data structure associated with the FSM. In the preferred embodiment of the present invention a state table (STB) data structure is used to provide the required information to the GETSCB function. An example of how the STB data structure can be implemented in C++ is illustrated in Table IV below:
TABLE IV
______________________________________
typedef struct
{
word total.sub.-- sta;
int deft.sub.-- prm;
word *loc.sub.-- tos;
SFV *svt.sub.-- adr;
} STA.sub.-- TBL
______________________________________
.COPYRGT. 1993 Telefonaktiebolaget L M Ericsson
The variable total.sub.-- sta (STB. total.sub.-- sta) identifies the total number of states within the FSM. Variable deft.sub.-- prm (STB. deft.sub.-- prm) identifies a parameter to be passed to a transitioned state. The variable loc.sub.-- tos (STB. loc.sub.-- tos) is a pointer to the local top of stack of a process associated with the FSM. Variable svt.sub.-- adr (STB. svt.sub.-- adr) is a pointer to a SVT data structure associated with the FSM. FIG. 5 is a flow chart of the operations which comprise the GETSCB function of the state oriented portion 225 of FIG. 2 in the preferred embodiment of the present invention. The GETSCB function is provided with a STB data structure from a FSM. The GETSCB function begins at step 500 and proceeds to step 502 by determining whether any SCB data structures available. If no SCB data structures are available, then the function proceeds to return. If SCB data structures are available, then the function proceeds to step 504, an error, at step 504, which indicates that no SCB data structures are currently available, and the function proceeds to end. At step 506, an SCB data structure is retrieved from the scb.sub.-- arry, and the function proceeds to step 508. At step 508, the value of variable scb. loc.sub.-- tos is compared to zero to determine whether the function was requested by a nested FSM. If the value of variable scb. loc.sub.-- tos equals zero (i.e., the function was requested from a nested FSM), then the function proceeds to step 515; otherwise the function proceeds to step 510 where variable scb. loc.sub.-- tos is set equal to the current executing process's top of stack, and the function proceeds to step 520. At step 515, the variable scb. loc.sub.-- tos is set equal to the variable STB. loc.sub.-- tos, and the function proceeds to step 520. At step 520, the variables of the SCB data structure are initialized with information from the current executing process and the STB data structure. The function then proceeds to return the value of variable scb. id at step 525, and the function proceeds to end. The value of variable scb.sub.-- id is used by FSM 104 (FIG. 1) to identify the SCB data structure which is associated with it. The CHSTA function of the state oriented portion 225 (FIG. 2) provides FSM 104 (FIG. 1) with the ability to transition from one state to another. FIG. 6 is a flow chart of the operations which comprise the change state function (CHSTA) in the preferred embodiment of the present invention. The CHSTA function is provided with the following information from a FSM: the identification of a SCB data structure (scb.sub.-- id), an identification of a new state (new.sub.-- sta) to which FSM 104 is to transition and a parameter (prm) which is to be passed to the new state. The CHSTA function begins at step 600 and proceeds to step 602 where the scb.sub.-- arry 305 is accessed with the value of variable scb.sub.-- id and an SCB data structure which is identified by the variable scb.sub.-- id is retrieved. The function then proceeds to determine whether the current executing process is the same process identified by the variable scb. pid at step 604. If the executing process is the same process as identified by variable scb. pid, then the function proceeds to step 608; Otherwise, the function proceeds to return an error indicating that the SCB data structure identified by variable scb. id is invalid, and the function proceeds to end. At step 608, a determination of whether the variable new.sub.-- sta indicates a request for a previous state is made. If variable new.sub.-- sta indicates that a request for a previous state is made, then the function proceeds to step 610. If variable new.sub.-- sta indicates that a request for a previous state was not made, then the function proceeds to step 612. At step 610, variable new.sub.-- sta is set equal to variable scb. pre.sub.-- sta, and the function proceeds to step 616. At step 612, a determination of whether a request for the current state is made. If variable new.sub.-- sta equals a request for the current state, then the function proceeds to step 614. If variable new.sub.-- sta does not equal a request for the current state, then the function proceeds to step 610 where the variable new.sub.-- sta is set equal to variable scb. pre.sub.-- sta, and the function proceeds to step 616. At step 614, variable new.sub.-- sta is set equal to variable scb. sta, and the function proceeds to step 616 where variable new.sub.-- sta is analyzed to determine whether a valid transition state was specified. If the value of variable new.sub.-- sta is less than the value of variable scb. total.sub.-- sta, then the function proceeds to step 620. Otherwise, the function proceeds to step 618 where an error is returned indicating that an invalid state was requested, and the function proceeds to end. At step 620, variable scb. pre.sub.-- sta is set equal to variable new.sub.-- sta, and the function proceeds to step 625 where variable scb. loc.sub.-- tos is used to adjust a specified FSM's stack so that variable prm, variable scb. deft.sub.-- prm, and the memory address of the main state processing function for the identified new state may be pushed onto the stack. The memory address of the main state processing function for the identified new state is acquired by accessing the associated SVT data structure with the value of variable new.sub.-- sta. Variable prm, variable scb. deft.sub.-- prm and the memory address of the main state processing function for the new state are all pushed onto the adjusted FSM's stack, and the function proceeds to end. Once a FSM has successfully performed its required state transitions, the previously retrieved SCB data structure must be released. If the retrieved SCB is not released after the FSM has completed its operation, a dead SCB will result. A sufficient number of dead SCBs will eventually result in the failure of I/O event manager 108. The RELSCB function of the state oriented portion 225 (FIG. 2) releases a previously retrieved SCB data structure. The RELSCB function is provided with the following information from a FSM: a variable identifying the retrieved SCB data structure (scb.sub.-- id) and a variable identifying the current process (pid). FIG. 7 is a flow chart of the operations which comprise the RELSCB function in the preferred embodiment of the present invention. The RELSCB function begins at step 700 and proceeds to step 702 where a determination of whether the process (task) identified by the retrieved SCB (scb. pid) is equal to the current executing process (pid) is made. If variable pid does not equal variable scb. pid (i.e., the current process.noteq.identified process), then the function proceeds to step 704. Otherwise, the function proceeds to step 706. At step 704, an error is returned indicating that the process identified by variable scb. pid is not the current executing process and the function proceeds to end. At step 706 the identified SCB data structure is verified to have been used. If variable scb. sts indicates that the SCB has been used, then the function proceeds to step 708 where an error is returned indicating that the SCB data structure was not used, and the function proceeds to end. If variable scb. sts indicates that the scb is not in use, then the function proceeds to step 710 where the SCB data structure is initialized to default values, and the function proceeds to end at step 712. The GETSTA function of the state oriented portion 225 (FIG. 2) is used to determine the current or previous state of FSM 104. FIG. 8 is a flow chart of the operations which comprise the GETSTA function in the preferred embodiment of the present invention. The GETSTA function is provided with the following information from a FSM: a variable identifying the retrieved SCB data structure (scb. Id) and a variable indicating whether the current or previous state is requested (state). The GETSCB function begins at step 800 and proceeds to step 802 where the variable state is analyzed to determine whether a request for the current state is made. If the request is for the current state, then the function proceeds to step 804. Otherwise, the function proceeds to step 806. At step 804, the scb.sub.-- arry is accessed by using the value of variable scb.sub.-- id, and a SCB data structure identified by variable scb.sub.-- id is retrieved, and the function proceeds to step 806. At step 806, the value of variable scb. sta is returned, and the function proceeds to end. At step 808, a determination whether the request was for the previous state is made. If the request was for the previous state, then the function proceeds to step 815. Otherwise, the function proceeds to step 810. At step 810, an error is returned indicating that an invalid state was requested, and the function proceeds to end. At step 815, the scb.sub.-- arry is accessed by using the value of variable scb.sub.-- id and a SCB data structure identified by the variable scb.sub.-- id is retrieved, and the function proceeds to step 820. At step 820, the value of variable scb. pre.sub.-- sta is returned, and the function proceeds to end. Application Interface/Event Driven Portion Referring again to FIG. 2, the event driven portion 230 of application interface 205 communicates with the internal interface 210 via a logic path 232, and provides FSM 104 of FIG. 1 with the ability to have event driven control of the I/O capabilities of physical device 114. Control of the I/O capabilities includes controlling the reading and writing of information to and from the physical device 114, and the ability to determine the status of a particular event within the physical device 114. The following types of event driven control are provided by the event driven portion 230 (FIG. 2): no waiting, passive waiting, active waiting and redirection waiting. Passive, active, no, and redirection waiting are defined below in connection with their use by a FSM. A FSM which makes an I/O request specifying passive waiting is suspended until the I/O request has matured, at which time, the FSM is reactivated. A FSM which makes an I/O request specifying active waiting continues to execute until the I/O request has matured, at which time, the FSM is returned to the location where the I/O request was originally made. An I/O request by a FSM which specifies redirection waiting continues to execute until the I/O request has matured, at which time, the FSM is redirected to a specified state. The event driven control is provided by the event driven portion 230 (FIG. 2) in conjunction with the event driven coordination portion 240 (FIG. 2) of the internal interface 210 (via logic path 232) and the event driven driver portion 245 of the device driver interface 220 via logic paths 244 and 245. The information required by the event driven portion 230 can be provided and stored in numerous ways. For example, in the preferred embodiment of the present invention an Event Control Block (ECB) data structure is employed. Each I/O requested must have an ECB data structure associated with it. Since numerous I/O requests occur within an application program, a predetermined number of ECB data structures are dynamically allocated (created) within the I/O Event Manager 108 (FIG. 1) during the initialization of the OS 106 (FIG. 1). In order to determine the locations of the allocated ECB data structure within the memory of an associated computing system a linked list data structure such as a queue is used. For example, in the preferred embodiment of the present invention a linked list structure (ecb.sub.-- arry) is used to contain the allocated ECB data structures. FIG. 9 is a block diagram which illustrates a linked list data structure (ecb.sub.-- arry) used for linking the allocated ECB data structures within the I/O event manager 108 of FIG. 1 in the preferred embodiment of the present invention. The ecb.sub.-- arry includes a header data structure 905 having pointers head 925 and tail 930 for indicating the locations of a first ECB 910 and a last ECB 920, respectively within the ecb.sub.-- arry. An example of an allocated ECB data structure is illustrated in C++ in Table V below:
TABLE V
______________________________________
typedef struct
QUE.sub.-- MB
link; /* ECB linked list structure */
WORD ecb.sub.-- id
/* ECB ID */
WORD mevq.sub.-- id;
/* associated matured event queue */
WORD cmd.sub.-- fmt;
/* command or read, write format */
WORD rc; /* response code or action if event
matured */
WORD pid; /* user task (process ID) */
WORD dev.sub.-- id;
/* device ID */
WORD event; /* event code*/
WORD ev.sub.-- sts;
/* status of the requested event */
union
{
void *dt.sub.-- ptr;
/* I/O data pointer */
WORD dt.sub.-- word;
/* I/O data word, 16 bit */
BYTE dt.sub.-- byte;
/* I/O data byte, 8 bit */
} ppu; /* I/O parameter data type union */
US.sub.-- REG
*us reg.sub.-- ptr;
/* user registers pointer */
IOU *iou.sub.-- ptr;
/* IOU pointer */
} ECB;
______________________________________
.COPYRGT. 1993 Telefonaktiebolaget L M Ericsson
The variable link is a component of the ECB.sub.-- arry (queue) which interconnects the previously dynamically allocated list of ecb's together. Variable ecb.sub.-- id (ecb. ecb.sub.-- id) is used to identify the ECB data structure within the ecb.sub.-- arry. The variable mevq.sub.-- id (ecb. mevq. id) identifies an associated matured event queue. Variable cmd.sub.-- fmt (ecb. cmd.sub.-- fmt) represents a requested operation of the device driver (e.g. read or write). Variable pid (ecb. pid) identifies the process associated with the FSM making the I/O request. The variable dev.sub.-- id (ecb. dev.sub.-- id) identifies the device driver from which the I/O request is to be collected. Variable event (ECB. EVENT) identifies the type of event waiting requested (e.g. active or passive). The variable ev.sub.-- sts (ecb. ev.sub.-- sts) indicates the status of the requested event. The data structure ppu (ecb. ppu) is used to record and transmit data from a requested event. The ppu data structure includes the following pointers for accessing data: dt.sub.-- ptr (ecb. ppu. d.sub.-- ptr), dt.sub.-- word (ecb. ppu. dt.sub.-- word) and dt.sub.-- byte (ecb. ppu. dt.sub.-- byte). Variable us.sub.-- reg.sub.-- ptr (ecb. us.sub.-- reg.sub.-- ptr) is a pointer to the associated process's register location. The variable iou.sub.-- ptr (ecb. iou.sub.-- ptr) is a pointer to an associated IOU data structure and is used to access an IOU data structure. Referring once again to FIG. 2, the event driven portion 230 (FIG. 2) supports multiple active and redirection I/O requests within a FSM. In active and redirection event waiting the maturing of multiple I/O requests may occur simultaneously with the execution of a matured previous active or redirection I/O request. Therefore, a data structure is required for storing matured I/O requests (i.e., ECB data structures) during multiple active or redirection I/O requests. In the preferred embodiment of the present invention a Matured Event Queue (MEVQ) data structure is used for storing associated ECB data structures during multiple active or redirection I/O requests. The I/O event manager 108 (FIG. 2) dynamically allocates a predetermined number of MEVQ data structures during its initialization. In order to determine the locations of the dynamically allocated MEVQ data structure within the memory of an associated computing system a linked list structure such as a queue is used. FIG. 10 is a block diagram which illustrates a linked list (mevq.sub.-- arry) employed for containing MEVQ data structures which are dynamically allocated within I/O event manager 108 of FIG. 2 in the preferred embodiment of the present invention. The mevq.sub.-- arry may contain a plurality of dynamically allocated MEVQ data structures 1110 through 1120. The mevq.sub.-- arry includes a header data structure 1105 having pointers head 1125 and tail 1130 for indicating the locations of a first MEVQ 1110 and a last MEVQ 1120 respectively within the mevq.sub.-- arry. A dynamically allocated MEVQ data structure is illustrated in C++ in Table VI below:
TABLE VI
______________________________________
typedef struct
QUE.sub.-- MBS
link; /* link list structure */
WORD pid; /* User task ID that owned this
queue */
WORD mevq.sub.-- id;
/* matured event queue id */
WORD q.sub.-- sts;
/* Queue status */
EV.sub.-- LIST
mq; /* Queue */
} MEVQ
______________________________________
.COPYRGT. 1993 Telefonaktiebolaget L M Ericsson
The variable link (mevq. link) is a component of the mevq.sub.-- arry (queue) which interconnects the previously dynamically allocated mevqs together. Variable pid (mevq. pid) identifies an associated process. The variable mevq.sub.-- id (mevq. mevq.sub.-- id) identifies the MEVQ data structure within the mevq.sub.-- array. Variable q.sub.-- sts (mevq. q.sub.-- sts) is used to enable and disable the MEVQ during multiple execution of active and redirection I/O requests. The variable mq (mevq. mq) is a linked list for ECB data structures that have matured I/O requests for the process identified by variable mevq. pid. FIG. 4B is a block diagram illustrating in greater detail the functions of the event driven portion 230 of FIG. 2 in a preferred embodiment of the present invention. The event driven portion 230 comprises the following functions: initializing the physical device (IOCTL), determining the status of a requested I/O event from the physical device (IOSTS), reading information from the physical device (read and RDCHR) and writing information to the hardware device (write and WRCHR). All of the above functions call associated functions within the event driven coordination portion 240 (FIG. 2) via logic path 232 (FIG. 2). The event driven portion 230 functions require certain information to be provided by a FSM. The required information varies depending upon the particular function invoked. Therefore, in the preferred embodiment of the present invention an IOU data structure is used in order to provide the necessary information for each of the event driven portion 230 functions. An example of how the IOU data structure may be implemented in C++ is illustrated in Table VII below.
TABLE VII
______________________________________
typedef union
CTL.sub.-- STRU
ctl; /* parameter struct. for IOCTL */
STS.sub.-- STRU
sts; /* parameter struct. for iosts */
RW.sub.-- STRU
rw; /* parameter struct. for read.write
*/
} IOU
______________________________________
.COPYRGT. 1993 Telefonaktiebolaget L M Ericsson
The IOCTL function is invoked by application programs such as application program 102, to configure and control a physical device such as physical device 114 via device driver 110. The IOCTL function allows an application program 102 to open and close a specified device driver. An individual device driver is specified to the IOCTL function by a device driver identification variable (Id) which indicates whether the device driver is to be opened exclusively or generally. The IOCTL function is provided with the following information from an application program: the device driver identification, the type of operation to be performed (e.g. open or close), the device driver type, the device driver mode, and an associated FSM's parameter table. The IOCTL function uses the CTL.sub.-- STRU data structure within the IOU data structure. The CTL.sub.-- STRU data structure may be implemented in C++ as illustrated in Table VIII below:
TABLE VIII
______________________________________
typedef struct
Word cmd; /* control command */
Byte d.sub.-- type;
/* device type */
Byte d.sub.-- mode;
/* device mode */
void *table /* user's parameter table addr
*/
Byte tbl.sub.-- idx
/* index to parameter table */
Byte para.sub.-- val;
/* byte value of the indicated
entry */
}CTL.sub.-- STRU
______________________________________
.COPYRGT. 1993 Telefonaktiebolaget L M Ericsson
Variable cmd (iou. ctl. cmd) indicates the type of operation to be performed (e.g. open or close). Variable d.sub.-- type (iou. ctl. d.sub.-- type) indicates the device driver type. Variable d.sub.-- mode (iou. ctl. d.sub.-- mode) represents the device driver mode. Variable table (iou. ctl. table) indicates a pointer to the FSM's parameter table address. Variable para.sub.-- val (iou. ctl. para.sub.-- val) represents the current position within the FSM's parameter table. FIG. 11 is a flow chart of the operations which comprise the IOCTL function of the event driven portion 230 of FIG. 2 in a preferred embodiment of the present invention. The IOCTL function is provided with the following information from an application program: a variable specifying a device driver (device.sub.-- id), and an IOU data structure (iou.sub.-- ptr). The IOCTL function begins at step 1600 and proceeds to step 1605 where a determination of whether the specified device driver is to be opened generally is made. If variable iou. ctl. cmd specifies a request for opening the device driver generally, then the function proceeds to step 1610. Otherwise, the function proceeds to step 1625. At step 1610, the specified device driver is checked to verify that it is not already opened. If the specified device driver is already open, then the function proceeds to step 1615. Otherwise, the function proceeds to step 1620. At step 1615, an error is returned indicating that the specified device driver is already open, and the function proceeds to end at step 1665. At step 1620, the function IOCTL in the specified device driver is invoked, and variables IOU and device.sub.-- id are passed, and the function proceeds to end at step 1665. At step 1625, a determination of whether the specified device driver is to be opened exclusively is made. If variable iou. sts. cmd equals a request to open the specified device driver exclusively, then the function proceeds to step 1630. Otherwise, the function proceeds to step 1645. At step 1630, the specified device driver is checked to verify that it is not already opened. If the specified device driver is already opened the function proceeds to step 1635. Otherwise, the function proceeds to step 1640. At step 1635, an error is returned indicating that the specified device driver is already opened, and the function proceeds to end at step 1665. At step 1640, the function IOCTL in the specified device driver is invoked and variables IOU and device.sub.-- id are pass ed and the function proceeds to end at step 1665. At step 1645, a determination of whether the specified driver is to be closed is made. If variable iou. cts. cmd equals a request to close the device driver, then the function proceeds to step 1650. Otherwise, the function proceeds to end at step 1665. At step 1650, the specified device driver is checked to see if it is already closed. If the specified device driver is already closed the function proceeds to step 1655. Otherwise, the function proceeds to step 1660. At step 1655, an error is returned indicating that the specified device is already closed, and the function proceeds to end. At step 1660, the function IOCTL in the specified device driver is invoked and variables IOU and device.sub.-- id are passed, and the function proceeds to end at step 1665. Still referring to FIG. 4B, the IOSTS function of the event driven portion 230 (FIG. 2) provides an application program with the ability to poll the occurrence or non-occurrence of an I/O event within a specified physical device, and to specify the action to be taken once the polled I/O event occurs or ceases to occur. The IOSTS function is provided with the following information by an application program: the event requested, the type of event waiting, identification of a matured event queue associated with the requested event, and a function address for redirection event waiting. In the preferred embodiment of the present invention the IOSTS function employs the STS.sub.-- STU data structure within the IOU data structure for the transfer of the required information from the application program. The STS.sub.-- STU data structure may be implemented in C++ as illustrated in Table IX below:
TABLE IX
______________________________________
typedef struct
WORD cmd; /* status command */
WORD ev; /* event code */
WORD rc; /* response code or action if */
/* event matured */
WORD mevq.sub.-- id;
/* matured event queue ID, */
void *fn.sub.-- addr;
/* function address for REDIR */
} STS.sub.-- STRU
______________________________________
.COPYRGT. 1993 Telefonaktiebolaget L M Ericsson
Variable cmd (iou. sts. cmd) indicates the type of I/O event request. Variable ev (iou. sts. ev) indicates the type of event waiting requested. Variable rc (iou. sts. rc) indicates the response code or action to be taken once the I/O event requested matures. Variable mevq.sub.-- id (iou. sts. mevq.sub.-- id) identifies a MEVQ data structure. Variable fn.sub.-- addr (iou. sts. fn.sub.-- addr) contains the function address for redirection. FIG. 12 is a flow chart of the operations which comprise the IOSTS function in the event driven portion 230 of FIG. 2 in the preferred embodiment of the present invention. The iosts function is provided with the following information by an application program: a variable for specifying the device driver for collecting the requested I/O event (dev.sub.-- id) and a variable pointing to the IOU data structure (iou.sub.-- ptr). The iosts function begins at step 1700 and proceeds to 1705 where the specified device driver (dev.sub.-- id) is checked to verify that it is currently open. If the specified device driver is already open, then the function proceeds to step 1715. Otherwise, the function proceeds to step 1710 where an error is returned indicating that the specified device driver is closed, and the function proceeds to end. At step 1715, a determination of whether an ECB data structure is available within the ecb.sub.-- array is make. If an ECB data structure is available within the ecb.sub.-- array, then the function proceeds to retrieve the ECB data structure from the ecb.sub.-- array, and the function proceeds to step 1725. Otherwise, the function proceeds to step 1720 where an error is returned indicating that there are no ECB data structures currently available, and the function proceeds to end. At step 1725, the variables in the retrieved ECB data structure are initialized with information from the iou. sts data structure and the current executing process. The function then proceeds to step 1730 where the IOCOMMON function in the event driven coordination portion 240 (FIG. 2) is invoked and passed the ECB data structure and the specified device driver function for iosts. The value of variable rtn.sub.-- sts is also set equal to the value returned by the IOCOMMON function and the function proceeds to step 1735 where the value of rtn.sub.-- sts is analyzed to determine if an error has occurred or if the requested I/O event is mature. If the rtn.sub.-- sts variable indicates than an error has occurred or that the requested I/O event is mature, then the function proceeds to step 1740. Otherwise, the function proceeds to step 1745. At step 1740, the ECB data structure is released to the ecb.sub.-- arry, and the function proceeds to step 1755. At step 1745, the variable iou. sts. ev pointed to by iou.sub.-- ptr is analyzed to determine if active or redirection event waiting is requested. If variable iou. sts. ev indicates that redirection or active event waiting is requested, then the function proceeds to step 1750. Otherwise, the function proceeds to step 1755. At step 1750, the ECB data structure is stored in the MEVQ data structure identified by variable ecb. mevq. id, and the function proceeds to step 1755. At step 1755, the value of variable rtn.sub.-- sts is returned, and the function proceeds to end. The READ function provides an application program with the ability to read data from a specified physical device with event driven control. The data which is read from the specified physical device is returned to the application program in a specified format. The READ function is provided with the following information from the application program: the type of format for data output, the type of event waiting, an identification of an associated matured event queue, and a pointer to a function address if redirection event waiting is specified. The READ function utilizes the data structure rw.sub.-- STU within the IOU data structure to provide the above information. The rw.sub.-- STU data structure is used for both reading and writing to a specified physical device (via a device driver). The rw.sub.-- STU data structure may be implemented in C++ as illustrated in Table X below:
TABLE X
______________________________________
typedef struct
WORD format; /* Data input/output format */
WORD ev; /* event code */
WORD rc /* response code or actin if */
/* event matured */
WORD mevq_id; /* matured event queue ID, */
void *dt_ptr; /* associated pointer for I/O
data */
BYTE bc; /* byte counter for STRING/
LINE */
BYTE wr_dlm; /* delimiter used for write
to */
/* indicate end of string */
void *fn_addr; /* function address for REDIR */
} rw_STRU
______________________________________
.COPYRGT. 1993 Telefonaktiebolaget L M Ericsson
The variable format (rw. format) indicates the requested data output format (e.g. string). Variable ev (rw. ev) indicates the type of event waiting requested. Variable rc (rw. rc) indicates the response code or action to be taken once the requested I/O event has matured. Variable mevq.sub.-- id (rw. mevq.sub.-- id) identifies a matured event queue associated with the RW data structure. The variable dt.sub.-- ptr (rw. dt.sub.-- ptr) is a pointer to a buffer for storing the I/O request data. The variable bc (rw. bc) is a counter used if string or line format is specified for storing the I/O event data. Variable wr.sub.-- dlm (rw. wr.sub.-- dlm) is used to indicate a specified delimiter for an end of string if the string format is specified. The variable fn.sub.-- addr (rw. fn.sub.-- addr) is a pointer for a function if redirection event waiting is specified. FIG. 13 is a flow chart of the operations which comprise the READ function in the event driven portion 230 of FIG. 2 in the preferred embodiment of the present invention. The following variables are provided to the READ function by an application program: a variable specifying the device driver for collecting the requested I/O event (dev.sub.-- id) and a variable pointing to the IOU data structure (iou.sub.-- ptr). The READ function begins at step 1800 and proceeds to step 1805 where a determination of whether the specified device driver (dev.sub.-- id) is open is made. If the specified device driver is already open, then the function proceeds to step 1815. Otherwise, the function proceeds to step 1810 where an error is returned indicating that the specified device driver is closed, and the function proceeds to end. At step 1815, a determination of whether an ECB data structure is available within the ecb.sub.-- arry is made. If an ECB data structure is available, then the function retrieves the ECB data structure from the ecb.sub.-- arry and proceeds to step 1825. Otherwise, the function proceeds to step 1820 where an error is returned indicating that there are no ECB data structures currently available, and the function proceeds to end. At step 1825, a determination of whether no event waiting was specified is made. If variable iou. rw. format does not specify no event waiting, then the function proceeds to step 1830. Otherwise, the function proceeds to step 1835 where an error is returned indicating that the function does not support no event waiting, and the function proceeds to end. At step 1835, the variables in the retrieved ECB data structure are initialized with information from the iou. rw data structure and the current process identification. The function then proceeds to step 1840 where the IOCOMMON function in the event driven coordination portion 240 (FIG. 2) is invoked and passed the ECB data structure and the specified device driver function for read. The value of variable rtn.sub.-- sts is also set equal to the value returned by the IOCOMMON function. The function then proceeds to step 1845 where the value of variable rtn.sub.-- sts is analyzed to determine if an error has occurred or if the I/O request is mature. If variable rtn.sub.-- sts indicates than an error has occurred or that the I/O request is mature, then the function proceeds to step 1850. Otherwise, the function proceeds to step 1855. At step 1850, the ECB data structure is released to ecb.sub.-- arry, and the function proceeds to step 1865. At step 1855, a determination of whether active or redirection event waiting is requested by the application program is made. If variable iou. sts. ev pointed to by iou.sub.-- ptr indicates that redirection or active event waiting is requested, then the function proceeds to step 1860. Otherwise, the function proceeds to step 1865. At step 1860, the ECB data structure is stored in the MEVQ data structure which is identified by variable ecb. mevq. id, and the function proceeds to step 1865. At step 1865, the value of variable rtn.sub.-- sts is returned, and the function proceeds to end. An application program requires the ability to transmit data (output data) to a hardware device. The write function of the event driven portion 230 provides an application program with the ability to transmit output data to a specified physical device (via a device driver). The write function is provided with the following information by an application program: the type of output format for the output data, the type of event waiting requested, an identifier for a matured event queue, an end of string indicator for output data which uses strings, and a pointer to a function address for redirection event waiting. The write function also employs the RW data structure within the IOU data structure. FIGS. 14A-14B are flow charts of the operations which comprise the write function in the event driven portion 230 of FIG. 2 in the preferred embodiment of the present invention. The following information is provided by an application program: a variable for specifying the device driver for collecting the requested I/O event (dev.sub.-- id) and a variable pointing to the IOU data structure (iou.sub.-- ptr). The write function begins at step 1900 and proceeds to step 1905 where a determination of whether the specified device driver (dev.sub.-- id) is open is made. If the specified device driver is already open, then the function proceeds to step 1915. Otherwise, the function proceeds to step 1910 where an error is returned indicating that the specified device driver is closed and the function proceeds to end. At step 1915, a determination of whether the device driver was opened exclusively is made. If the device driver was opened exclusively, then the function proceeds to step 1920. Otherwise, the function proceeds to step 1927. At step 1920, variable dev.sub.-- id is compared to the exclusive device ID for the device driver. If variable dev.sub.-- id equals the exclusive device driver Id, then the function proceeds to step 1927. Otherwise, the function proceeds to step 1925 where an error is returned indicating that the variable dev.sub.-- id does not equal the exclusive device driver Id, and the function proceeds to end. At step 1927, a determination of whether an ECB data structure is available within the ecb.sub.-- arry is made. If an ECB data structure is available within the ecb.sub.-- arry, then the function retrieves the ECB data structure from the ecb.sub.-- arry and proceeds to step 1930. Otherwise, the function proceeds to step 1928 where an error is returned indicating that there are no ECB data structures currently available, and the function proceeds to end. At step 1930, the variables in the retrieved ECB data structure are initialized with information from the iou. rw data structure and the current process. The function then proceeds to step 1935 where a determination of whether a word is to be written to the device driver (i.e., the physical device) is made. If variable ecb. cm.sub.-- fmt specifies writing a word to the device driver, then the function proceeds to step 1940. Otherwise, the function proceeds to step 1945. At step 1940, variable ecb. ppu. dt.sub.-- ptr is set equal to the value of variable iou. rw. dt.sub.-- ptr pointed to by iou.sub.-- ptr (type casted as a word), and the function proceeds to step 1950. At step 1945, the variable ecb. ppu. dt.sub.-- ptr is set equal to variable iou. rw. dt.sub.-- ptr, pointed to by iou.sub.-- ptr, and the function proceeds to step 1950. At step 1950, the ECB data structure variables are initialized with information from the iou. rw and iou. pw data structures, and the function proceeds to step 1955 where the IOCOMMON function in the event driven coordination portion 240 (FIG. 2) is invoked and passed the ECB data structure and the specified device driver function for write. The value of variable rtn.sub.-- sts is also set equal to the value returned by the IOCOMMON function and the function proceeds to step 1960 at FIG. 14B. Referring now to FIG. 14B, at step 1960, the value of rtn.sub.-- sts is analyzed to determine whether an error has occurred or if the I/O request is mature. If variable rtn.sub.-- sts indicates that an error has occurred or that the I/O request is mature, then the function proceeds to step 1965. Otherwise, the function proceeds to step 1970. At step 1965, the ECB data structure is released to the ecb.sub.-- arry, and the function proceeds to step 1980. At step 1970, a determination of whether active or redirection event waiting is requested by the application program is made. If variable iou. rw. ev pointed to by iou.sub.-- ptr indicates that redirection or event waiting is requested, then the function proceeds to step 1975. Otherwise, the function proceeds to step 1980. At step 1975, the ECB data structure is stored in the MEVQ identified by variable ecb. mevq. id, and the function proceeds to step 1980 where the value of rtn.sub.-- sts is returned, and the function proceeds to end. Referring again to FIG. 4B, the WRCHR function of the event driven portion 230 (FIG. 2) provides an application program with the ability to write characters to character type physical devices. The WRCHR function, however, only supports no event waiting. FIG. 15 is a flow chart of the operations which comprise the WRCHR function in the preferred embodiment of the present invention. The following variables are provided by an application program to the WRCHR function: a variable specifying the device driver for collecting the I/O request (dev.sub.-- id) and a variable specifying the character to be written to the device driver (i.e., the physical device). The WRCHR function begins at step 2000 and proceeds to step 2005 where a determination of whether the specified device driver (dev.sub.-- id) is currently open is made. If the specified device driver is already open, then the function proceeds to step 2015. Otherwise, the function proceeds to step 2010 where an error is returned indicating that the specified device driver is closed, and the function proceeds to end. At step 2015, a determination of whether the device driver was opened exclusively is made. If the device driver was opened exclusively, then the function proceeds to step 2020. Otherwise, the function proceeds to step 2030. At step 2020, a determination of whether the variable dev.sub.-- id is equal to the exclusive device driver Id is made. If variable dev.sub.-- id equals the exclusive device driver Id, then the function proceeds to step 2030. Otherwise, the function proceeds to step 2025 where an error is returned indicating that the specified device driver is currently opened exclusively and that the variable dev.sub.-- id does not have access to it, and the function proceeds to end. At step 2030, a determination of whether an ECB data structure is available within the ecb.sub.-- arry is made. If an ECB data structure is available within the ecb.sub.-- arry, then the function retrieves the ECB data structure from the ecb.sub.-- arry and proceeds to step 2040. Otherwise, the function proceeds to step 2035 where an error is returned indicating that there are no ECB data structures currently available, and the function proceeds to end. At step 2040, the variables in the retrieved ECB data structure are initialized and the function proceeds to step 2045 where the IOCOMMON function in the event driven coordination portion 240 (FIG. 2) is invoked and passed the ECB data structure and the specified device driver function for WRCHR. The value of variable rtn.sub.-- sts is also set equal to the value returned by the IOCOMMON function, and the IOCOMMON function proceeds to step 2050 where variable rtn.sub.-- sts is analyzed to determine if an error has occurred or if the I/O request is mature. If variable rtn.sub.-- sts indicates that an error has occurred or that the I/O request is mature, then the function proceeds to step 2055. Otherwise, the function proceeds to step 2065. At step 2055, the exe.sub.-- return function in the event driven coordination portion 240 (FIG. 2) is invoked and passed the ECB data structure and a variable which indicates that no register swapping is to be performed. The WRCHR function then proceeds to step 2060 where the ECB data structure is released to the ecb.sub.-- arry, and the function proceeds to step 2065. At step 2065, the value of variable rtn.sub.-- sts is returned and the function proceeds to end. Referring again to FIG. 4B, the RDCHR function of the event driven portion 230 provides an application program with the ability to read characters from physical character devices. The RDCHR function is provided with the following information by the application program: the identification of the device driver to perform the data input and the identification of a matured event queue for recording the input data. FIG. 16 is a flow chart of the operations which comprise the RDCHR function in the preferred embodiment of the present invention. The RDCHR function begins at step 2100 and proceeds to step 2105 where a determination of whether the MEVQ data structure is valid is made. If the MEVQ data structure is valid, then the function proceeds to step 2115. Otherwise, the function proceeds to step 2110 where an error is returned indicating that the MEVQ data structure is invalid, and the function proceeds to end. At step 2115, a determination of whether the specified device driver (dev.sub.-- id) is currently open is made. If the specified device driver is already open, then the function proceeds to step 2125. Otherwise, the function proceeds to step 2120 where an error is returned indicating that the specified device driver is closed, and the function proceeds to end. At step 2125, a determination of whether the specified device driver was opened exclusively is made. If the specified device driver was opened exclusively, then the function proceeds to step 2130. Otherwise, the function proceeds to step 2140. At step 2130, variable dev.sub.-- id is compared to the exclusive device driver Id. If variable dev.sub.-- id is equal to the exclusive device driver. id, then the function proceeds to step 2140. Otherwise, the function proceeds to step 2135 where an error is returned indicating that the variable dev.sub.-- id does not have access to the specified device driver, and the function proceeds to end. At step 2140, a determination of whether an ECB data structure is available within the ecb.sub.-- arry is made. If an ECB data structure is available within the ecb.sub.-- arry, then the function retrieves the ECB data structure from the ecb.sub.-- arry and proceeds to step 2150. Otherwise, the function proceeds to step 2145 where an error is returned indicating that there are no ECB data structures currently available, and the function proceeds to end. At step 2150, the variables in the retrieved ECB data structure are initialized, and the function proceeds to step 2155 where the IOCOMMON function in the event driven coordination portion 240 is invoked and passed the ECB data structure and the specified device driver function for RDCHR. The function then proceeds to step 2160 where the value of rtn.sub.-- sts is analyzed to determine if an error has occurred or if the I/O requested is mature. If variable rtn.sub.-- sts indicates that an error has occurred or that the I/O request is mature, then the function proceeds to step 2165. Otherwise, the function proceeds to step 2170. At step 2165, the ECB data structure is released to the ecb.sub.-- arry, and the function proceeds to step 2170. At step 2170, the value of variable rtn.sub.-- sts is returned, and the function proceeds to end. Referring again to FIG. 4B, the event driven portion 230 of the application interface 205 is further comprised of the following functions for controlling MEVQ data structures: get an available MEVQ (GETEVQ), release a MEVQ (relevq), enable a MEVQ (evenb) and disable a MEVQ (evdis). The above functions for controlling MEVQ data structures are only used during multiple active or redirection waiting I/O requests. The GETEVQ function of the event driven portion 230 determines if one of the previously dynamically allocated MEVQ data structures is currently available. FIG. 17 is a flow chart of the operations which comprise the GETEVQ function in the preferred embodiment of the present invention. The GETEVQ function begins at step 2200 and proceeds to step 2205 where a determination of whether any available MEVQ data structures within the mevq.sub.-- arry are available is made. If there are any available MEVQ data structures within the mevq.sub.-- arry, then the function proceeds to step 2215. Otherwise, the function proceeds to step 2210 where an error is returned indicating that there are no MEVQ data structures currently available, and the function proceeds to end. At step 2215, an MEVQ data structure is retrieved from the mevq.sub.-- arry, and the function proceeds to step 2220 where variable mevq. q.sub.-- sts is set to indicate that the MEVQ data structure is enabled, and the function proceeds to step 2225. At step 2225, variable mevq. pid is set equal to the identification of the current process, and the function proceeds to step 2230 where the value of variable mevq. id is returned, and the function proceeds to end. Referring again to FIG. 4B, the relevq function of the event driven portion 230 (FIG. 2) is responsible for releasing a previously used MEVQ to the mevq.sub.-- arry. FIG. 18 is a flow chart of the operations which comprise the relevq function in the preferred embodiment of the present invention. The relevq function requires the following information to be provided by an application program: the identification of the MEVQ data structure to be made available again (mevq.sub.-- id) and an identification of a process associated with the MEVQ (pid). The relevq function begins at step 2300 and proceeds to step 2305 where the mevq.sub.-- arry is accessed with the value of variable mevq.sub.-- id and the MEVQ data structure identified by variable mevq.sub.-- id is retrieved, and the function proceeds to step 2310. At step 2310, a determination of whether the process identified by variable mevq. pid equals the process identified by variable pid is made. If the process identified by variable mevq. pid equals the process identified by variable pid, then the function proceeds to step 2315. Otherwise, the function proceeds to step 2312 where an error is returned indicating that the process identified by variable pid does not equal the process identified by variable mevq. pid, and the function proceeds to end. At step 2315, all ECB data structures contained within the linked list identified by variable mevq. mq are released, and the function proceeds to step 2320 where variable mevq. q.sub.-- sts is set equal to available, and the function proceeds to step 2325. At step 2325, variable mevq. pid is set equal to zero, and the function proceeds to step 2330 where the MEVQ data structure is released to the mevq.sub.-- arry, and the function proceeds to step 2335. At step 2335, a value is returned indicating the function executed the request, and the function proceeds to end. Referring again to FIG. 4B, the EVDIS function of the event driven portion 230 is used whenever more than one multiple active or redirection I/O request matures for an identified process. The EVDIS function disables the MEVQ associated with an identified process until the process associated with a previously matured active or redirection I/O request has finished executing. It is the responsibility of an application program to re-enable the MEVQ once the associated process has finished executing. FIG. 19 is a flow chart of the operations which comprise the EVDIS function in the event driven portion 230 of FIG. 2 in the preferred embodiment of the present invention. The EVDIS function is provided with an identification of a MEVQ data structure (mevq.sub.-- id) by an application program. The EVDIS function begins at step 1800 and proceeds to step 1805 where the mevq.sub.-- arry is accessed with the value of variable mevq-id and the MEVQ data structure identified by variable mevq.sub.-- id is retrieved, and the function proceeds to step 1810. At step 1810, variable mevq. q.sub.-- sts is set to indicate that the MEVQ data structure is disabled, and the function proceeds to end at step 1815. An application program which makes a plurality of active or redirection I/O requests is responsible for reactivating the MEVQ data structure associated with those requests. The EVENB function enables an identified MEVQ data structure. The EVENB function is provided with an identification of a MEVQ data structure which is to be enabled (mevq.sub.-- id) by an application program. FIG. 20 is a flow chart of the operations which comprise the EVENB function in the event driven portion 230 of FIG. 2 in the preferred embodiment of the present invention. The EVENB function begins at step 1900 and proceeds to step 1905 where the mevq.sub.-- arry is accessed with the value of variable mevq.sub.-- id, and the MEVQ data structure identified by variable mevq.sub.-- id is retrieved, and the function proceeds to step 1910. At step 1910, a determination of whether the linked list identified by variable mevq. mq contains any matured ECB data structures. If variable mevq. mq. n indicates that no ECB data structures remain in the linked list, then the function proceeds to step 1915. Otherwise, the function proceeds to step 1925. At step 1915, variable mevq. q.sub.-- sts is set to indicate that the MEVQ data structure is enabled, and the function proceeds to step 1920 where a value is returned indicating that the MEVQ data structure is enabled, and the function proceeds to end. At step 1925, a matured ECB data structure is retrieved from the linked list which is identified by variable mevq. mq, and the function proceeds to step 1930 where the SET.sub.-- RTV function of the event driven coordination portion 240 is invoked and the ECB data structure is passed. The function then proceeds to step 1935 where the EV.sub.-- DVN function of the event driven coordination portion 240 is invoked and the ECB data structure is passed. The function then proceeds to step 1940 where variable mevq. q.sub.-- sts is set to indicate that the MEVQ data structure is disabled, and the function proceeds to end at step 1945. INTERNAL INTERFACE/EVENT DRIVEN COORDINATION PORTION The internal interface 210 of the I/O event manager 108 provides the event driven capabilities of the I/O requests. The internal interface 210 implements the event driven capabilities through the utilization of an event driven coordination portion 240 in conjunction with an operating system protocol portion 235 via logic paths 241 and 242 respectively. The logic paths 227 and 232 provide direct input to the operating system protocol portion 235 and the event driven coordination portion 240, respectively. The event driven coordination portion 240 incorporates and coordinates the event driven capabilities of the I/O manager 108. The event driven coordination portion 240 comprises the following functions: I/O common (IOCOMMON), execution return (exe.sub.-- return) and set return value (set.sub.-- rtv). The IOCOMMON function of the event driven coordination portion 240 initiates the I/O request with the specified device driver and manipulates the associated OS 206 process in order to provide the specified event waiting. FIGS. 21A through 21E are a flow chart of the operations which comprise the IOCOMMON function of FIG. 2 in the preferred embodiment of the present invention. The IOCOMMON function is provided with an ECB data structure and a pointer to a function in a specified device driver (fp) by the event driven portion 230. FIG. 21A begins at step 2000 and proceeds to step 2005 where a determination of whether no waiting is specified is made. If variable ECB. EVENT specifies no waiting, then the function proceeds to step 2015 in FIG. 21B. Otherwise, the function proceeds to step 2050. Referring now to FIG. 21B, at step 2015, variable ecb. mevq.sub.-- id is set to a status of clear, and the function proceeds to step 2020 where the function of a specified device driver is invoked and passed the ECB data structure and the value of variable ecb. device.sub.-- id. The variable rtn.sub.-- sts is also set equal to the value returned by the specified function. The IOCOMMON function then proceeds to step 2025 where the variable rtn.sub.-- sts is analyzed to determine whether an error has occurred. If variable rtn.sub.-- sts equals an error, then the function proceeds to step 2030. Otherwise, the function proceeds to step 2270 in FIG. 21A. At step 2030, the ECB data structure is released to the ecb.sub.-- arry, and the function proceeds to end at step 2270. Referring back to FIG. 21A, at step 2050, a determination of whether passive event waiting is specified is made. If variable ECB. EVENT specifies passive event waiting, then the function proceeds to step 2055 in FIG. 21C. Otherwise, the function proceeds to step 2120. Referring now to FIG. 21C, at step 2055 the mevq.sub.-- arry is accessed using the value of variable ecb. mevq.sub.-- id and the MEVQ data structure identified by variable ecb. mevq.sub.-- id is retrieved. The function then proceeds to step 2060 to determine whether the retrieved MEVQ data structure is valid by comparing its associated process to the current process. If variable mevq. pid equals the current process Id, then the function proceeds to step 2070. Otherwise, the function proceeds to step 2065 where an error is returned indicating that an invalid MEVQ was specified by variable mevq.sub.-- id, and the function proceeds to end. At step 2070, the specified device driver function is invoked using variable fp and passed the ECB data structure and the value of variable ecb. device.sub.-- id. The variable rtn.sub.-- sts is also set equal to the value returned by the specified function. The IOCOMMON function then proceeds to step 2075 to analyze he variable rtn.sub.-- sts to determine whether the device driver accepted the I/O request. If the device driver accepted the I/O request, then the function proceeds to step 2080. Otherwise, the function proceeds to step 2090. At step 2080, a pointer to the current process's register is stored in variable ecb. us.sub.-- reg.sub.-- ptr, and the function proceeds to step 2085 where an OS 206 function is invoked to suspend the current process, and the function proceeds to end at step 2270. Variable rtn.sub.-- sts is analyzed at step 2090 to determine whether the I/O request is mature. If variable rtn.sub.-- sts indicates that the I/O request is mature, then the function proceeds to step 2095. Otherwise, the function proceeds to step 2100. The exe.sub.-- return function is invoked at step 2095 to receive both the ECB data structure and an indication not to swap registers. The variable rtn.sub.-- sts is also set equal to the value returned by the exe.sub.-- return function, and the function proceeds to end at 2270. The variable rtn.sub.-- sts is analyzed at step 2100 to determine whether the specified device driver indicated that an error has occurred. If variable rtn.sub.-- sts specifies that the specified device driver has indicated that an error has occurred, then the function proceeds to step 2105. Otherwise, the function proceeds to end at step 2270. The exe.sub.-- return function is invoked at step 2105 and receives both the ECB data structure and an indication that no register swapping is to occur. The variable rtn.sub.-- sts is also set equal to the value returned by the exe.sub.-- return function, and the IOCOMMON function proceeds to end at step 2270. Referring again to FIG. 21A, at step 2120, variable ECB. EVENT is analyzed to determine whether active event waiting is specified. If variable ECB. EVENT indicates that active event waiting is specified, then the function proceeds to step 2140 at FIG. 21D. Otherwise, the function proceeds to step 2210. Referring now to FIG. 21D, at step 2140, the mevq.sub.-- arry is accessed using the value of the variable ecb. mevq.sub.-- id and the MEVQ data structure identified by variable ecb. mevq.sub.-- id is retrieved. The function then proceeds to step 2145 where the retrieved MEVQ data structure is analyzed to verify that it is valid. The MEVQ data structure is valid if the process associated with the MEVQ data structure equals the current process. If variable mevq. pid equals the current process Id, then the function proceeds to step 2155. Otherwise, the function proceeds to step 2150 where an error is returned indicating that the MEVQ data structure identified by variable mevq.sub.-- id is not valid, and the function proceeds to end. At step 2155, a pointer to the current process's register is stored in variable ecb. us.sub.-- reg.sub.-- ptr, and the function proceeds to step 2160. At step 2160, the specified driver function is accessed by the fp pointer and invoked passing the ECB data structure and the value of variable ecb. device.sub.-- id. The variable rtn.sub.-- sts is also set equal to the value returned by the specified driver function. The IOCOMMON function then proceeds to step 2165 where variable rtn.sub.-- sts is analyzed to determine whether the specified device driver has indicated that it has accepted the I/O request. If variable rtn.sub.-- sts indicates that the device driver has accepted the I/O request, then the function proceeds to step 2170. Otherwise, the function proceeds to step 2180. At step 2170, variable rtn.sub.-- sts is set equal to the value of variable ecb. id, and the function proceeds to end at step 2270. At step 2180, variable rtn.sub.-- sts is analyzed to determine whether the device driver has indicated that an error has occurred, or that the I/O request is mature. If variable rtn.sub.-- sts specifies that the device driver has indicated that an error has occurred, or that the I/O request is mature, then the function proceeds to step 2190. Otherwise, the function proceeds to end at step 2270. At step 2190, the exe.sub.-- return function is invoked and passed the ECB data structure and an indication that the registers are to swapped. The variable rtn.sub.-- sts is also set equal to the value returned by the exe.sub.-- return function and the IOCOMMON function proceeds to end at step 2270. Referring again to FIG. 21A, at step 2210, variable ECB. EVENT is analyzed to determine whether redirection waiting is requested. If variable ECB. EVENT indicates that redirection event waiting is requested, then the function proceeds to step 2220 in FIG. 21E. Otherwise, the function proceeds to end at step 2270. Referring now FIG. 21e, at step 2220, a function of the device driver is invoked, and passed the ECB data structure and the value of variable ecb. device.sub.-- id. The variable rtn.sub.-- sts is also set equal to the value returned by the specified device driver function. The IOCOMMON function then proceeds to step 2225 where variable rtn.sub.-- sts is analyzed to determine if the device driver has indicated that an error has occurred. If variable rtn.sub.-- sts specifies that the device driver has not indicated that an error has occurred, then the function proceeds to step 2235. Otherwise, the function proceeds to step 2230 where an error is returned and the function proceeds to end. At step 2235, the ECB data structure is stored into a redirection queue or linked list of the OS 206 and the function then proceeds to end at step 2270. The second function of the event driven coordination portion 240, the exe.sub.-- return function, accesses an identified process within the OS 206 ready queue or linked list and alters register contents of the queue to correspond to a given ECB data structure. FIG. 22 is a flow chart of the operations comprising the exe.sub.-- return function in a preferred embodiment of the present invention. The exe.sub.-- return function is provided with the following information by the event driven portion 230: an ECB data structure and a variable for indicating if register swapping is to occur (flag). The exe.sub.-- return function begins at step 2300 and proceeds to step 2305 where the SET.sub.-- RTV function is invoked and passed the ECB data structure. The variable rtn.sub.-- sts is also set equal to the value returned by the SET.sub.-- RTV function. The exe.sub.-- return function then proceeds to step 2310 where variable flag is analyzed to determine whether register swapping is to occur. If variable flag indicates that register swapping is to occur, then the function proceeds to step 2315. Otherwise, the function proceeds to step 2325. At step 2315, the OS 206 process's ready queue or linked list is accessed with the value of variable ecb. pid and the process identified by variable ecb. pid is retrieved. The function then proceeds to step 2320 where the register of the retrieved process is swapped with the register pointed to by variable ecb. us.sub.-- reg.sub.-- ptr, and the function proceeds to step 2325 where the value of the variable rtn.sub.-- sts is returned, and the function proceeds to end. The third function of the event driven coordination portion 240, the SET.sub.-- RTV function, passes any data which was transmitted or read from a particular device driver to a specified process. FIG. 23 is a flow chart of the operations comprising the SET.sub.-- RTV function in a preferred embodiment of the present invention. The SET.sub.-- RTV function is provided with an ECB data structure by the event driven portion 230. The SET.sub.-- RTV function begins at step 2400 and proceeds to step 2405 where variable ecb. cmd.sub.-- fmt is analyzed to determine whether a character was read. If variable ecb. cmd.sub.-- fmt indicates that a character was read, then the function proceeds to step 2415. Otherwise, the function proceeds to step 2420. At step 2415, variable r.sub.-- code is set equal to variable ecb. ppu. dt.sub.-- byte, and the function proceeds to step 2430. At step 2420, variable ecb. cmd.sub.-- fmt is analyzed to determine whether data was read or written to a device driver with a message buffer. If variable ecb. cmd.sub.-- fmt indicates that data was read or written to a device driver with a message buffer, then the function proceeds to step 2425. Otherwise, the function proceeds to step 2430. At step 2425, variable iou. rw. dt.sub.-- ptr pointed to by variable ecb. iou.sub.-- ptr is set equal to variable ecb. ppu. dt.sub.-- ptr, and the function proceeds to step 2430. At step 2430, data register ›0! pointed to by variable ecb. us.sub.-- re.sub.-- ptr is set equal to variable r.sub.-- code, and the function proceeds to step 2435 where the value of variable r.sub.-- code is returned and the function proceeds to end. INTERNAL INTERFACE/OPERATING SYSTEM PROTOCOL PORTION The Operating System protocol portion (hereinafter "OSPP") 235 interacts with the OS 106 to implement event driven I/O requests. The OSPP comprises an event driven function (EV.sub.-- DVN) which includes the operation shown by the flow charts in FIGS. 24A-24C according to the preferred embodiment of the present invention. The EV.sub.-- DVN function is provided with an ECB data structure. The EV.sub.-- DVN function begins at step 2500 and proceeds to step 2505 where the OS 206 ready queue or linked list is accessed with variable ecb. pid, and the process identified by variable ecb. pid is retrieved. The function then proceeds to step 2510 where the user register of the retrieved process is swapped with the user register pointed to by ecb. us.sub.-- reg.sub.-- ptr. The function then proceeds to step 2515 where a determination of whether the current process is equal to the process identified by variable ecb. pid is made. If the current process is equal to the process identified by variable ecb. pid, then the function proceeds to step 2520. Otherwise, the function proceeds to step 2530. At step 2520, the OS 106 is forced to restore the process which is identified by the ECB data structure (via ecb. pid), and the function proceeds to end at step 2525. At step 2530, the external interrupts are disabled with an appropriate OS 206 call, and the function proceeds to step 2535 where the retrieved process status is analyzed to determine whether it is mature. If the retrieved process status is mature, then the function proceeds to step 2540. Otherwise, the function proceeds to step 2545. At step 2540, the OS 206 timer is released, and the function proceeds to step 2575 in FIG. 24C. At step 2545, the retrieved process's status is analyzed to determine whether the process is waiting in an OS 206 semaphore queue or linked list. If the retrieved process's status indicates that the process is waiting in an OS 206 semaphore queue, then the function proceeds to step 2550. Otherwise, the function proceeds to step 2555. At step 2550, the retrieved process is dequed from the OS 206 semaphore queue, the OS timer is released, the retrieved process is inserted into the OS 206 ready queue or linked list, and the retrieved process is scheduled with the OS 206 scheduler. The function then proceeds to step 2575 at FIG. 24C. At step 2555, the retrieved process's status is analyzed to determine whether the process is waiting in a mail box queue. If the retrieved process's status indicates that the process is waiting in a mail box queue, then the function proceeds to step 2560. Otherwise, the function proceeds to step 2565 at FIG. 24B. At step 2560, the retrieved process is dequed from the OS 206 mail box queue, the OS 206 timer associated with the process is released, the retrieved process is inserted into the OS 206 ready queue and the retrieved process is scheduled with the OS 206 scheduler. The function then proceeds to step 2575 at FIG. 24C. Referring now to FIG. 24B, at step 2565, the retrieved process's status is analyzed to determine whether it indicates that the process was suspended and needs to be reactivated. If the retrieved process's status indicates that the process needs to be reactivated, then the function proceeds to step 2570. Otherwise, the function proceeds to step 2575 in FIG. 24C. At step 2570, the retrieved process is stored into the OS 206 ready queue, and the retrieved process scheduled with the OS 206 scheduler. The function then proceeds to step 2575 at FIG. 24C. Referring now to FIG. 24C, at step 2575, the external interrupts are enabled with an appropriate OS 206 call, and the function proceeds to end at step 2580. DEVICE DRIVER INTERFACE/EVENT DRIVER PORTION Referring back to FIG. 2, the device driver interface 220 comprises an event driven portion 245 for communicating with device drivers 110. The device driver 110 communicates with the event driver portion 245 via logic path 246. The event driver portion 245 comprises an I/O done function (IODONE) and a system interface function (sys.sub.-- if). The IODONE function of the event driven portion 245 is invoked by a device driver when the information of an I/O request has been collected and stored in an associated ECB data structure. The IODONE function comprises the operations shown in the flow charts of FIGS. 25A-25B according to the preferred embodiment of the present invention. The IODONE function is provided with an ECB data structure from a device driver. Referring now to FIG. 25A, the IODONE function begins at step 2600 and proceeds to step 2605 where a determination is made concerning whether redirection event waiting is specified. If variable ECB. EVENT specified redirection event waiting, then the function proceeds to step 2610. Otherwise, the function proceeds to step 2625. At step 2610, the ECB data structure is stored in the OS's 206 redirection queue, and the function proceeds to step 2615 where the OS 206 is signalled that the ECB data structure is waiting in the redirection queue, and the function proceeds to end at step 2620. At step 2625, the mevq.sub.-- arry is accessed with the value of variable ecb. mevq.sub.-- id, and the MEVQ data structure identified by variable ecb. mevq.sub.-- id is retrieved. The function then proceeds to step 2630 where the process identified by variable mevq. pid is compared to the process identified by variable ecb. pid. If the process identified by variable mevq. pid is the same process identified by variable ecb. pid, then the function proceeds to step 2645. Otherwise, the function proceeds to step 2635 where the ECB data structure is released, and the function proceeds to end at step 2640. At step 2645, variable ECB. EVENT is analyzed to determine whether no event waiting is specified, or there has been no change in the status of the I/O request. If variable ECB. EVENT specifies no waiting, or there has been no change in the status of the I/O request, then the function proceeds to step 2650. Otherwise, the function proceeds to step 2660. At step 2650, the ECB data structure is released, and the function proceeds to end at step 2655. At step 2660, variable mevq. q.sub.-- sts is analyzed to determine whether the retrieved MEVQ data structure is disabled (i.e., that a previously requested active or redirection I/O request is being processed), or if variable mevq. mq. n indicates that the linked list containing the ECB data structure is not empty. If the MEVQ data structure is disabled or the linked list containing the ECB data structure is not empty, then the function proceeds to step 2665. Otherwise, the function proceeds to step 2675 in FIG. 25b. At step 2665, the ECB data structure is stored in the linked list identified by variable mevq. mq, and the function proceeds to end at step 2670. Referring now to FIG. 25B, at step 2675, variable ECB. EVENT is analyzed to determine whether active event waiting is requested. If variable ECB. EVENT indicates that active event waiting is requested, then the function proceeds to step 2680. Otherwise, the function proceeds to step 2710. At step 2680, the SET.sub.-- RTV function is invoked passing the ECB data structure and the IODONE function proceeds to step 2685 where the EV.sub.-- DVN function is invoked passing the ECB data structure. The IODONE function then proceeds to step 2690 where variable mevq. q.sub.-- sts is set to disabled in order to indicate that the current I/O request which specified active waiting is to be executed before any other active I/O requests are executed by the same process. The IODONE function then proceeds to step 2695 where the ECB data structure is released, and the function proceeds to end at step 2700. At step 2710, variable ECB. EVENT is analyzed to determine whether passive event waiting is requested. If variable ECB. EVENT indicates that passive event waiting is requested, then the function proceeds to step 2720. Otherwise, the function proceeds to step 2735. At step 2720, the ECB data structure is released, and the function proceeds to end at step 2725. At step 2735, the SET.sub.-- RTV function is invoked passing the ECB data structure, the OS 106 ready queue is accessed with the value of variable ecb. pid and the process which is identified by variable ecb. pid is retrieved. The function then proceeds to step 2740 where the user register of the retrieved process is swapped with the user register identified by variable ecb. us.sub.-- reg.sub.-- ptr. The function then proceeds to step 2745 where the suspended process identified by variable ecb. pid is reactivated with an OS 106 call. The function then proceeds to step 2750 where variable mevq. sts is set to disabled, and the function proceeds to step 2755 where the ECB data structure is released, and the function proceeds to end at step 2760. The sys.sub.-- if function of the event driven portion 245 is called by a device driver to invoke certain operations of the OS 106 via logic path 246, and comprises the operations shown in the flow charts of FIGS. 26A-26B according to the preferred embodiment of the present invention. The sys.sub.-- if function begins at step 2800 and proceeds to step 2805 where a determination is made concerning whether the si.sub.-- create function is specified. If the si.sub.-- create function is specified, then the sys.sub.-- if function proceeds to step 2810. Otherwise, the sys.sub.-- if function proceeds to step 2820. At step 2810, an OS 106 process is created with an appropriate OS 106 call, and the sys.sub.-- if function proceeds to end at step 2815. At step 2820, a determination of whether the si.sub.-- delete function is specified is made. If the si.sub.-- delete function is specified, then the sys.sub.-- if function proceeds to step 2825. Otherwise, the sys.sub.-- if function proceeds to step 2835. At step 2825 a specified process is deleted with an appropriate OS 106 call, and the function proceeds to end at step 2830. At step 2835, a determination of whether the si.sub.-- mcreate function is specified is made. If the si.sub.-- mcreate function is specified, then the sys.sub.-- if function proceeds to step 2840. Otherwise, the sys.sub.-- if function proceeds to step 2850. At step 2840, a multi-user process is created with an appropriate OS 106 call, and the sys.sub.-- if function proceeds to end at step 2845. At step 2850, a determination of whether the si.sub.-- m.sub.-- delete function is specified is made. If the si.sub.-- m.sub.-- delete function is specified, then the sys.sub.-- if function proceeds to step 2855. Otherwise, the sys.sub.-- if function proceeds to step 2865. At step 2855, a specified multi-user process is deleted with an appropriate OS 106 call, and the sys.sub.-- if function proceeds to end at step 2860. At step 2865, a determination of whether the si.sub.-- signal function is specified is made. If the sys.sub.-- if function is specified, the sys.sub.-- if function proceeds to step 2870. Otherwise, the sys.sub.-- if function proceeds to step 2880 in FIG. 26B. At step 2870, an OS 106 semaphore is signalled with an appropriate OS 106 call and the sys.sub.-- if function proceeds to end at step 2875. Referring now to FIG. 26B, at step 2880, a determination of whether the si.sub.-- getmp function is specified is made. If the si.sub.-- getmp function is specified, then the sys.sub.-- if function proceeds to step 2885. Otherwise, the sys.sub.-- if function proceeds to step 2895. At step 2895, a message buffer is retrieved with an appropriate OS 106 call, and the sys.sub.-- if function proceeds to end at step 2890. At step 2895, a determination of whether the si.sub.-- relmscb function is specified is made. If the si.sub.-- relmscb function is specified, then the sys.sub.-- if function proceeds to step 2900. Otherwise, the sys.sub.-- if function proceeds to end at step 2905. At step 2900, a specified message buffer is released with an appropriate OS 106 call, and the sys.sub.-- if function proceeds to end at step 2905. DEVICE DRIVER Referring back to FIGS. 1 and 2, a device driver 110 manages and controls the I/O requests to the physical device (hardware) 114, performs layer 1 (OSI model) functionalities (e.g. handshaking, synchronization, protocol verification and low level error checking), participates in event driven control, and processes physical device 114 interrupts. The device driver 110 accomplishes these tasks by using the following information: the operating status of the physical device, the identification of the specified physical device from which the I/O requests are to be collected, a queue for read events, a queue for write requests (i.e. write, WRCHR), a buffer queue for matured read requests, and a buffer queue for matured write requests. There are numerous ways in which the above information could be provided and used by the device driver. For example, in the preferred embodiment of the present invention a device control table (DCT) data structure is used. The DCT data structure may be implemented in C++ as illustrated in C++ in Table XI below.
TABLE XI
______________________________________
Typedef struct
WORD dev.sub.-- id; /* device ID */
union {
WORD d.sub.-- cls;
struct
{
BYTE dev.sub.-- type;
BYTE dev.sub.-- mode;
} dc;
} dev.sub.-- class; /* device
classification */
WORD operating.sub.-- status;
/* */
EV.sub.-- LIST
in.sub.-- event.sub.-- waiting.sub.-- q;
/* queue */
BUF.sub.-- QUE
in.sub.-- buffer.sub.-- q;
/* use by in waiting
events */
EV.sub.-- LIST
out.sub.-- event.sub.-- waiting.sub.-- q;
/* queue */
BUF.sub.-- QUE
out.sub.-- buffer.sub.-- q;
/* use by out waiting
events */
EV.sub.-- LST
control.sub.-- status.sub.-- ev.sub.-- q;
/* queue for status
event */
/* waiting only */
ADDRESS cfg.sub.-- tbl.sub.-- ptr;
/* pointer to specific */
/* configuration table */
ADDRESS sts.sub.-- tbl.sub.-- tr;
/* pointer to specific */
/* status table */
} DCT /* device control
table */
______________________________________
.COPYRGT. 1993 Telefonaktiebolaget L M Ericsson
Variable dev.sub.-- id (DCT. dev.sub.-- id) is used by the device driver to identify a particular physical device under its control. Variable dev.sub.-- type (DCT. dc. dev.sub.-- type) identifies the type of physical device specified. The variable dev.sub.-- mode (DCT. dc. dev.sub.-- mode) identifies the current operating mode of the physical device (e.g. master or slave). Variable operating.sub.-- status (DCT. operating.sub.-- status) indicates the current operating status of the specified physical device. The variable in.sub.-- event.sub.-- waiting.sub.-- q (DCT. in.sub.-- event.sub.-- waiting.sub.-- q) is used to store ecb data structures in connection with a read request. Variable in.sub.-- buffer.sub.-- q (DCT. in.sub.-- buffer.sub.-- q) is a queue used to store data associated with the read request. Variable out.sub.-- event.sub.-- waiting.sub.-- q (DCT. out.sub.-- event.sub.-- waiting.sub.-- q) is used to store ecb data structures associated with a write request. Variable out.sub.-- buffer.sub.-- q (DCT. out.sub.-- buffer.sub.-- q) is used to store data associated with the write request. Variable control.sub.-- status.sub.-- ev.sub.-- q (DCT. control.sub.-- status.sub.-- ev.sub.-- q) is used for storing ecb data structures associated with a I/O status request (i.e. a request made via the iosts function). Referring back to FIG. 1, the device driver 110 comprises a general system interface 111, a device specific interface 111 and a hardware dependent interface 112. The general system interface 111 is used by the I/O event manager 108 for specific I/O requests from a hardware device which is controlled by the device driver. The general system interface 111 comprises the following functions: initialize the device driver (Init), determine the current status of an I/O event within a specified hardware device (iosts), control the device driver (IOCTL), read information from a specified hardware device (read) and write information to a specified hardware device (write). The functions may be made accessible to the I/O event manager 108 in numerous ways. For example, in the preferred embodiment of the present invention, a device vector table (Dvt) data structure is used. A Dvt data structure may be implemented in C++ as illustrated in Table XII below.
TABLE XII
______________________________________
Typedef struct
VOID (init *)( );
/* initialization vector */
VOID (ioctl *)( );
/* io control vector */
VOID (read *)( );
/* read vector*/
VOID (write *)( );
/* write vector */
VOID (iosts *)( );
/* iostatus.sub.-- xxx vector */
DCT (*dct.sub.-- pt;;
/* device control table pointer */
int tbl.sub.-- id;
/* an indication of valid table. */
} DVT; /* device vector table
______________________________________
.COPYRGT. 1993 Telefonaktiebolaget L M Ericsson
The Dvt data structure contains the physical addresses for each of the device driven's functions. The Dvt data structure also contains a pointer to an associated DCT data structure, and a variable tbl.sub.-- id (Dvt. tbl.sub.-- id) for indicating a valid table. The IOCTL function of the device driven 110 opens, closes and reinitializes a device driver. FIGS. 27A-27C are a flow chart of the operations comprising the IOCTL function according to a preferred embodiment of the present invention. The IOCTL function is provided with an ECB data structure and a variable identifying a particular hardware device (dev). Referring now to FIG. 27A, the IOCTL function begins at step 3100 and proceeds to step 3105 where v | ||||||
