2 Copyright © 2015, The AROS Development Team. All rights reserved.
8 #include <aros/debug.h>
9 #include <aros/symbolsets.h>
11 #include <proto/exec.h>
12 #include <proto/kernel.h>
14 #include "taskres_intern.h"
16 void TaskResAddTask(struct TaskResBase
*TaskResBase
, struct Task
*task
)
18 struct TaskListEntry
*newEntry
;
22 if the list is locked, defer tasks addition until it is unlocked
24 if ((newEntry
= AllocMem(sizeof(struct TaskListEntry
), MEMF_CLEAR
)) != NULL
)
26 D(bug("[TaskRes] TaskResAddTask: taskentry @ 0x%p for '%s'\n", newEntry
, task
->tc_Node
.ln_Name
));
27 newEntry
->tle_Task
= task
;
28 AddTail(&TaskResBase
->trb_TaskList
, &newEntry
->tle_Node
);
32 AROS_LH4(APTR
, NewAddTask
,
33 AROS_LHA(struct Task
*, task
, A1
),
34 AROS_LHA(APTR
, initialPC
, A2
),
35 AROS_LHA(APTR
, finalPC
, A3
),
36 AROS_LHA(struct TagItem
*, tagList
, A4
),
37 struct ExecBase
*, SysBase
, 176, Task
)
42 struct TaskResBase
*TaskResBase
;
44 TaskResBase
= (struct TaskResBase
*)SysBase
->lb_TaskResBase
;
46 D(bug("[TaskRes] NewAddTask(0x%p)\n", task
));
48 newTask
= AROS_CALL4(APTR
, TaskResBase
->trb_NewAddTask
,
49 AROS_LCA(struct Task
*, task
, A1
),
50 AROS_LCA(APTR
, initialPC
, A2
),
51 AROS_LCA(APTR
, finalPC
, A3
),
52 AROS_LCA(struct TagItem
*, tagList
, A4
),
53 struct ExecBase
*, SysBase
);
55 D(bug("[TaskRes] NewAddTask: task @ 0x%p\n", newTask
));
58 TaskResAddTask(TaskResBase
, newTask
);
65 AROS_LH1(void, RemTask
,
66 AROS_LHA(struct Task
*, task
, A1
),
67 struct ExecBase
*, SysBase
, 48, Task
)
71 struct TaskListEntry
*tmpEntry
;
72 struct TaskResBase
*TaskResBase
;
74 TaskResBase
= (struct TaskResBase
*)SysBase
->lb_TaskResBase
;
76 D(bug("[TaskRes] RemTask()\n"));
78 AROS_CALL1(APTR
, TaskResBase
->trb_RemTask
,
79 AROS_LCA(struct Task
*, task
, A1
),
80 struct ExecBase
*, SysBase
);
82 ForeachNode(&TaskResBase
->trb_TaskList
, tmpEntry
)
84 if (tmpEntry
->tle_Task
== task
)
88 if the list is locked flag the entry to be removed,
89 else remove it immediately
91 D(bug("[TaskRes] RemTask: destroying taskentry @ 0x%p for '%s'\n", tmpEntry
, task
->tc_Node
.ln_Name
));
92 Remove(&tmpEntry
->tle_Node
);
93 FreeMem(tmpEntry
, sizeof(struct TaskListEntry
));