1: #include "nap.h" 2: #if NNAP > 0 3: #include "param.h" 4: #include <sys/systm.h> 5: #include <sys/tty.h> 6: #include <sys/dir.h> 7: #include <sys/user.h> 8: #include <sys/proc.h> 9: 10: #define N_NAP 32 11: #define NAPPRI 31 12: 13: int ttnap[N_NAP]; 14: 15: /*ARGSUSED*/ 16: napioctl(dev, cmd, addr, flags) 17: dev_t dev; 18: caddr_t addr; 19: { 20: int wakeup(); 21: int *ptr; 22: 23: for(ptr=ttnap; *ptr && (ptr <= &ttnap[N_NAP]); ptr++) 24: ; 25: if(ptr == &ttnap[N_NAP]) { 26: u.u_error = ENXIO; 27: return; 28: } 29: 30: *ptr = u.u_procp->p_pid; 31: timeout(wakeup, ptr, cmd); 32: sleep(ptr, NAPPRI); 33: *ptr = 0; 34: } 35: 36: /*ARGSUSED*/ 37: napclose(dev, flags) 38: dev_t dev; 39: { 40: int *ptr; 41: 42: for(ptr=ttnap; (*ptr != u.u_procp->p_pid) && (ptr <= &ttnap[N_NAP]); ptr++) 43: ; 44: if(*ptr == u.u_procp->p_pid) 45: *ptr = 0; 46: } 47: #endif NNAP