/**********************************************************************
 
	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.

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

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

	machine dependent
	task system

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

#ifndef ___M_TASK_H___
#define ___M_TASK_H___

#ifdef __cplusplus
typedef	class LSimpleThread *	THREAD;
typedef	class LSemaphore *		D_SEM;
#else
typedef	void *	THREAD;
typedef	void *	D_SEM;
#endif


#define THREAD_BLOCK_SIZE	1000

typedef struct sw_hash {
	struct sw_hash *		next;
	unsigned int		key;
	THREAD			thread;
} SW_HASH;

 
typedef union thread_block {
	union thread_block *	next;
	SW_HASH			sw_hash;
} THREAD_BLOCK;



typedef void * TKEY;
int GET_TKEY(TKEY);
int _create_task(void (*func)(), int data, int priority, char *name,char*,int);

#define xx_create_task(func,data,pri,__f,__l) _create_task(func,data,pri,#func,__f,__l)

static void set_t_msg(int a) {}

void init_thread_block();
void * new_block();
void free_block(void * t);
void sw_init();

void init_test_task();
void test_task(char * str);



#endif
