public inbox for ecos-patches@sourceware.org
 help / color / mirror / Atom feed
* Correct threads hanging situation on SMP architecture
@ 2010-04-23 10:08 Christophe Coutand
  0 siblings, 0 replies; only message in thread
From: Christophe Coutand @ 2010-04-23 10:08 UTC (permalink / raw)
  To: ecos-patches

[-- Attachment #1: Type: text/plain, Size: 394 bytes --]

Hi,

Related to post
http://ecos.sourceware.org/ml/ecos-discuss/2010-04/msg00026.html, here
is a possible small patch to avoid thread "hanging" situation on SMP
targets. It can be easily reproduced using the FreeBSD network stack and
HTTPD packages. Call to cyg_thread_self() in spl_any()
(packages\net\bsd_tcpip\current\src\ecos\synchc) can return wrong value.

Regards,
Christophe

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 734 bytes --]

diff -r 418d34334c77 packages/kernel/current/include/sched.hxx
--- a/packages/kernel/current/include/sched.hxx	Thu Apr 01 13:17:10 2010 +0000
+++ b/packages/kernel/current/include/sched.hxx	Fri Apr 23 11:14:11 2010 +0200
@@ -358,7 +358,24 @@
 
 inline Cyg_Thread *Cyg_Scheduler_Base::get_current_thread()
 {
-    return current_thread[CYG_KERNEL_CPU_THIS()];
+#ifdef CYGPKG_KERNEL_SMP_SUPPORT
+
+  cyg_uint32 istate;
+  Cyg_Thread * self;
+
+  HAL_DISABLE_INTERRUPTS( istate );
+
+  self = current_thread[CYG_KERNEL_CPU_THIS()];
+
+  HAL_RESTORE_INTERRUPTS( istate );
+
+  return self;
+
+#else
+
+  return current_thread[CYG_KERNEL_CPU_THIS()];
+
+#endif
 }
 
 inline void Cyg_Scheduler_Base::set_current_thread(Cyg_Thread *thread )

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-04-23 10:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-23 10:08 Correct threads hanging situation on SMP architecture Christophe Coutand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).