5.3.3 Testing for the Termination Flag

The following code shows how the el_autosense_thread( ) routine tests for the termination flag:

while (thread_should_halt(sc->autosense_thread)) {

1

printf("el%d: Autosense thread exiting\n", ifp->if_unit);

thread_halt_self();

}

2

1

2

Performs an initial test for the termination flag. The termination flag would have been set if another kernel thread had called the thread_terminate( ) routine for the el_autosense_thread( ) routine.

The thread_halt_self( ) routine performs the work that is associated with a variety of asynchronous traps (ASTs) for a kernel thread that terminates itself. A kernel thread terminates itself by calling the thread_halt_self( ) routine. The thread_halt_self( ) routine does not return to the caller.

5.3.4 Starting Up Statistics

The following code shows how the el_autosense_thread( ) routine starts up statistics:

s = splimp();

1

simple_lock(&sc->el_softc_lock); WRITE_CMD(sc, CMD_STATSENA); simple_unlock(&sc->el_softc_lock); splx(s);

1

Starts up statistics to test for the loss of the carrier during the transmit operation.

5.3.5 Entering the Packet Transmit Loop

The following code shows how the el_autosense_thread( ) routine enters the packet transmit loop:

good_xmits = passes = 0; 1 sc->lm_media_state = LAN_MEDIA_STATE_SENSING; while (good_xmits < 5) {

while (thread_should_halt(sc->autosense_thread)) { printf("el%d: Autosense thread exiting\n", ifp->if_unit); s = splimp();

simple_lock(&sc->el_softc_lock); WRITE_CMD(sc, CMD_STATSDIS);

5–20Implementing the Autoconfiguration Support Section (probe)

Page 78
Image 78
Compaq AA-RNG2A-TE manual Testing for the Termination Flag, Starting Up Statistics, Entering the Packet Transmit Loop