macsim/src/noc/pbuffer.c
// function is used exclusively by core buffers
// The first flit from the source 'rank' is dequeued
function is used exclusively by core buffers
The first flit from the source 'rank' is dequeued
function is used exclusively by core buffers The first flit from the source ' rank ' is dequeued
flit_container_t *msgdeque_rank(p_buffer_t *buffer, rank_t rank){
	p_buffer_entry_t *result, *previous;
	result = buffer->head;
	unsigned i;
	for(i = buffer->size - buffer->slots;i>0;i--){
		if(result->flit->src == rank){				
			if(result == buffer->head){
				buffer->head = result->next;
				if(buffer->head == NULL){
					buffer->tail = NULL;
				}
			} else{						
				previous->next = result->next;
				if(result == buffer->tail){
					buffer->tail = previous;
				}
			}
			flit_container_t *flit = result->flit;
			free(result);
			buffer->slots++;				
			return flit;					
		}
		previous = result;
		result = result->next;
	}
	return NULL;
}
flit_container_t * msgdeque_rank ( p_buffer_t * buffer , rank_t rank ) { p_buffer_entry_t * result , * previous ; result = buffer -> head ; unsigned i ; for ( i = buffer -> size - buffer -> slots ; i > 0 ; i -- ) { if ( result -> flit -> src == rank ) { if ( result == buffer -> head ) { buffer -> head = result -> next ; if ( buffer -> head == NULL ) { buffer -> tail = NULL ; } } else { previous -> next = result -> next ; if ( result == buffer -> tail ) { buffer -> tail = previous ; } } flit_container_t * flit = result -> flit ; free ( result ) ; buffer -> slots ++ ; return flit ; } previous = result ; result = result -> next ; } return NULL ; }
function is used exclusively by core buffers
The first flit from the source 'rank' is dequeued
function is used exclusively by core buffers The first flit from the source ' rank ' is dequeued
// if the entry which is going to be removed is the head flit let the head pointer point to the next entry // else the next-pointer of the previous entry needs to be adjusted // increment available slots // pointer to flit_container_t