Linux multi-core server time Function bug

Source: Internet
Author: User
I recently developed a multi-thread module and used Linux time functions to find a bug, in multiple core servers, the time function will suddenly return more than 4000 seconds longer than the normal time. the Linux operating system we use is RedHatEnterpriseLinux5.0, and the kernel version is 2.6.18-8. below el5 is the test program # include & lt; iostream & gt; # include & lt; pthread. h & gt

I recently developed a module that uses multithreading and Linux time functions.

The result shows that a bug occurs. in multiple core servers, the time function will suddenly return more than 4000 seconds more than the normal time.

The Linux operating system we use is Red Hat Enterprise Linux 5.0, kernel version 2.6.18-8. el5

Below are the test procedures

# Include
# Include
# Include
Using namespace std;
Void * thr1_fun (void * param)
{
Time_t now, pre;
Time (& pre );
Time (& now );
For (;;)
{
If (time (& now) =-1)
Perror ("time ");
If (now-pre)> 5)
{
Std: cout <"thr?fun" <"now-pre" <now-pre <std: endl;
Pre = now;
}
}
}
Void * thr2_fun (void * param)
{
Time_t now, pre;
Time (& pre );
Time (& now );
For (;;)
{
If (time (& now) =-1)
Perror ("time ");
If (now-pre)> 5)
{
Std: cout <"thr2_fun" <"now-pre" <now-pre <std: endl;
Pre = now;
}
}
}
Int main ()
{
Pthread_t th1, 22;
Pthread_create (& th1, NULL, thr1_fun, NULL );
Pthread_create (& Th1, NULL, thr2_fun, NULL );
Pthread_join (th1, NULL );
Pthread_join (2nd, NULL );
Return 0;
}

The two threads keep running the time function to get the current time. The running result is occasionally a thread now-pre will print more than 4000 values, and no time function execution failure is found, then the thread that prints more than 4000 values will die.

After checking the information, it seems to be a kernel bug.

This bug is not found in Ubuntu 10.04 and kernel version 2.6.32.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.