sem_release(): Simplify (made by rasky on scfirm).
authorbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 21 Oct 2004 10:48:57 +0000 (10:48 +0000)
committerbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 21 Oct 2004 10:48:57 +0000 (10:48 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@255 38d2e660-2303-0410-9eaa-f027e97ec537

kern/sem.c

index 9e5905f6ae4db7c34777c0a5b7d04d752ef03d97..2262cb081d8306693cc13036903c1d0a4f92f69f 100755 (executable)
@@ -15,6 +15,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.5  2004/10/21 10:48:57  bernie
+ *#* sem_release(): Simplify (made by rasky on scfirm).
+ *#*
  *#* Revision 1.4  2004/08/25 14:12:09  rasky
  *#* Aggiornato il comment block dei log RCS
  *#*
@@ -141,20 +144,19 @@ void sem_release(struct Semaphore *s)
        DISABLE_IRQSAVE(flags);
 
        /*
-        * Decremement nesting count and check if the semaphore
+        * Decrement nesting count and check if the semaphore
         * has been fully unlocked
         */
        if (--s->nest_count == 0)
        {
+               Process *proc;
+
                /* Disown semaphore */
                s->owner = NULL;
 
-               /* Anybody still waiting for this semaphore? */
-               if (!ISLISTEMPTY(&s->wait_queue))
+               /* Give semaphore to the first applicant, if any */
+               if ((proc = (Process*)REMHEAD(&s->wait_queue)))
                {
-                       /* Give semaphore to the first applicant */
-                       Process *proc = (Process *)s->wait_queue.head;
-                       REMOVE((Node *)proc);
                        s->nest_count = 1;
                        s->owner = proc;
                        SCHED_ENQUEUE(proc);