Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ncar!tank!nic.MR.NET!hal!ncoast!allbery From: zeeff@b-tech.ann-arbor.mi.us.UUCP (Jon Zeeff) Newsgroups: comp.sources.misc Subject: v04i128: Simple nap() for Sys V Message-ID: <4874@b-tech.ann-arbor.mi.us> Date: 22 Oct 88 01:17:42 GMT Sender: allbery@ncoast.UUCP Reply-To: zeeff@b-tech.ann-arbor.mi.us.UUCP (Jon Zeeff) Organization: Branch Technology, Ann Arbor, MI Lines: 131 Approved: allbery@ncoast.UUCP Posting-number: Volume 4, Issue 128 Submitted-by: "Jon Zeeff" Archive-name: s5nap The kernel has a method for < 1 sleeps - allow user process to do so also. #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh ft.c <<'END_OF_ft.c' X X/* X Written by Jon Zeeff umix!b-tech!zeeff X X This "device driver" uses the kernel delay() call to allow calls X to nap() from user processes. Nap() is like sleep, but with finer X resolution. X X Compile with cc -O -c ft.c X X Written for a Sys V.3 system, but should work on others. X X For Sys V.3: X X Make a new kernel according to the instructions and then: X mknod /dev/ft c 28 0 X X modules/ft/config: X character(28) X prefix = ft X functions = open, close, read X X Edit systems/system.std and add ft. X Copy ft.o to modules/ft/config X X*/ X X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X X/* use a raw device interface */ X Xftopen() {} X Xftread(dev) Xint dev; X{ Xdelay(u.u_count); Xu.u_count = 0; X} X Xftwrite() {} Xftclose() {} X END_OF_ft.c if test 1082 -ne `wc -c nap.c <<'END_OF_nap.c' X Xnap(ticks) Xunsigned ticks; X{ Xstatic int fd=0; X Xif (fd == 0) fd = open("/dev/ft",0); Xread(fd,(char *)0,ticks); X X} X END_OF_nap.c if test 115 -ne `wc -c test.c <<'END_OF_test.c' X Xmain() X{ X Xnap(1000); X X} X END_OF_test.c if test 26 -ne `wc -c