Esempio n. 1
0
static void
add_quad_job( struct quad_job_que *que, struct quad_header *quad, quad_job_routine routine )
{
#if INSTANT_NOTEMPTY_NOTIFY
   boolean empty;
#endif

   /* Wait for empty slot, see if the que is empty.
    */
   pipe_mutex_lock( que->que_mutex );
   while ((que->last + 1) % NUM_QUAD_JOBS == que->first) {
#if !INSTANT_NOTEMPTY_NOTIFY
      pipe_condvar_broadcast( que->que_notempty_condvar );
#endif
      pipe_condvar_wait( que->que_notfull_condvar, que->que_mutex );
   }
#if INSTANT_NOTEMPTY_NOTIFY
   empty = que->last == que->first;
#endif
   que->jobs_added++;
   pipe_mutex_unlock( que->que_mutex );

   /* Submit new job.
    */
   que->jobs[que->last].input = quad->input;
   que->jobs[que->last].inout = quad->inout;
   que->jobs[que->last].routine = routine;
   que->last = (que->last + 1) % NUM_QUAD_JOBS;

#if INSTANT_NOTEMPTY_NOTIFY
   /* If the que was empty, notify consumers there's a job to be done.
    */
   if (empty) {
      pipe_mutex_lock( que->que_mutex );
      pipe_condvar_broadcast( que->que_notempty_condvar );
      pipe_mutex_unlock( que->que_mutex );
   }
#endif
}
Esempio n. 2
0
/**
 * Called by the rendering threads to increment the fence counter.
 * When the counter == the rank, the fence is finished.
 */
void
lp_fence_signal(struct lp_fence *fence)
{
   if (LP_DEBUG & DEBUG_FENCE)
      debug_printf("%s %d\n", __FUNCTION__, fence->id);

   pipe_mutex_lock(fence->mutex);

   fence->count++;
   assert(fence->count <= fence->rank);

   if (LP_DEBUG & DEBUG_FENCE)
      debug_printf("%s count=%u rank=%u\n", __FUNCTION__,
                   fence->count, fence->rank);

   /* Wakeup all threads waiting on the mutex:
    */
   pipe_condvar_broadcast(fence->signalled);

   pipe_mutex_unlock(fence->mutex);
}