[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Printing at lower priority



This is a patch for your problem.
I'll try to submit it as an RFE.
The parallel port routine takes an interrupt for every single byte sent.
This ties the system in knots.
Look at vmstat or iostat in repeat mode to see that interrupt time is >90%.
This patch reduces it to 2-6%.

Index: sys/dev/ic/lpt.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/lpt.c,v
retrieving revision 1.4
diff -c -r1.4 lpt.c
*** sys/dev/ic/lpt.c	2000/07/21 17:41:02	1.4
--- sys/dev/ic/lpt.c	2001/01/07 00:08:50
***************
*** 406,420 ****
  	    (sc->sc_flags & LPT_NOINTR))
  		return 0;
  
  	/* is printer online and ready for output */
  	if (NOT_READY() && NOT_READY_ERR())
  		return -1;
  
  	if (sc->sc_count) {
  		u_int8_t control = sc->sc_control;
  		/* send char */
  		bus_space_write_1(iot, ioh, lpt_data, *sc->sc_cp++);
! 		delay (50);
  		bus_space_write_1(iot, ioh, lpt_control, control | LPC_STROBE);
  		sc->sc_count--;
  		bus_space_write_1(iot, ioh, lpt_control, control);
--- 406,432 ----
  	    (sc->sc_flags & LPT_NOINTR))
  		return 0;
  
+ 	for (;;) {
+ 	    int i ;
  	/* is printer online and ready for output */
+ 	    for (i = 0 ; i < 10 ; i++)
+ 		if (NOT_READY())
+ 		    delay(5) ;
+ 		else
+ 		    goto ok ;
+ 	    NOT_READY_ERR() ;
+ 	    return -1 ;
+ #if 0
  	if (NOT_READY() && NOT_READY_ERR())
  		return -1;
+ #endif
  
+ ok:
  	if (sc->sc_count) {
  		u_int8_t control = sc->sc_control;
  		/* send char */
  		bus_space_write_1(iot, ioh, lpt_data, *sc->sc_cp++);
! 		delay (5);
  		bus_space_write_1(iot, ioh, lpt_control, control | LPC_STROBE);
  		sc->sc_count--;
  		bus_space_write_1(iot, ioh, lpt_control, control);
***************
*** 425,430 ****
--- 437,444 ----
  	if (sc->sc_count == 0) {
  		/* none, wake up the top half to get more */
  		wakeup((caddr_t)sc);
+ 		break ;
+ 	}
  	}
  
  	return 1;