knowing-current-time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I read that in order to get the current time by using
do_gettimeofday( struct timeval *tv) function we need
to disable the inturrepts because we can't access both
fields of timeval struct tv_sec and tv_usec. Why is it
so ? also i read code from Linux device drivers book
that  
they are reading all the values in /proc interface. is
it compulsary to do so ?

This is my code ....

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/time.h>
#include <asm-i386/system.h>
                                                      
                                                      
               
int init_module(void)
{
        struct timeval tv;
        unsigned long flags;
        save_flags( flags );
        cli();
        do_gettimeofday(&tv);
        printk("\n\t The current time is %f",( time_t
)tv.tv_sec);
        restore_flags( flags );
        sti();
        return 0;
}
                                                      
                                                      
               
void cleanup_module(void)
{
                                                      
                                                      
               
}
 
Plz guide me where i am going wrong.

Thanks in advance,
Deepak Joshi.



		
___________________________________________________________ 
How much free photo storage do you get? Store your holiday 
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux