Fix the ntc problems.
[bertos.git] / bertos / kern / sem.c
index 0f31fa067b9fff651945b60076adaf3e855e05f4..ac4e7d969bb4afa5bd505a182a16a59b9a31372f 100644 (file)
  * the GNU General Public License.
  *
  * Copyright 2001, 2004 Develer S.r.l. (http://www.develer.com/)
- * Copyright 1999, 2000, 2001 Bernardo Innocenti <bernie@develer.com>
- *
+ * Copyright 1999, 2000, 2001 Bernie Innocenti <bernie@codewiz.org>
  * -->
  *
  * \brief Semaphore based synchronization services.
  *
  * \version $Id$
- *
- * \author Bernardo Innocenti <bernie@develer.com>
+ * \author Bernie Innocenti <bernie@codewiz.org>
  */
 
 #include "sem.h"
+#include <cfg/debug.h>
+
+#include <cpu/irq.h> // ASSERT_IRQ_DISABLED()
+
 #include <kern/proc.h>
 #include <kern/proc_p.h>
 #include <kern/signal.h>
-#include <cfg/debug.h>
 
 INLINE void sem_verify(struct Semaphore *s)
 {
@@ -53,7 +54,6 @@ INLINE void sem_verify(struct Semaphore *s)
        ASSERT(s->nest_count < 128);   // heuristic max
 }
 
-
 /**
  * \brief Initialize a Semaphore structure.
  */
@@ -128,7 +128,7 @@ void sem_obtain(struct Semaphore *s)
                 * be locked for us.
                 */
                proc_permit();
-               proc_schedule();
+               proc_switch();
        }
        else
        {
@@ -178,7 +178,7 @@ void sem_release(struct Semaphore *s)
                {
                        s->nest_count = 1;
                        s->owner = proc;
-                       SCHED_ENQUEUE(proc);
+                       ATOMIC(SCHED_ENQUEUE(proc));
                }
        }