/**********************************************************************
 
	Copyright (C) 2003 Hirohisa MORI <joshua@nichibun.ac.jp>
 
	This program is free software; you can redistribute it 
	and/or modify it under the terms of the GLOBALBASE 
	Library General Public License (G-LGPL) as published by 

	http://www.globalbase.org/
 
	This program is distributed in the hope that it will be 
	useful, but WITHOUT ANY WARRANTY; without even the 
	implied warranty of MERCHANTABILITY or FITNESS FOR A 
	PARTICULAR PURPOSE.

**********************************************************************/



#include	<stdio.h>
#include	"task.h"

#define TEST_SIZE	1000

SEM test_sems[TEST_SIZE];
int test_flag;

void
init_test_task()
{
int i;
	for ( i = 0 ; i < TEST_SIZE ; i ++ )
		test_sems[i] = new_lock(0);
	test_flag = 1;
}

void
test_task(char * str)
{
int i;
	if ( test_flag == 0 )
		return;
	printf("TEST(%i) %s...",get_tid(),str);
	fflush(stdout);
	for ( i = 0 ; i < TEST_SIZE ; i ++ )
		lock_task(test_sems[i]);
	for ( i = TEST_SIZE-1 ; i >= 0 ; i -- )
		unlock_task(test_sems[i],"test");
	printf("END\n");
}
