예제 #1
0
void
_pq_insert_tail(pq_queue_t *pq, pthread_t pthread)
{
	int prio;

	/*
	 * Don't insert suspended threads into the priority queue.
	 * The caller is responsible for setting the threads state.
	 */
	if ((pthread->flags & PTHREAD_FLAGS_SUSPENDED) != 0) {
		/* Make sure the threads state is suspended. */
		if (pthread->state != PS_SUSPENDED)
			PTHREAD_SET_STATE(pthread, PS_SUSPENDED);
	} else {
		/*
		 * Make some assertions when debugging is enabled:
		 */
		_PQ_ASSERT_INACTIVE("_pq_insert_tail: pq_active");
		_PQ_SET_ACTIVE();
		_PQ_ASSERT_NOT_QUEUED(pthread,
		    "_pq_insert_tail: Already in priority queue");
		_PQ_ASSERT_PROTECTED("_pq_insert_tail: prioq not protected!");

		prio = pthread->active_priority;
		TAILQ_INSERT_TAIL(&pq->pq_lists[prio].pl_head, pthread, pqe);
		if (pq->pq_lists[prio].pl_queued == 0)
			/* Insert the list into the priority queue: */
			pq_insert_prio_list(pq, prio);

		/* Mark this thread as being in the priority queue. */
		pthread->flags |= PTHREAD_FLAGS_IN_PRIOQ;

		_PQ_CLEAR_ACTIVE();
	}
}
예제 #2
0
void
_pq_insert_tail(pq_queue_t *pq, pthread_t pthread)
{
	int prio = pthread->active_priority;

	/*
	 * Make some assertions when debugging is enabled:
	 */
	_PQ_ASSERT_INACTIVE("_pq_insert_tail: pq_active");
	_PQ_SET_ACTIVE();
	_PQ_ASSERT_NOT_QUEUED(pthread,
	    "_pq_insert_tail: Already in priority queue");

	TAILQ_INSERT_TAIL(&pq->pq_lists[prio].pl_head, pthread, pqe);
	if (pq->pq_lists[prio].pl_queued == 0)
		/* Insert the list into the priority queue: */
		pq_insert_prio_list(pq, prio);

	/* Mark this thread as being in the priority queue. */
	pthread->flags |= PTHREAD_FLAGS_IN_PRIOQ;

	_PQ_CLEAR_ACTIVE();
}
예제 #3
0
void
_pq_insert_head(pq_queue_t *pq, pthread_t pthread)
{
	int prio;

	/*
	 * Make some assertions when debugging is enabled:
	 */
	PQ_ASSERT_INACTIVE(pq, "_pq_insert_head: pq_active");
	PQ_SET_ACTIVE(pq);
	PQ_ASSERT_NOT_QUEUED(pthread,
	    "_pq_insert_head: Already in priority queue");

	prio = pthread->active_priority;
	TAILQ_INSERT_HEAD(&pq->pq_lists[prio].pl_head, pthread, pqe);
	if (pq->pq_lists[prio].pl_queued == 0)
		/* Insert the list into the priority queue: */
		pq_insert_prio_list(pq, prio);
	pq->pq_threads++;
	/* Mark this thread as being in the priority queue. */
	pthread->flags |= THR_FLAGS_IN_RUNQ;

	PQ_CLEAR_ACTIVE(pq);
}