Quantcast
Channel: Active questions tagged linux-kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 12323

linux kernel: understand how jiffies diff is calculated

$
0
0

I came across the following code in the kernel:

/* * Have the 32 bit jiffies value wrap 5 minutes after boot * so jiffies wrap bugs show up earlier. */             #define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ))static inline u32 cstamp_delta(unsigned long cstamp){        return (cstamp - INITIAL_JIFFIES) * 100UL / HZ;}

where cstamp value is in jiffies.

This is the code from net/ipv4/devinet.c where IP address per interface is implemented (among other things).

I see that INITIAL_JIFFIES macro takes the value of 5 minutes (300) and converts it in jiffies (-300*HZ), and typecasting ensures correct value wrapping.

But why is it explicitly set to negative value (-300*HZ)?

I'm not sure, in what units cstamp_delta() returns?


Viewing all articles
Browse latest Browse all 12323

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>