예제 #1
0
FUNCTION Msgh *sysbuf ()
{
	register Msgh  *m;
	register int   count = 0;

  Debug

	/* first try to allocate space */
	m = (Msgh *) l_create (msgdefsize);

	if (m == NULLMSGH)
	{  /* no space--get desperate */
		while (BITTST (emergbuf->flags, LOCKED))
		{
			if (count++ == 10000)
			{                   /* Wait for the MI to free the buffer..  */
				_pprintf ("Waiting for emergbuf to be unlocked... %x\n",
						emergbuf);
				send_e_from_q();        /* clear emergbuf */
				count = 0;
			}
		}
		m = emergbuf;   /* grab emergbuf */
	}

	clear ( m, sizeof (Msgh) ); /* clear it */

	if ( m == emergbuf )
		BITSET (m->flags, LOCKED); /* Tell rest of system not to use */

	return m;
}
예제 #2
0
size_t snprintf(char* str, size_t len, const char* fstr, ...)
{
  size_t ret = 0;
  PrintfInfo printfInfo;

  va_list args;
  va_start(args, fstr);

  INIT_PRINTF_INFO(&printfInfo, -1, str);
  printfInfo.bufSize = len;

  ret = _pprintf(&printfInfo, fstr, args);

  va_end(args);
 
  return (ret);
}
예제 #3
0
breakpoint ()
{
	register int torf = FALSE;

	if ( object_breakpoint )
	{
		if ( strcmp ( xqting_ocb->name, breakpoint_object ) == 0 )
			torf = TRUE;
	}

	if ( time_breakpoint )
	{
		if ( geSTime ( xqting_ocb->svt.simtime, breakpoint_time ) )
			torf = TRUE;
	}

	if ( torf )
	{
		_pprintf ( "Breakpoint on Object %s at Time %.2f\n",
			xqting_ocb->name, xqting_ocb->svt.simtime );
	}
	return ( torf );
}
예제 #4
0
FUNCTION calculateCritPath()
{
	Ocb * o, *critOcb;
	State *s, *nxtState;
	truncState * lastState;
	Byte duplicateEpt;

	if ( tw_node_num == CRITPATHMASTER )
	{
		_pprintf("Calculating critical path\n");
	}

	duplicateEpt = 0;

	/* Look through each object to find the local object with the state with
		the highest ept. */

	for ( o = fstocb_macro; o != NULLOCB; o = nxtocb_macro ( o ) )
	{

		/* Ignore the stdout object. */

		if ( o->runstat == ITS_STDOUT )
			continue;


		/* Truncate any states still in the state queue.  They're only
			needed for critical path purposes, at this point, and having
			all the states in one queue simplifies matters. */


		for ( s = fststate_macro ( o ) ; s != NULLSTATE; s = nxtState )
		{
			nxtState = nxtstate_macro ( s );

			truncateState ( s );

		}

		lastState = l_prev_macro ( o->tsqh );
		
		/* We expect all objects to have at least one state. */

		if ( l_ishead_macro ( lastState ))
		{
			_pprintf("ocb %s has no state in truncated state queue\n", o->name );
			tester();
		}


		/* Now check to see if this state's Ept is the highest seen so far.
			If so, change both highEpt and critOcb.  In any case, watch for
			duplicates of the highest Ept using duplicateEpt. */

		if ( lastState->Ept > highEpt )
		{	
			highEpt = lastState->Ept; 
			critOcb = o;
			duplicateEpt = 0;
		}
		else
		if ( lastState->Ept < highEpt )
			duplicateEpt = 0;
		else
			duplicateEpt++ ;
	}

	/* We're not prepared to deal with duplicate Epts yet. */

	if ( duplicateEpt )
	{
		_pprintf("duplicate final EPT's = %d\n", highEpt );
		tester();
	}
		
	if ( tw_node_num == CRITPATHMASTER )
	{
		/* If this node is the master, check its contribution immediately. */

		/* highEpt keeps the recently calculated contribution for this node.
			highestEpt, used only on the CRITPATHMASTER node, keeps the
			globally highest Ept for all nodes that have reported, so far. */

		if ( highestEpt < highEpt )
		{
			highestEpt = highEpt;
			strcpy ( critObject, critOcb->name );
			critNode = CRITPATHMASTER;
		}
		else
		if ( highestEpt == highEpt )
		{
			_pprintf("duplicate high Epts %d and %d\n", highestEpt, highEpt);
			tester();
		}	

		nodesReporting--;

		/* The master was the last node to report (or is the only node). 
			Call startCritPath().  (A function is used here because the
			same code in startCritPath() will also be used by checkCritPath().
			So both routines call the function startCritPath(), rather than
			duplicate the code.) */

		if ( nodesReporting == 0 )
		{
			startCritPath ();
		}
	}
	else
	{

		/* This is not the master node.  Send the CP contribution to the
			master node. */

		Msgh * p;
		Critmsg * q;

		p = sysbuf (); 
		q = ( Critmsg *) (p + 1);

		sprintf ( p->snder, "CRIT%d", tw_node_num );
		sprintf ( p->rcver, "CRIT%d", CRITPATHMASTER );
		q->Ept = highEpt;
		q->node = tw_node_num;
		sprintf ( q->object, critOcb->name );

		sysmsg ( CRITMSG, p, sizeof (Critmsg), CRITPATHMASTER );
	}
}
예제 #5
0
static size_t _fprintf(int fd, const char* fstr, va_list args)
{
  PrintfInfo* pInfo = NULL;
  pInfo = getPrintfInfo(fd);
  return (_pprintf(pInfo, fstr, args));
}