## Physical Device Driver Reference

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

### DeRegister

When a monitor application terminates normally (by calling DosMonClose and DosMonExit) or abnormally (for example, Ctrl+C has been pressed or the monitor buffers have been corrupted), the file system sends a monitor close request to the character device driver. When the physical device driver receives this request, it must call on the monitor dispatcher to remove all monitors registered by the terminating process from all monitor chains belonging to the physical device driver. It calls the DevHlp_DeRegister routine for each nonempty chain (that is, for each monitor chain for which there are monitors registered).

DeRegister is called at task time. On calling DeRegister, the physical device driver places the parameters to the call in the registers as illustrated in the table below. For each call to DeRegister, the physical device driver provides the monitor dispatcher with the PID (Process ID) of the terminating application and the handle of a nonempty monitor chain.

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

    |Registers      |Parameter Description                        |

    |---------------+---------------------------------------------|

    |AX             |Device Driver's Handle for Monitor Chain     |

    |---------------+---------------------------------------------|

    |BX             |PID of Monitor Process                       |

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

For each call to DeRegister, the monitor dispatcher removes all monitors registered by the terminating process from the specified monitor chain, and returns to the physical device driver the number of monitors still registered with the chain. During the call to DeRegister, the monitor dispatcher reduces the risk for data loss by:

Suspending subsequent calls to MonWrite and MonFlush to place data into the monitor chain until the monitors belonging to the terminating application have been removed from the monitor chain.

Marking the monitor as closed to subsequent data movement through DosMonReads and DosMonWrites.

Draining all data from the monitor in an orderly manner.

The physical device driver or another monitor downstream in the monitor chain must not be blocked, so that all data can be drained from the monitor . The physical device driver must not issue the call to DeRegister in either of the following situations:

It has previously blocked on a monitor chain notification routine call because it cannot process the data received into its monitor chain buffer.

The return of a critical data record is pending (for example, the physical device driver is waiting to receive a data record from the monitor chain before processing additional request packets).

Depending on timing and the well-behaved nature of the monitor, data records might be lost during monitor termination. A monitor can inadvertently consume data records if it does not stop taking data to the data stream before it terminates.