## Physical Device Driver Reference

[prev][next][parent][TOC]

### Registering and Terminating a Monitor

During monitor registration and termination, the monitor dispatcher communicates with the character device driver on behalf of the monitor application through the OS/2 file system and IOCtl interface. The application initiates OS/2 monitor functions, and the character device driver receives and responds to the corresponding requests. The following figure illustrates the monitor function calls made by the application and the corresponding responses by the character device driver.

The following figure shows an Application to the Device Driver Interface.

                                                                  MONITOR

    APPLICATION         FILE SYSTEM          DEVICE DRIVER      DISPATCHER

    /-----\               /-----\               /-----\            /-----\

    |  (1)| DosMonOpen    |     | Open request  |     MonitorCreate|     |

    |    ----------------|    ----------------|    -------------|     |

    |  (3)| DosMonClose   |     | Close request |     | DeRegister |     |

    |    ----------------|    ----------------|    -------------|     |

    |     |               \-----/               |     |            |     |

    |     |           IOCtl INTERFACE           |     |            |     |

    |     |               /-----\               |     |            |     |

    |  (2)| DosMonReg     |     Register request|     | Register   |     |

    |    ----------------|    ----------------|    -------------|     |

    |     |               |     |               |     |            |     |

    \-----/               \-----/               \-----/            \-----/

For example, Character Device Driver Z defines only one data stream for its device. Application X wishes to monitor Character Device Driver Z's data stream:

1.Application X calls DosMonOpen to get a handle to Character Device Driver Z. Through the file system, the monitor dispatcher sends an Open request for monitors to Character Device Driver Z on behalf of Application X. It is recommended to wait until Step 2, when the device driver receives the monitor Register IOCtl.

If Character Device Driver Z has not already created a monitor chain for its data stream, Character Device Driver Z can call the DevHlp_ MonitorCreate to create the monitor chain.

2.Application X calls DosMonReg to register Monitor Y with the monitor chain for Character Device Driver Z's data stream. On behalf of Application X, the monitor dispatcher issues a monitor register IOCtl request to Character Device Driver Z.

If Character Device Driver Z has not already defined a monitor chain for its data stream, Character Device Driver Z must now call MonitorCreate to create the monitor chain.

On receiving the monitor register IOCtl request, Character Device Driver Z calls the DevHlp_Register so that the monitor dispatcher can install Application X in the monitor chain.

3.When Application X stops monitoring Character Device Driver Z's data stream, Application X calls DosMonClose.

The monitor dispatcher sends a Close request for monitors through the file system to Character Device Driver Z on behalf of Application X.

On receiving the monitor close request, Character Device Driver Z must call the DevHlp_DeRegister so the monitor dispatcher can remove Application X from the monitor chain.