From: Ingo van Lil <inguin@gmx.de>
To: user-mode-linux-devel@lists.sourceforge.net
Subject: [uml-devel] Multi-threaded applications and floating point registers
Date: Tue, 07 Apr 2009 19:47:50 +0200 [thread overview]
Message-ID: <49DB91C6.7030005@gmx.de> (raw)
Hello there,
I'm experiencing some weird problems with a multi-threaded application
I'm working on: A function which uses nothing but a single input value,
a few constants and a couple of floating point operations returns wrong
results from time to time. The application uses multiple threads, and
we're suspecting that the FPU state isn't properly saved and restored
when switching between threads within a process.
I've written a trivial test program which can be used to reproduce the
issue (see below). In theory the program should run forever, but in UML
it aborts after just a few seconds.
I have observed the issue both with kernel 2.6.28.8 and Busybox/uclibc
and with the demo kernel 2.6.24-rc7 and the Fedora10 image from the UML
home page. The problem does not happen with kernel 2.6.23.1. We're
suspecting that the problem has been introduced by the patch [1] to stop
saving the process FP state which has been applied just before 2.6.24-rc1.
Regards,
Ingo
[1]
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=42daba316557e597a90a730f61c762602b7f0e0c
======================================================================
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
static double my_abs(double d)
{
return (d >= 0) ? d : -d;
}
static void *fp_test_thread_func(void *arg)
{
volatile double value1 = *(double *)arg;
volatile double value2 = *(double *)arg;
while (1) {
if (my_abs(value1 - value2) > 0.0001) {
fprintf(stderr, "Inconsistent values: %lf, %lf\n", value1,
value2);
abort();
}
}
return NULL;
}
#define NUM_THREADS 2
int main(void)
{
pthread_t threads[NUM_THREADS];
int i;
for (i = 0; i < NUM_THREADS; i++) {
double startval = i;
pthread_create(&threads[i], NULL, fp_test_thread_func, &startval);
}
while (1) pause();
return 0;
}
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
next reply other threads:[~2009-04-07 17:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-07 17:47 Ingo van Lil [this message]
2009-04-07 18:27 ` [uml-devel] Multi-threaded applications and floating point registers Stanislav Meduna
2009-04-07 21:23 ` Ingo van Lil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49DB91C6.7030005@gmx.de \
--to=inguin@gmx.de \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.