From owner-freebsd-questions Fri Sep 29 11:56:24 2000 Delivered-To: freebsd-questions@freebsd.org Received: from horus.its.uow.edu.au (horus.its.uow.edu.au [130.130.68.25]) by hub.freebsd.org (Postfix) with ESMTP id ABEDA37B423 for ; Fri, 29 Sep 2000 11:56:19 -0700 (PDT) Received: from wumpus.its.uow.edu.au (wumpus.its.uow.edu.au [130.130.68.12]) by horus.its.uow.edu.au (8.9.3/8.9.3) with ESMTP id FAA15540 for ; Sat, 30 Sep 2000 05:56:12 +1100 (EST) From: King Fai Wong Received: (from kfw02@localhost) by wumpus.its.uow.edu.au (8.9.3/8.9.3) id FAA15467 for freebsd-questions@freebsd.org; Sat, 30 Sep 2000 05:56:12 +1100 (EST) Message-Id: <200009291856.FAA15467@wumpus.its.uow.edu.au> Subject: How to use gettimeofday() in kernel? To: freebsd-questions@freebsd.org Date: Sat, 30 Sep 2000 05:56:12 +1100 (EST) X-Mailer: ELM [version 2.4ME+ PL49 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hello, please help me to solve my problem I have a question on how to use the gettimeofday function inside the kernel of FreeBSD. I included the libraries /sys/proc.h and /sys/sysproto.h in the file that will be compiled inside Kernel. The following is code that I added to a function inside that file. The purpose of my code is to get a current time when running this function. #include #include #include : : struct proc d; struct gettimeofday_args T; : : gettimeofday(&p, &T); printf("Current time is: %ld and %ld\n", T.tp->sec, T.tp->usec); When I compile the kernel, there's no error message for that file. But I got the same value everytime I run this function(the time should be different). Output: Sep 30 04:51:17 myClient / kernel: Current time is: 11010 and 3 I think that I used this gettimeofday function incorrectly. Please tell me how to use this gettimeofday function correctly or tell me somewhere I can find the information of the usage of: int gettimeofday __P((struct proc *, struct gettimeofday_args *)) This gettimeofday function is inside /sys/kern/kern_time.c and it's prototype is inside /sys/sys/sysproto.h Actually, I have tried to use the other gettimeofday function outside kernel and compile the code with this function with cc and it was working properly. This gettimeofday function's prototype is inside /sys/sys/time.h Also, can you tell me that how to open a file inside the kernel or use the open function inside a program that run in kernel? Thanks you very much! Thomas To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message