start service tasks separately in-case platforms need to perform additional set-up...
[AROS.git] / test / taskstorage.c
blobace4c41561d8f91c3d9656d68ac5fb3fbbc08141
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/exec.h>
7 #include <proto/dos.h>
9 #include <assert.h>
11 static BPTR out;
12 static LONG slot1, slot2, slot3;
14 static void printslot1(void)
16 FPrintf(out, "Value slot %ld: %ld\n", slot1, GetTaskStorageSlot(slot1));
19 int main(void)
21 out = Output();
23 slot1 = AllocTaskStorageSlot();
24 FPrintf(out, "Got slot %ld\n", slot1);
26 slot2 = AllocTaskStorageSlot();
27 FPrintf(out, "Got slot %ld\n", slot2);
29 FreeTaskStorageSlot(slot2);
30 FPrintf(out, "Freed slot %ld\n", slot2);
32 slot2 = AllocTaskStorageSlot();
33 FPrintf(out, "Got slot %ld\n", slot2);
35 slot3 = AllocTaskStorageSlot();
36 FPrintf(out, "Got slot %ld\n", slot3);
38 SetTaskStorageSlot(slot1, 69);
39 FPrintf(out, "Stored value 69 in slot %ld\n", slot1);
41 FPrintf(out, "Checking value in subtask\n");
42 struct Process *proc =
43 CreateNewProcTags(
44 NP_Entry, printslot1, NP_Name, "Check slot1",
45 NP_Synchronous, TRUE, TAG_DONE
47 assert(proc != NULL);
49 FreeTaskStorageSlot(slot1);
50 FPrintf(out, "Freed slot %ld\n", slot1);
52 slot1 = AllocTaskStorageSlot();
53 FPrintf(out, "Got slot %ld\n", slot1);
55 FreeTaskStorageSlot(slot2);
56 FPrintf(out, "Freed slot %ld\n", slot2);
58 FreeTaskStorageSlot(slot1);
59 FPrintf(out, "Freed slot %ld\n", slot1);
61 FreeTaskStorageSlot(slot3);
62 FPrintf(out, "Freed slot %ld\n", slot3);
64 return 0;