2 Copyright © 1995-2007, The AROS Development Team.
5 Desc: Task exception test adapted from tasktest.
9 #include <proto/alib.h>
10 #include <proto/exec.h>
11 #include <exec/tasks.h>
20 #define STACKSIZE 16384
25 struct ExecBase
* SysBase
)
27 printf("exception handler called\n");
28 /* this call of Signal will not call the handler
29 again, because the signals handled are disabled
30 during handler execution, we could even avoid
31 excbit from being restored after handling with:
32 signals ^= 1 << excbit */
33 Signal(parent
, 1 << sigbit1
);
37 static void entry(void)
39 sigbit2
= AllocSignal(-1);
40 /* signal the parent task via a task exceptions */
41 Signal(parent
, 1 << excbit
);
46 for (i
= 0; i
< 9; i
++)
51 for (i
= 0; i
< 10000; i
++)
57 Wait(0); /* Let the parent remove me */
60 int main(int argc
, char* argv
[])
62 parent
= FindTask(NULL
);
64 excbit
= AllocSignal(-1);
65 sigbit1
= AllocSignal(-1);
66 if (excbit
>= 0 && sigbit1
>= 0)
68 APTR oldexc
= parent
->tc_ExceptCode
;
69 parent
->tc_ExceptCode
= &handler
;
70 /* call handler on excbit */
71 SetExcept(1 << excbit
, 1 << excbit
);
73 struct Task
* t
= CreateTask("new task", 1, &entry
, STACKSIZE
);
77 /* we only want to get exceptioned once not on
78 every new call to Signal, so disable excbit */
79 SetExcept(0, 1 << excbit
);
83 for (i
= 0; i
< 10; i
++)
85 Signal(t
, 1 << sigbit2
);
92 parent
->tc_ExceptCode
= oldexc
;