コード例 #1
0
ファイル: lthread_sched.c プロジェクト: DrenfongWong/dpdk
/*
 * Returns 0 if there is a pending job in scheduler or 1 if done and can exit.
 */
static inline int _lthread_sched_isdone(struct lthread_sched *sched)
{
	return (sched->run_flag == 0) &&
			(_lthread_queue_empty(sched->ready)) &&
			(_lthread_queue_empty(sched->pready)) &&
			(sched->nb_blocked_threads == 0);
}
コード例 #2
0
ファイル: lthread_cond.c プロジェクト: 0day-ci/dpdk
/*
 * Broadcast a condition variable
 */
int lthread_cond_broadcast(struct lthread_cond *c)
{
	struct lthread *lt;

	if (c == NULL) {
		DIAG_EVENT(c, LT_DIAG_COND_BROADCAST, c, POSIX_ERRNO(EINVAL));
		return POSIX_ERRNO(EINVAL);
	}

	DIAG_EVENT(c, LT_DIAG_COND_BROADCAST, c, 0);
	do {
		/* drain the queue waking everybody */
		lt = _lthread_queue_remove(c->blocked);

		if (lt != NULL) {
			DIAG_EVENT(c, LT_DIAG_COND_BROADCAST, c, lt);
			/* wake up */
			_ready_queue_insert((struct lthread_sched *)lt->sched,
					    lt);
		}
	} while (!_lthread_queue_empty(c->blocked));
	_reschedule();
	DIAG_EVENT(c, LT_DIAG_COND_BROADCAST, c, 0);
	return 0;
}