/* $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 */

#ident "$Header: cpus_online.c 1.2 89/05/31 $"

/*
 * cpus_online.c
 *	cpus_online() function definition.
 */

#include <sys/tmp_ctl.h>

#include "parc.h"

/*
 * cpus_online()
 *	Returns the number of CPUs available for use.
 */

cpus_online() 
{
	register int	cpu;
	register int	ngood;
	register int	ncpus;


	ncpus = tmp_ctl(TMP_NENG, 0);

	ngood = 0;
	for (cpu = 0; cpu < ncpus; cpu++)
		if (tmp_ctl(TMP_QUERY, cpu) == TMP_ENG_ONLINE)
			ngood++;
	return(ngood);
}

/*
 * cpus_online_()	fortran version.
 *	Returns the number of CPUs available for use.
 */

cpus_online_() 
{
	register int	cpu;
	register int	ngood;
	register int	ncpus;


	ncpus = tmp_ctl(TMP_NENG, 0);

	ngood = 0;
	for (cpu = 0; cpu < ncpus; cpu++)
		if (tmp_ctl(TMP_QUERY, cpu) == TMP_ENG_ONLINE)
			ngood++;
	return(ngood);
}
