Module: xenomai-2.6
Branch: master
Commit: b0ece7f1365464fea6cffd93a1e3155adf1064ad
URL:    
http://git.xenomai.org/?p=xenomai-2.6.git;a=commit;h=b0ece7f1365464fea6cffd93a1e3155adf1064ad

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun Sep 21 20:46:37 2014 +0200

vfile/snapshot: avoid starvation by spinning 1us after every iteration

---

 ksrc/nucleus/vfile.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/ksrc/nucleus/vfile.c b/ksrc/nucleus/vfile.c
index c8e0363..066c12f 100644
--- a/ksrc/nucleus/vfile.c
+++ b/ksrc/nucleus/vfile.c
@@ -279,6 +279,15 @@ redo:
                        data += vfile->datasz;
                        it->nrdata++;
                }
+#ifdef CONFIG_SMP
+               {
+                       /* Leave some time for other cpus to get the lock */
+                       xnticks_t wakeup = xnarch_get_cpu_tsc();
+                       wakeup += xnarch_ns_to_tsc(1000);
+                       while ((xnsticks_t)(xnarch_get_cpu_tsc() - wakeup) < 0)
+                               cpu_relax();
+               }
+#endif
        }
 
        if (ret < 0) {


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to