FreeBSD/usr.sbin/camdd/camdd.c
/*
 * Return a buffer to the reader thread when we have completed writing it.
 */
Return a buffer to the reader thread when we have completed writing it.
Return a buffer to the reader thread when we have completed writing it .
int
camdd_complete_peer_buf(struct camdd_dev *dev, struct camdd_buf *peer_buf)
{
	struct kevent ke;
	int retval = 0;
	EV_SET(&ke, (uintptr_t)&dev->peer_dev->peer_done_queue, EVFILT_USER, 0,
	       NOTE_TRIGGER, 0, NULL);
	pthread_mutex_unlock(&dev->mutex);
	pthread_mutex_lock(&dev->peer_dev->mutex);
	STAILQ_INSERT_TAIL(&dev->peer_dev->peer_done_queue, peer_buf,
			   work_links);
	dev->peer_dev->num_peer_done_queue++;
	retval = kevent(dev->peer_dev->kq, &ke, 1, NULL, 0, NULL);
	if (retval == -1)
		warn("%s: unable to add peer_done_queue kevent", __func__);
	else
		retval = 0;
	pthread_mutex_unlock(&dev->peer_dev->mutex);
	pthread_mutex_lock(&dev->mutex);
	return (retval);
}
int camdd_complete_peer_buf ( struct camdd_dev * dev , struct camdd_buf * peer_buf ) { struct kevent ke ; int retval = 0 ; EV_SET ( & ke , ( uintptr_t ) & dev -> peer_dev -> peer_done_queue , EVFILT_USER , 0 , NOTE_TRIGGER , 0 , NULL ) ; pthread_mutex_unlock ( & dev -> mutex ) ; pthread_mutex_lock ( & dev -> peer_dev -> mutex ) ; STAILQ_INSERT_TAIL ( & dev -> peer_dev -> peer_done_queue , peer_buf , work_links ) ; dev -> peer_dev -> num_peer_done_queue ++ ; retval = kevent ( dev -> peer_dev -> kq , & ke , 1 , NULL , 0 , NULL ) ; if ( retval == -1 ) warn ( " " , __func__ ) ; else retval = 0 ; pthread_mutex_unlock ( & dev -> peer_dev -> mutex ) ; pthread_mutex_lock ( & dev -> mutex ) ; return ( retval ) ; }
Return a buffer to the reader thread when we have completed writing it.
Return a buffer to the reader thread when we have completed writing it .
/*
	 * Setup the event to let the other thread know that we have
	 * completed a buffer.
	 */ /*
	 * Drop our lock and acquire the other thread's lock before
	 * manipulating 
	 */ /*
	 * Put the buffer on the reader thread's peer done queue now that
	 * we have completed it.
	 */ /*
	 * Send an event to the peer thread to let it know that we've added
	 * something to its peer done queue.
	 */ /*
	 * Drop the other thread's lock and reacquire ours.
	 */