LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-04-2012, 12:51 PM   #1
sindhu4sind
Member
 
Registered: Apr 2012
Posts: 38

Rep: Reputation: Disabled
Jiffies to seconds


Hello everybody,

how to convert jiffies to seconds?

I have a sample code:

Code:
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/jiffies.h>
#include <linux/timer.h>
unsigned long js, je, tet;
int netblock_init_module(void){
    js = jiffies;
    printk("\n[Jiffies start Time : %lu]\nModule Started.\n", js);
    return 0;
}

void netblock_cleanup_module(void) {
    je = jiffies;
    printk("\n[Jiffies End Time : %lu]\nModule Removed.\n", je);
    tet = je - js;
    printk("\nEnd Time [%lu] - Start Time [%lu]: \nTotlal elapsed Time [%lu]\n",js,je, tet);

}

module_init(netblock_init_module);
module_exit(netblock_cleanup_module);

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("JIFFIES EXAMPLE");
MODULE_AUTHOR("RAHEEL");
Output is as :

Quote:
$insmod jiffexample.ko
[Jiffies start Time : 13363583]

Module Started

$rmmod jiffexample.ko
[Jiffies End Time : 13361588]

Module Removed.

End Time 13361588 - Start Time 1336358
Total Elapsed time [1605]

Now i want to get converted time in seconds.. how its possible to convert this elapsed time 1605 in seconds? or alternatively can you please tell me how many jiffies are in a second?

Thanks in advance..
looking for your nice response
Sindhu
 
Old 06-04-2012, 01:02 PM   #2
teckk
Senior Member
 
Registered: Oct 2004
Distribution: FreeBSD Arch
Posts: 1,752

Rep: Reputation: 189Reputation: 189
http://en.wikipedia.org/wiki/Jiffie
 
1 members found this post helpful.
Old 06-04-2012, 01:04 PM   #3
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942
Quote:
Originally Posted by sindhu4sind View Post
how to convert jiffies to seconds?
include/linux/jiffies.h: jiffies_to_msecs(jiffies) / 1000U .
 
1 members found this post helpful.
Old 06-04-2012, 01:29 PM   #4
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-15 with Cinnamon & KDE
Posts: 1,346
Blog Entries: 3

Rep: Reputation: 86
Quote:
Originally Posted by sindhu4sind View Post
...
Now i want to get converted time in seconds.. how its possible to convert this elapsed time 1605 in seconds? or alternatively can you please tell me how many jiffies are in a second?

Thanks in advance..
looking for your nice response
Sindhu
As I understand things, a "jiffy" expresses the clock tick interval on the workstation under consideration. This means that it is tied to whichever processor and buss etc are in use that the time. Take a look at the following:
Code:
prompt$ dmesg | grep delay

[    0.000006] Calibrating delay loop (skipped), value calculated using timer frequency.. 4983.93 BogoMIPS (lpj=9967860)
I don't know what "BogoMIPS" or "lpj" stand for either.

[b]Follow-Up:
This item explains Bogo-MIPS: http://en.wikipedia.org/wiki/Bogomips and
offers a chart for processor comparison. There is also this Mini-HOWTO:
http://tldp.org/HOWTO/BogoMips/bogo-list.html

Can anyone explain "lpj=NNNN"?

I got this from my Intel® i5™ laptop. Someone more knowing that I might can get you closer to a real answer.

ASIDE -- A hundred years ago, I worked on VAX/VMS systems. We'd call them mainframes by today's standards.
They had a similar time unit called the "micro-fortnight". A "fortnight" being 14 days, that is 1,209,600 seconds making a micro-fortnight (14*24*60*60)/1.oE6 = 1.209 seconds. Something in VAX/VMS took some amount of time
that was just short of 1.209 seconds and so the name stuck. I forget what it was used for or why it was important.

Good luck and keep us posted on your results,
~~~ 0;-Dan

Last edited by SaintDanBert; 06-04-2012 at 01:35 PM.
 
  


Reply

Tags
linux, time


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert total no of seconds in the format hour minutes and seconds suchi_s Programming 15 03-15-2011 11:34 AM
[SOLVED] Experiencing freezing up to 5 seconds every 10 seconds, could these be the problem? Switch7 Slackware 10 11-16-2009 04:36 PM
What is user mode jiffies and kernel mode jiffies of a process iamjayanth Linux - Software 2 09-14-2009 11:35 PM
hdparm power save, 15 seconds of spin, 5 seconds of rest... Romanus81 Linux - Laptop and Netbook 1 01-01-2009 05:24 PM
Jiffies Rawjoe Linux - Kernel 5 08-08-2006 07:42 AM


All times are GMT -5. The time now is 08:16 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration