From owner-freebsd-realtime Fri Sep 29 11:59:14 2000 Delivered-To: freebsd-realtime@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 C219D37B423 for ; Fri, 29 Sep 2000 11:59:03 -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 FAA15733 for ; Sat, 30 Sep 2000 05:59:02 +1100 (EST) From: King Fai Wong Received: (from kfw02@localhost) by wumpus.its.uow.edu.au (8.9.3/8.9.3) id FAA15474 for freebsd-realtime@freebsd.org; Sat, 30 Sep 2000 05:59:02 +1100 (EST) Message-Id: <200009291859.FAA15474@wumpus.its.uow.edu.au> Subject: How to use gettimeofday() in the kernel? To: freebsd-realtime@freebsd.org Date: Sat, 30 Sep 2000 05:59:02 +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-realtime@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-realtime" in the body of the message From owner-freebsd-realtime Fri Sep 29 13: 1:36 2000 Delivered-To: freebsd-realtime@freebsd.org Received: from mass.osd.bsdi.com (adsl-63-202-176-106.dsl.snfc21.pacbell.net [63.202.176.106]) by hub.freebsd.org (Postfix) with ESMTP id 10D7C37B49B for ; Fri, 29 Sep 2000 13:01:31 -0700 (PDT) Received: from mass.osd.bsdi.com (localhost [127.0.0.1]) by mass.osd.bsdi.com (8.11.0/8.9.3) with ESMTP id e8TK2pA06174; Fri, 29 Sep 2000 13:02:52 -0700 (PDT) (envelope-from msmith@mass.osd.bsdi.com) Message-Id: <200009292002.e8TK2pA06174@mass.osd.bsdi.com> X-Mailer: exmh version 2.1.1 10/15/1999 To: King Fai Wong Cc: freebsd-realtime@freebsd.org Subject: Re: How to use gettimeofday() in the kernel? In-reply-to: Your message of "Sat, 30 Sep 2000 05:59:02 +1100." <200009291859.FAA15474@wumpus.its.uow.edu.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 29 Sep 2000 13:02:51 -0700 From: Mike Smith Sender: owner-freebsd-realtime@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. You don't. The variable time_second contains the current time, UTC. > 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? If you are trying to read/write files inside the kernel, you are probably trying to do the wrong thing. If you insist on doing this, look at the kernel linker (sys/kern/kern_linker.c) for examples. -- ... every activity meets with opposition, everyone who acts has his rivals and unfortunately opponents also. But not because people want to be opponents, rather because the tasks and relationships force people to take different points of view. [Dr. Fritz Todt] V I C T O R Y N O T V E N G E A N C E To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-realtime" in the body of the message