Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site onfcanim.UUCP Path: utzoo!watmath!watnot!watcgl!onfcanim!dave From: dave@onfcanim.UUCP (Dave Martindale) Newsgroups: net.unix-wizards Subject: Re: busy looping in kernel, time question Message-ID: <14809@onfcanim.UUCP> Date: Thu, 17-Apr-86 12:32:11 EST Article-I.D.: onfcanim.14809 Posted: Thu Apr 17 12:32:11 1986 Date-Received: Fri, 18-Apr-86 04:45:48 EST References: <234@Shasta.ARPA> Reply-To: dave@onfcanim.UUCP (Dave Martindale) Organization: ONF, Montreal Lines: 39 In article <234@Shasta.ARPA> alex@lancelot writes: > > Assume I want to busy loop in the kernel for 100 milliseconds, how >many times (approx) should I go around a loop which increments an int? > Do you *really* want to lock up the processor for that long? sleep/wakeup would make much better use of the processor. But if your really want a busy loop, you realize that this depends on what processor you are running on, which you didn't mention? A Cray-2 and an 8088 can both run UNIX, but there is a fair difference in the number of instructions they execute in 100 ms. Tell you what. Why not write a program like this: main(argc, argv) char **argv; { long i, limit, atol(); limit = atol(argv[1]); for (i = 0; i < limit; i++) ; } Then run it until you find a value of the argument that gives an execution time of 10 seconds. Divide that number by 100, and you will know how many times to go around a loop to get 100 milliseconds pretty accurately. Seriously, wouldn't it have made more sense to just write the test program and have your answer in 3 minutes, rather than posting an article that several thousand people would read, particularly since they can't answer it from the information given? USENET is a wonderful resource for obtaining hard-to-find information. I hate to see its effectiveness damaged by people using it as a crutch. Dave Martindale