Commit 6ab2cdb2 authored by Philippe Gerum's avatar Philippe Gerum

Add predicate for testing queue emptiness

git-svn-id: svn+ssh://svn.gna.org/svn/xenomai/trunk@1014 c6d672ea-8702-0410-b560-f74c916a59fe
parent 8b843d8a
2006-04-29 Philippe Gerum <rpm@xenomai.org>
* include/nucleus/queue.h, ksrc: Define and use a predicate for
testing queue emptiness.
2006-04-27 Dmitry Adamushko <dmitry.adamushko@gmail.com>
* ksrc/skins/native/intr.c (rt_intr_delete):
......
......@@ -88,7 +88,7 @@
#ifdef CONFIG_XENO_OPT_SCALABLE_SCHED
typedef xnmlqueue_t xnsched_queue_t;
#define sched_initpq initmlq
#define sched_countpq countmlq
#define sched_emptypq_p emptymlq_p
#define sched_insertpql insertmlql
#define sched_insertpqf insertmlqf
#define sched_appendpq appendmlq
......@@ -100,7 +100,7 @@ typedef xnmlqueue_t xnsched_queue_t;
#else /* ! CONFIG_XENO_OPT_SCALABLE_SCHED */
typedef xnpqueue_t xnsched_queue_t;
#define sched_initpq initpq
#define sched_countpq countpq
#define sched_emptypq_p emptypq_p
#define sched_insertpql insertpql
#define sched_insertpqf insertpqf
#define sched_appendpq appendpq
......
This diff is collapsed.
......@@ -28,7 +28,7 @@ static int xncore_unload_hook (void)
/* If no thread is hosted by the Xenomai pod, unload it. We are
called with interrupts off, nklock locked. */
if (nkpod == &__core_pod && countq(&nkpod->threadq) == 0)
if (nkpod == &__core_pod && emptyq_p(&nkpod->threadq))
{
xncore_umount();
return 1;
......
......@@ -67,7 +67,7 @@ void xnmod_alloc_glinks (xnqueue_t *freehq)
allocating memory eventually. Otherwise, we have to raise a
fatal error right now. */
if (countq(freehq) == 0)
if (emptyq_p(freehq))
xnpod_fatal("cannot allocate generic holders");
return;
......
......@@ -944,7 +944,7 @@ static unsigned xnpipe_poll (struct file *file,
if (testbits(state->status,XNPIPE_KERN_CONN))
w_mask |= (POLLOUT|POLLWRNORM);
if (countq(&state->outq) > 0)
if (!emptyq_p(&state->outq))
r_mask |= (POLLIN|POLLRDNORM);
if (!r_mask)
......
......@@ -699,7 +699,7 @@ static inline void xnpod_switch_zombie (xnthread_t *threadout,
xnltt_log_event(xeno_ev_finalize,threadout->name,threadin->name);
if (countq(&nkpod->tdeleteq) > 0 &&
if (!emptyq_p(&nkpod->tdeleteq) &&
!testbits(threadout->status,XNROOT))
{
xnltt_log_event(xeno_ev_callout,"SELF-DELETE",threadout->name);
......@@ -1020,7 +1020,7 @@ int xnpod_start_thread (xnthread_t *thread,
nkpod->schedhook(thread,XNREADY);
#endif /* __XENO_SIM__ */
if (countq(&nkpod->tstartq) > 0 &&
if (!emptyq_p(&nkpod->tstartq) &&
!testbits(thread->status,XNROOT))
{
xnltt_log_event(xeno_ev_callout,"START",thread->name);
......@@ -1335,7 +1335,7 @@ void xnpod_delete_thread (xnthread_t *thread)
}
else
{
if (countq(&nkpod->tdeleteq) > 0 &&
if (!emptyq_p(&nkpod->tdeleteq) &&
!testbits(thread->status,XNROOT))
{
xnltt_log_event(xeno_ev_callout,"DELETE",thread->name);
......@@ -2030,7 +2030,7 @@ void xnpod_rotate_readyq (int prio)
sched = xnpod_current_sched();
if (sched_countpq(&sched->readyq) == 0)
if (sched_emptypq_p(&sched->readyq))
goto unlock_and_exit; /* Nobody is ready. */
xnltt_log_event(xeno_ev_rdrotate,sched->runthread,prio);
......@@ -2311,8 +2311,8 @@ void xnpod_switch_fpu (xnsched_t *sched)
*
* Preempts the running thread (because a higher priority thread has
* just been readied). The thread is re-inserted to the front of its
* priority group in the ready thread queue. Must must be called
* with nklock locked, interrupts off.
* priority group in the ready thread queue. Must be called with
* nklock locked, interrupts off.
*/
static inline void xnpod_preempt_current_thread (xnsched_t *sched)
......@@ -2324,14 +2324,16 @@ static inline void xnpod_preempt_current_thread (xnsched_t *sched)
__setbits(thread->status,XNREADY);
#ifdef __XENO_SIM__
if (sched_getheadpq(&sched->readyq) != &thread->rlink)
if (getheadpq(&sched->readyq) != &thread->rlink)
nkpod->schedhook(thread,XNREADY);
else if (sched_countpq(&sched->readyq) > 1)
else if (nextpq(&sched->readyq,&thread->rlink) != NULL)
{
/* The running thread is still heading the ready queue and
more than one thread is linked to this queue, so we may
refer to the following element as a thread object
(obviously distinct from the running thread) safely. */
(obviously distinct from the running thread) safely. Note:
this works because the simulator never uses multi-level
queues for holding ready threads. --rpm */
thread = link2thread(thread->rlink.plink.next,rlink);
nkpod->schedhook(thread,XNREADY);
}
......@@ -2582,7 +2584,7 @@ void xnpod_schedule (void)
nkpod->schedhook(runthread,XNRUNNING);
#endif /* __XENO_SIM__ */
if (countq(&nkpod->tswitchq) > 0 &&
if (!emptyq_p(&nkpod->tswitchq) &&
!testbits(runthread->status,XNROOT))
{
xnltt_log_event(xeno_ev_callout,"SWITCH",runthread->name);
......
......@@ -230,7 +230,7 @@ static void xnsynch_clear_boost (xnsynch_t *synch,
__clrbits(synch->status,XNSYNCH_CLAIMED);
downprio = lastowner->bprio;
if (countpq(&lastowner->claimq) == 0)
if (emptypq_p(&lastowner->claimq))
__clrbits(lastowner->status,XNBOOST);
else
{
......@@ -343,7 +343,7 @@ xnthread_t *xnsynch_wakeup_one_sleeper (xnsynch_t *synch)
xnlock_put_irqrestore(&nklock,s);
xnarch_post_graph_if(synch,0,countpq(&synch->pendq) == 0);
xnarch_post_graph_if(synch,0,emptypq_p(&synch->pendq));
return thread;
}
......@@ -412,7 +412,7 @@ xnpholder_t *xnsynch_wakeup_this_sleeper (xnsynch_t *synch,
xnlock_put_irqrestore(&nklock,s);
xnarch_post_graph_if(synch,0,countpq(&synch->pendq) == 0);
xnarch_post_graph_if(synch,0,emptypq_p(&synch->pendq));
return nholder;
}
......@@ -477,7 +477,7 @@ int xnsynch_flush (xnsynch_t *synch, xnflags_t reason)
xnltt_log_event(xeno_ev_syncflush,synch,reason);
status = countpq(&synch->pendq) > 0 ? XNSYNCH_RESCHED : XNSYNCH_DONE;
status = emptypq_p(&synch->pendq) ? XNSYNCH_DONE : XNSYNCH_RESCHED;
while ((holder = getpq(&synch->pendq)) != NULL)
{
......@@ -497,7 +497,7 @@ int xnsynch_flush (xnsynch_t *synch, xnflags_t reason)
xnlock_put_irqrestore(&nklock,s);
xnarch_post_graph_if(synch,0,countpq(&synch->pendq) == 0);
xnarch_post_graph_if(synch,0,emptypq_p(&synch->pendq));
return status;
}
......@@ -538,7 +538,7 @@ void xnsynch_forget_sleeper (xnthread_t *thread)
xnthread_t *owner = synch->owner;
int rprio;
if (countpq(&synch->pendq) == 0)
if (emptypq_p(&synch->pendq))
/* No more sleepers: clear the boost. */
xnsynch_clear_boost(synch,owner);
else if (getheadpq(&synch->pendq)->prio !=
......@@ -560,7 +560,7 @@ void xnsynch_forget_sleeper (xnthread_t *thread)
}
}
xnarch_post_graph_if(synch,0,countpq(&synch->pendq) == 0);
xnarch_post_graph_if(synch,0,emptypq_p(&synch->pendq));
}
/*!
......
......@@ -523,7 +523,7 @@ int ftruncate (int fd, off_t len)
}
err = 0;
if (!countq(&shm->mappings))
if (emptyq_p(&shm->mappings))
{
/* Temporary storage, in order to preserve the memory contents upon
resizing, if possible. */
......
......@@ -122,7 +122,7 @@ u_long ev_send (u_long tid,
/* Only the task to which the event group pertains can
pend on it. */
if (countpq(xnsynch_wait_queue(&evgroup->synchbase)) > 0)
if (!emptypq_p(xnsynch_wait_queue(&evgroup->synchbase)))
{
u_long flags = task->waitargs.evgroup.flags;
u_long bits = task->waitargs.evgroup.events;
......
......@@ -243,9 +243,9 @@ static u_long q_destroy_internal (psosqueue_t *queue)
removeq(&psosqueueq,&queue->link);
if (countpq(xnsynch_wait_queue(&queue->synchbase)) > 0)
if (!emptypq_p(xnsynch_wait_queue(&queue->synchbase)))
err = ERR_TATQDEL;
else if (countq(&queue->inq) > 0)
else if (!emptyq_p(&queue->inq))
err = ERR_MATQDEL;
else
err = SUCCESS;
......@@ -428,7 +428,7 @@ again:
mbuf = link2psosmbuf(holder);
xnarch_post_graph(&queue->synchbase,
countq(&queue->inq) > 0 ? 2 : 0); /* POSTED or EMPTY */
emptyq_p(&queue->inq) ? 0 : 2); /* EMPTY or POSTED */
}
if (mbuf->len > buflen)
......
......@@ -379,7 +379,6 @@ dnl Nucleus setup -- set reasonable values.
AC_DEFINE_UNQUOTED(CONFIG_XENO_OPT_TIMING_PERIODIC,1,[config])
AC_DEFINE_UNQUOTED(CONFIG_XENO_OPT_TIMING_PERIOD,0,[config])
AC_DEFINE_UNQUOTED(CONFIG_XENO_OPT_SYS_HEAPSZ,128,[config])
AC_DEFINE_UNQUOTED(CONFIG_XENO_OPT_SCALABLE_PRIOS,256,[config])
AC_DEFINE(CONFIG_XENO_OPT_REGISTRY,1,[config])
AC_DEFINE_UNQUOTED(CONFIG_XENO_OPT_REGISTRY_NRSLOTS,1024,[config])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment