5.3.12 Setting a Timer for the Current Kernel Thread
The following code shows how the el_autosense_thread( ) routine sets a timer for the current kernel thread:
wait = 0;
while ((prev_tint ==
assert_wait((vm_offset_t)&wait_flag, TRUE); thread_set_timeout(1*hz); 2 thread_block();
}
1
2
Waits until the transmit makes it out, a timeout occurs, or 4 seconds pass.
Sets the timer and puts the current thread to sleep. To use a timer, thread_set_timeout( ) must be called between an assert_wait( ) and a thread_block( ).
5.3.13 Testing for Loss of Carrier
The following code shows how the el_autosense_thread( ) routine tests for loss of carrier:
link_beat = 0; 1 switch
s = splimp();
i = READ_MD(sc);
if ((i & MD_VLB) != 0) link_beat=1;
WRITE_CMD(sc, CMD_WINDOW1);
case LAN_MEDIA_BNC: case LAN_MEDIA_AUI: s = splimp();
i =
wait = 100;
if
printf("el%d: autosense: %s carrier loss\n",
}
WRITE_CMD(sc, CMD_STATSENA);