1 #include "sysmon_intern.h"
3 #include <exec/execbase.h>
4 #include <clib/alib_protos.h>
8 /* Task information handling*/
14 struct TaskInfo
* Next
;
15 UBYTE Private
; /* MUST ALWAYS BE LAST. HERE NAME WILL BE COPIED */
18 UBYTE taskinfobuffer
[16 * 1024]; /* 16 kB buffer */
20 static LONG
AddTaskInfo(struct Task
* task
, struct TaskInfo
* ti
)
22 ti
->Type
= task
->tc_Node
.ln_Type
;
23 ti
->Priority
= (WORD
)task
->tc_Node
.ln_Pri
;
24 ti
->Name
= (STRPTR
)&ti
->Private
;
26 STRPTR src
= task
->tc_Node
.ln_Name
;
32 ti
->Name
[namesize
++] = *src
;
37 *(ti
->Name
+ namesize
) = 0; /* Terminate */
39 /* Calculate next item */
40 ti
->Next
= (struct TaskInfo
*)(((UBYTE
*)ti
) + sizeof(struct TaskInfo
) + namesize
);
45 static BOOL
FillTaskInfoBuffer(UBYTE
* buffer
)
47 struct TaskInfo
* current
= (struct TaskInfo
*)buffer
;
51 if(!AddTaskInfo(SysBase
->ThisTask
, current
))
57 for(task
=(struct Task
*)SysBase
->TaskReady
.lh_Head
;
58 task
->tc_Node
.ln_Succ
!=NULL
;
59 task
=(struct Task
*)task
->tc_Node
.ln_Succ
)
61 current
= current
->Next
;
63 if(!AddTaskInfo(task
, current
))
70 for(task
=(struct Task
*)SysBase
->TaskWait
.lh_Head
;
71 task
->tc_Node
.ln_Succ
!=NULL
;
72 task
=(struct Task
*)task
->tc_Node
.ln_Succ
)
74 current
= current
->Next
;
76 if(!AddTaskInfo(task
, current
))
83 current
->Next
= NULL
; /* "stop" list */
89 VOID
UpdateTasksInformation(struct SysMonData
* smdata
)
91 set(smdata
->tasklist
, MUIA_List_Quiet
, TRUE
);
93 /* Clear prior to reading information, because list contains items
94 from the taskinfobuffer. Once FillTaskInfoBuffer is executed old items
95 are invalid and could crash list */
96 DoMethod(smdata
->tasklist
, MUIM_List_Clear
);
98 if (FillTaskInfoBuffer(taskinfobuffer
))
100 struct TaskInfo
* ti
= (struct TaskInfo
*)taskinfobuffer
;
102 for (; ti
->Next
!= NULL
; ti
= ti
->Next
)
104 DoMethod(smdata
->tasklist
, MUIM_List_InsertSingle
, ti
, MUIV_List_Insert_Bottom
);
108 set(smdata
->tasklist
, MUIA_List_Quiet
, FALSE
);
111 AROS_UFH3(VOID
, TasksListDisplayFunction
,
112 AROS_UFHA(struct Hook
*, h
, A0
),
113 AROS_UFHA(STRPTR
*, strings
, A2
),
114 AROS_UFHA(struct TaskInfo
*, obj
, A1
))
118 static TEXT bufprio
[8];
122 __sprintf(bufprio
, "%ld", (LONG
)obj
->Priority
);
123 strings
[0] = obj
->Name
;
124 strings
[1] = bufprio
;
125 strings
[2] = obj
->Type
== NT_TASK
? (STRPTR
)_(MSG_TASK
) : (STRPTR
)_(MSG_PROCESS
);
129 strings
[0] = (STRPTR
)_(MSG_TASK_NAME
);
130 strings
[1] = (STRPTR
)_(MSG_TASK_PRIORITY
);
131 strings
[2] = (STRPTR
)_(MSG_TASK_TYPE
);
137 static BOOL
InitTasks()
142 static VOID
DeInitTasks()
146 struct SysMonModule tasksmodule
=
149 .DeInit
= DeInitTasks
,