[PATCH] RT: Checks for cmpxchg in get_task_struct_rcu()

Daniel Walker
2005-09-21T23:38:00Z

Adds a check for cmpxchg in get_task_struct_rcu(), and implements the
case when it doesn't exist.

Signed-Off-By: Daniel Walker <dwalker@mvista.com>

Index: linux-2.6.13/include/linux/sched.h
===================================================================
--- linux-2.6.13.orig/include/linux/sched.h
+++ linux-2.6.13/include/linux/sched.h
@@ -1026,13 +1026,21 @@ static inline int get_task_struct_rcu(st
{
int oldusage;

+#ifdef __HAVE_ARCH_CMPXCHG
do {
oldusage = atomic_read(&t->usage);
if (oldusage == 0) {
return 0;
}
} while (cmpxchg(&t->usage.counter,
- oldusage, oldusage + 1) != oldusage);
+ oldusage, oldusage + 1) != oldusage);
+#else
+ oldusage = atomic_read(&t->usage);
+ if (oldusage == 0) {
+ return 0;
+ }
+ atomic_inc(&t->usage);
+#endif
return 1;
}