Home > Linux Kernel Misc > Get current time in kernel

Get current time in kernel

The way to get the current time in kernel is by calling current_kernel_time() from the linux/time.h file. There is a macro called CURRENT_TIME() which just calls current_kernel_time(). It saves a few cycles to call it directly. The return type will be timespec struct type.

timespec has 2 fields – seconds and nanoseconds.

Advertisements
Categories: Linux Kernel Misc Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: