Here is a programm to show a simple (the simplest ?) race condition.
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/types.h>
MODULE_AUTHOR("tyler@xxxxxxxx");
MODULE_DESCRIPTION("Race condition");
MODULE_LICENSE("GPL");
static int value = 10;
static int thread_function(void *data)
{
char msg[50];
sprintf(msg, "%d + 5 = ", value);
value += 5;
schedule();
printk(KERN_ERR "%s%d\n", msg, value);
return 0;
}
static int __init init_module_race(void)
{
pid_t th1, th2;
th1 = kernel_thread(thread_function, NULL, 0);
th2 = kernel_thread(thread_function, NULL, 0);
return 0;
}
static void __exit exit_module_race(void)
{
return;
}
module_init(init_module_race);
module_exit(exit_module_race);
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/