wip commit. acpi button driver.
[AROS.git] / test / exec / tasktest2.c
blob850634dbbd90a49cfd76bf5625929996a0ca9cc9
1 /*
2 Copyright © 1995-2017, 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 #include "exec_platform.h"
16 int cnt;
17 int sigbit1,sigbit2;
18 struct Task *parent;
20 #define STACKSIZE 4096
22 static void entry(void)
24 int i=0;
26 sigbit2=AllocSignal(-1);
27 Signal(parent,1<<sigbit1);
28 if(sigbit2>=0)
30 for(i=0;i<9;i++)
32 Wait(1<<sigbit2);
33 cnt++;
35 for(i=0;i<10000;i++)
36 cnt++;
38 FreeSignal(sigbit2);
40 Wait(0);/* Let the parent remove me */
43 int main(int argc, char* argv[])
45 struct Task *t;
47 parent=FindTask(NULL);
49 sigbit1=AllocSignal(-1);
50 if(sigbit1>=0)
52 t=(struct Task *)AllocMem(sizeof(struct Task), MEMF_PUBLIC|MEMF_CLEAR);
53 if(t!=NULL)
55 UBYTE *s;
56 s=(UBYTE *)AllocMem(STACKSIZE, MEMF_PUBLIC|MEMF_CLEAR);
57 if(s!=NULL)
59 t->tc_Node.ln_Type=NT_TASK;
60 t->tc_Node.ln_Pri=0;
61 t->tc_Node.ln_Name="new task";
62 t->tc_SPLower=s;
63 t->tc_SPUpper=s+STACKSIZE;
64 #if AROS_STACK_GROWS_DOWNWARDS
65 t->tc_SPReg=(UBYTE *)t->tc_SPUpper-SP_OFFSET;
66 #else
67 t->tc_SPReg=(UBYTE *)t->tc_SPLower-SP_OFFSET;
68 #endif
69 NEWLIST(&t->tc_MemEntry);
70 AddTask(t,&entry,NULL);
71 SetTaskPri(t,1);
73 printf("%p %p %p %p\n",
74 t, GET_THIS_TASK,
75 FindTask("new task"), FindTask(NULL));
77 Wait(1<<sigbit1);
78 if(sigbit2>=0)
80 int i;
81 for(i=0;i<10;i++)
83 Signal(t,1<<sigbit2);
84 printf("%d\n",cnt);
86 RemTask(t);
88 FreeMem(s,STACKSIZE);
90 FreeMem(t,sizeof(struct Task));
92 FreeSignal(sigbit1);
94 return 0;