#include <linux16/config.h>
#include <linux16/types.h>
#include <arch/system.h>
#include <linux16/sched.h>

void taska();
void taskb();

extern __ptask _reglasttask, _regnexttask;

void main()
{
	__u16 a;
	__pregisters set; 
	__u16 num, tnum;

/*	We set the scheduler up as task #0, and this as task #1 */

	setup_arch();
	arch_setuptasks();
	if (!kernel_fork()) {
		if (!kernel_fork())  
			taskb();
		else
			if ((tnum = kernel_fork())) {
				task[tnum].t_priority = 5;	
				taskb();
			}	
			else
				taska();
	}
	/* This is the idle task! */
	while (1) {
#asm
b:		
	jmp b
	mov ax, #0xe43
	int 0x10
#endasm
	schedule();
	};
}

void taska()
{
/* Print 'A' and switch tasks */
	while (1) {
#asm
		mov ax, #0xe41
		int 0x10	
#endasm
		schedule();
	};
}

void taskb()
{
while (1) {
#asm
	mov ax, #0xe42
	int 0x10
#endasm
	schedule();
  };
}

