get current time in module problem

From: kernel.lover (cranium.2003_at_gmail.com)
Date: 04/14/05


Date: 13 Apr 2005 23:47:31 -0700

hello,
         Why am i getting oops in following kernel module on RH9 linux
with 2.4.20-8 kernel? I want to print current time in kernel. Is there
any other way to get current time in kernel?

#define __KERNEL__
#define MODULE
#include <linux/module.h>
#include <linux/config.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/time.h>

static int __init tt_init(void)
{
struct timeval *mytime=NULL;
do_gettimeofday(mytime);
printk(KERN_DEBUG "sec is = %ld\n",mytime->tv_sec);
return 0;
}

static void __exit tt_exit(void)
{
printk(KERN_DEBUG "Leaving Module\n");
}

module_init(tt_init);
module_exit(tt_exit);
MODULE_LICENSE("GPL");



Relevant Pages

  • Re: [GIT PULL] AlacrityVM guest drivers for 2.6.33
    ... the kernel was muck more than 2us. ... When you talk about trends the trend for IO is also to get faster. ... An exit will be always more expensive than passing something from ... even with all the tricks hardware can do. ...
    (Linux-Kernel)
  • patch uml-kill-subprocesses-on-exit.patch queued to -stable tree
    ... UML - kill subprocesses on exit ... I think the reason is the kernel ... linux guest is not trapped by the user mode linux kernel and is executed by ...
    (Linux-Kernel)
  • Re: Dumb question: Why are exceptions such as SIGSEGV not logged
    ... > It generates a small record for each exit, its trivial to parse the exit ... Is it possible to make kernel to print oops when SIGSEGV/SIGILL is ... when we have a crash in kernel space e.g. in sytem ... call that calling user space application which will crash. ...
    (Linux-Kernel)
  • Re: LPI exams - Ubuntu Certification
    ... I've been going through sample LPI exams, and I don't like some of the ... ISA disappeared years ago. ... Starting with the 2.4 kernel, ... that:x can save and exit as long as I am able to save and exit it? ...
    (Ubuntu)
  • Re: Vanilla kernels and usb key automount
    ... >>> is there anybody running vanilla kernels? ... >> What does lshal say about sda1 with vanilla and with the Ubuntu kernel? ... exit with 0, 0 seconds old ... device node '/dev/sda1' ...
    (Ubuntu)