
ENV

xx_get_sender_type(to_p,mp,proc_id,msg_type)
	PROC_ID *proc_id;
	struct xx_msg **mp;
	struct xx_process *to_p;
	int *msg_type;

	{
	if (!(*mp))
	{
		DELAY(to_p->msg_q_monitor,0)
	}
	/*
	printf("Slave: %d at delay \n",ntohl(xx_my_id.proc_table_indx));
	printf("Slave: %d thru delay \n",ntohl(xx_my_id.proc_table_indx));
	*/
	COPY_ID(proc_id,&((*mp)->sender));
	*msg_type = (*mp)->type;
	}

xx_copy_msg (msg_pt,msg,last_buf,length)
	struct xx_msg *msg_pt;
	char *msg;
	int *length;
    struct xx_buffer **last_buf;
	
	{
    char *xx_c1,*xx_c2;
    struct xx_buffer *xx_b1;
	int xx_i;

		/* now we copy from buffers into msg area 
		*/
			*last_buf=0;
			 if (length) *length = 0;
			for (xx_b1=msg_pt->first_buff,xx_c1=msg; 
			     (xx_b1);
			     xx_b1=xx_b1->link)
			{
			    for (xx_i=xx_b1->ln, xx_c2=xx_b1->buff;
				 (xx_i);
				 xx_i--)
			    {
					if (msg) *(xx_c1++) = *(xx_c2++);
			    }
			    if (length) *length += xx_b1->ln;
			    *last_buf = xx_b1;
			}
	    }

	xx_adj_links(mp,tp)
	struct xx_msg **mp;
	struct xx_process *tp;

	{
	if (tp->last_msg == *mp)
		tp->last_msg = ((struct xx_msg *) mp);
	*mp = (*mp)->link;
	if (!(tp->first_msg))
		tp->last_msg = 0;
	}

   xx_send_ack(proc_id,msg_pt,last_buf)
	PROC_ID *proc_id;
    struct xx_buffer *last_buf;
    struct xx_msg *msg_pt;

   {

	if (msg_pt->ack)
	{
	    SEND(proc_id,999)
	}
	LOCK(xx_cmem->avl_lock)
	msg_pt->link = xx_cmem->avail_msgs;
	xx_cmem->avail_msgs = msg_pt;
	if (last_buf)
	{
	    last_buf->link = xx_cmem->avail_buffs;
	    xx_cmem->avail_buffs = msg_pt->first_buff;
	}
	UNLOCK(xx_cmem->avl_lock)
    }

