From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f678f,4c06a816f2164b37 X-Google-Attributes: gidf678f,public From: denham@denham.zk3.dec.com (Jeffrey M. Denham) Subject: Re: getting time and pid in kernel? Date: 1996/02/06 Message-ID: <4f7sab$n88@zk2nws.zko.dec.com>#1/1 X-Deja-AN: 138421543 distribution: world references: <4eo9vc$41@nntp5.u.washington.edu> organization: Digital Equipment Corporation reply-to: denham@zk3.dec.com (Jeffrey M. Denham) newsgroups: comp.unix.osf.misc In article <4eo9vc$41@nntp5.u.washington.edu>, kenm@u.washington.edu (Ken Marquess) writes: >Executive summary: I'm having problems determining the process id and >time of day from a kernel process, specifically a device driver top half. >If you know how to do either, I'd like to talk to you! > >Details: I'm trying to port/rewrite a driver (from AIX) for a pseudodevice. >The pseudodevice forms a pair of devices (kind of like tty/pty pairs) that >are used to support a remote tape drive (i.e. there is a local pseudo >device that emulates a tape drive, and sends the data to/from a real >drive on another system. In the device drivers, I write a trace table >for diagnostic purposes, which includes the time of day and pid. > >Aix supplied a getpid() that worked in kernel mode, and a global variable >called 'time' that was the current time. When I call getpid() in >DEC OSF/Digital Unix (3.2.C if it matters) the system abends. > >sys/time.h has some lines that imply there ought to be a global >variable called time, but I haven't figured out the right loader >flags or something - I never get a value other than 0. For the current pid, just use #include . . . pid_t pid; pid = u.u_procp->p_pid; For the time, the approach should be: #include struct timeval tv; microtime(&tv); -- ----------------------------------------------------------------------------- Jeff Denham, Unix Software Group, Digital Equipment Corporation email: denham@zk3.dec.com, voice: (603) 881-0057