Do not try to Handle a units IRQ if unit == NULL
[AROS.git] / test / tasktest.c
blobbe626fe80aae6aa006b06d55dc47fb49ec7bfdb6
1 /*
2 Copyright © 1995-2002, The AROS Development Team.
3 $Id$
4 */
6 #include <proto/exec.h>
7 #include <exec/execbase.h>
8 #include <exec/memory.h>
9 #include <exec/tasks.h>
10 #include <clib/exec_protos.h>
11 #include "memory.h"
12 #include <stdio.h>
14 int cnt;
15 int sigbit1,sigbit2;
16 struct Task *parent;
18 #define STACKSIZE 4096
20 static void entry(void)
22 int i=0;
24 sigbit2=AllocSignal(-1);
25 Signal(parent,1<<sigbit1);
26 if(sigbit2>=0)
28 for(i=0;i<9;i++)
30 Wait(1<<sigbit2);
31 cnt++;
33 for(i=0;i<10000;i++)
34 cnt++;
36 FreeSignal(sigbit2);
38 Wait(0);/* Let the parent remove me */
41 int main(int argc, char* argv[])
43 struct Task *t;
45 parent=SysBase->ThisTask;
47 sigbit1=AllocSignal(-1);
48 if(sigbit1>=0)
50 t=(struct Task *)AllocMem(sizeof(struct Task), MEMF_PUBLIC|MEMF_CLEAR);
51 if(t!=NULL)
53 UBYTE *s;
54 s=(UBYTE *)AllocMem(STACKSIZE, MEMF_PUBLIC|MEMF_CLEAR);
55 if(s!=NULL)
57 t->tc_Node.ln_Type=NT_TASK;
58 t->tc_Node.ln_Pri=1;
59 t->tc_Node.ln_Name="new task";
60 t->tc_SPLower=s;
61 t->tc_SPUpper=s+STACKSIZE;
62 #if AROS_STACK_GROWS_DOWNWARDS
63 t->tc_SPReg=(UBYTE *)t->tc_SPUpper-SP_OFFSET;
64 #else
65 t->tc_SPReg=(UBYTE *)t->tc_SPLower-SP_OFFSET;
66 #endif
67 NEWLIST(&t->tc_MemEntry);
68 AddTask(t,&entry,NULL);
69 Wait(1<<sigbit1);
70 if(sigbit2>=0)
72 int i;
73 for(i=0;i<10;i++)
75 Signal(t,1<<sigbit2);
76 printf("%d\n",cnt);
78 RemTask(t);
80 FreeMem(s,STACKSIZE);
82 FreeMem(t,sizeof(struct Task));
84 FreeSignal(sigbit1);
86 return 0;