Date: Mon, 20 Nov 1995 15:47:29 -0800 (PST) From: Julian Elischer <julian@ref.tfs.com> To: Andres.Vega_Garcia@sophia.inria.fr (Andres Vega Garcia) Cc: hackers@freebsd.org Subject: Re: Notion of time in kernel + malloc Message-ID: <199511202347.PAA04744@ref.tfs.com> In-Reply-To: <199511201935.UAA16241@fun.inria.fr> from "Andres Vega Garcia" at Nov 20, 95 08:35:33 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> > Hello, I'm adding some code to the kernel in order to modify the > packet scheduling policy (currently FIFO) to Fair Queueing, and I > need to have a notion of time (seconds (or tens of seconds) elapsed > since ...). > > => Can I use just gettimeofday?, or there is a better way? > (The #ifdef in sys/time.h disables the prototype for gettimeofday > when KERNEL is defined) the variable structure (struct timeval) time; can be examined directly to give time to the nearest 'tick' (100hz usually) however, calling the "microtime()" function (in /sys/i386/i386/microtime.s) will give you the value in 'time' updated to the nearest microsecond (within a certain error or course) where just reading 'time' will give you the last time that variable was updated.. using "microtime()" has of course the problem that it uses more cpu time.. On a pentium, microtime uses the pentium's Usec timer and is a lot quicker.. > > I have realized that in order to do malloc I need the "kernel" call > to malloc. As this is related with the ethernet drivers (and ppp), I > decided to use: > > malloc(sizeof(fs_ctx_t),M_DEVBUF,M_KERNEL) for the main structures No M_KERNEL is not the class as M_NOWAIT see /sys/sys/malloc.h M_NOWAIT says that if ther is no RAM an ERROR might be returned (result == 0) where M_WAITOK says that it will NEVER FAIL becaues it will wait until memory becomes available.. M_WAITOK MUST be called from the contect of a process and not from interrupt context. I don't know what M_KERNEL is but it's only used within the vm system that I can see. > and > malloc(sizeof(fs_ses_t),M_DEVBUF,M_NOWAIT) for the secondary > > => Is the above right? > > Thank you > ------- > Andres Vega Garcia INRIA - Sophia Antipolis > 2004, Route des Lucioles B.P. 93 > 06902 Sophia Antipolis Cedex, France > avega@sophia.inria.fr (+33)93.65.76.78 Fax:(+33)93.65.77.65 > or 66 > >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199511202347.PAA04744>