WMProcessInfo.Mod 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. MODULE WMProcessInfo; (** AUTHOR "tf/staubesv"; PURPOSE "Components for process visualization"; *)
  2. IMPORT
  3. SYSTEM, KernelLog,
  4. Streams, Machine, Modules, Objects, Kernel, Reflection, Strings, ProcessInfo, XML, Commands,
  5. WMGraphics, WMProperties, WMComponents, WMStandardComponents, WMGrids, WMStringGrids,
  6. WMPopups, WMDialogs;
  7. CONST
  8. (* ProcessSelector.sort *)
  9. None* = 0;
  10. ID* = 1;
  11. Priority* = 2;
  12. Mode* = 3;
  13. (* States *)
  14. Paused = 0; Running = 3; RunningRefresh = 4; Terminating = 99; Terminated = 100;
  15. DefaultRefreshInterval = 500;
  16. DefaultInterleave = 2;
  17. MaxNofProcesses = 1000;
  18. TYPE
  19. Selection* = POINTER TO ARRAY OF Objects.Process;
  20. ProcessSelector* = OBJECT (WMComponents.VisualComponent)
  21. VAR
  22. sort- : WMProperties.Int32Property;
  23. sortI : LONGINT;
  24. processes : ARRAY MaxNofProcesses OF Objects.Process;
  25. nofProcesses : LONGINT;
  26. colWidth : WMGrids.Spacings;
  27. grid : WMStringGrids.StringGrid;
  28. lastProcTime : HUGEINT;
  29. sw : Streams.StringWriter; (* Only use in procedure Update *)
  30. nofUpdates, interval, interleave : LONGINT;
  31. timer : Kernel.Timer;
  32. state, currentState : LONGINT;
  33. PROCEDURE &Init*;
  34. BEGIN
  35. Init^;
  36. NEW(sort, PrototypeSort, NIL, NIL); properties.Add(sort);
  37. sortI := sort.Get();
  38. ProcessInfo.Clear(processes);
  39. nofProcesses := 0;
  40. NEW(colWidth, 11);
  41. grid := CreateGrid();
  42. AddContent(grid);
  43. lastProcTime := Machine.GetTimer();
  44. NEW(sw, 128);
  45. nofUpdates := 0;
  46. interval := DefaultRefreshInterval;
  47. interleave := DefaultInterleave;
  48. NEW(timer);
  49. state := Paused;
  50. END Init;
  51. PROCEDURE GetSelection*() : Selection;
  52. VAR
  53. processes : ARRAY ProcessInfo.MaxNofProcesses OF Objects.Process;
  54. nofProcesses : LONGINT;
  55. scol, srow, ecol, erow, id, i : LONGINT;
  56. selection : Selection;
  57. str : Strings.String;
  58. BEGIN
  59. selection := NIL;
  60. grid.Acquire;
  61. grid.model.Acquire;
  62. grid.GetSelection(scol, srow, ecol, erow);
  63. IF (srow >= 0) & (srow <= erow) THEN
  64. ProcessInfo.GetProcesses(processes, nofProcesses);
  65. NEW(selection, erow - srow + 1);
  66. FOR i := srow TO erow DO
  67. str := grid.model.GetCellText(0, i); (* Get the Process ID *)
  68. Strings.StrToInt(str^, id);
  69. IF id > 0 THEN
  70. selection[i - srow] := ProcessInfo.Find(processes, id); (* may be NIL *)
  71. ELSE
  72. selection[i - srow] := NIL;
  73. END;
  74. END;
  75. END;
  76. grid.model.Release;
  77. grid.Release;
  78. RETURN selection;
  79. END GetSelection;
  80. PROCEDURE PropertyChanged*(sender, property : ANY);
  81. BEGIN
  82. IF (property = sort) THEN
  83. CheckSort;
  84. ELSIF (property = visible) THEN
  85. PropertyChanged^(sender, property);
  86. CheckVisibility;
  87. ELSE
  88. PropertyChanged^(sender, property);
  89. END;
  90. END PropertyChanged;
  91. PROCEDURE RecacheProperties*;
  92. BEGIN
  93. RecacheProperties^;
  94. CheckVisibility;
  95. CheckSort;
  96. END RecacheProperties;
  97. PROCEDURE CheckVisibility;
  98. BEGIN
  99. IF visible.Get() THEN Start;
  100. ELSE Pause;
  101. END;
  102. END CheckVisibility;
  103. PROCEDURE CheckSort;
  104. BEGIN {EXCLUSIVE}
  105. sortI := sort.Get();
  106. IF (state = Running) THEN
  107. state := RunningRefresh;
  108. END;
  109. timer.Wakeup;
  110. END CheckSort;
  111. PROCEDURE CreateGrid() : WMStringGrids.StringGrid;
  112. VAR
  113. grid : WMStringGrids.StringGrid;
  114. str : ARRAY 256 OF CHAR;
  115. i, dx, dy, minWidth : LONGINT;
  116. f : WMGraphics.Font;
  117. BEGIN
  118. NEW(grid); grid.alignment.Set(WMComponents.AlignClient);
  119. f := WMGraphics.GetFont("Oberon", 12, {});
  120. grid.fixedCols.Set(2); grid.fixedRows.Set(1);
  121. grid.SetSelectionMode(WMGrids.GridSelectRows);
  122. grid.Acquire;
  123. grid.model.Acquire;
  124. grid.model.SetNofCols(11);
  125. grid.model.SetNofRows(2);
  126. f.GetStringSize("-999999999", minWidth, dy);
  127. FOR i := 0 TO 5 DO
  128. GetTitleStr(i, str);
  129. f.GetStringSize(str, dx, dy);
  130. colWidth[i] := MAX(dx + 4, 30);
  131. grid.model.SetCellText(i, 0, Strings.NewString(str));
  132. grid.model.SetTextAlign(i, 0, WMGraphics.AlignCenter)
  133. END;
  134. FOR i := 6 TO 11 - 1 DO
  135. GetTitleStr(i, str);
  136. f.GetStringSize(str, dx, dy);
  137. colWidth[i] := MAX(dx + 4, minWidth+ 40);
  138. grid.model.SetCellText(i, 0, Strings.NewString(str));
  139. grid.model.SetTextAlign(i, 0, WMGraphics.AlignCenter)
  140. END;
  141. grid.SetColSpacings(colWidth);
  142. grid.model.Release;
  143. grid.Release;
  144. RETURN grid;
  145. END CreateGrid;
  146. PROCEDURE Start;
  147. BEGIN {EXCLUSIVE}
  148. IF (state < Terminating) THEN state := Running; END;
  149. END Start;
  150. PROCEDURE Pause;
  151. BEGIN {EXCLUSIVE}
  152. IF (state < Terminating) THEN
  153. state := Paused;
  154. END;
  155. END Pause;
  156. PROCEDURE Resized*;
  157. VAR width, height, w, add, i : LONGINT; newColWidth : WMGrids.Spacings;
  158. BEGIN
  159. width := bounds.GetWidth(); height := bounds.GetHeight();
  160. NEW(newColWidth, LEN(colWidth));
  161. FOR i := 0 TO LEN(colWidth)-1 DO
  162. w := w + colWidth[i];
  163. newColWidth[i] := colWidth[i];
  164. END;
  165. IF w < width THEN
  166. add := (width - w) DIV 3;
  167. INC(newColWidth[6], add);
  168. INC(newColWidth[8], add);
  169. INC(newColWidth[9], add);
  170. colWidth := newColWidth;
  171. grid.SetColSpacings(colWidth);
  172. END;
  173. Resized^;
  174. END Resized;
  175. PROCEDURE Update;
  176. VAR
  177. cycles : Objects.CpuCyclesArray;
  178. i, posP, beg : LONGINT;
  179. mod : Modules.Module;
  180. str : ARRAY 256 OF CHAR;
  181. t0, t1 : HUGEINT;
  182. pc, relpc : ADDRESS;
  183. mode: LONGINT;
  184. PROCEDURE SetText(line, cell : LONGINT; CONST str : ARRAY OF CHAR);
  185. VAR s : Strings.String;
  186. BEGIN
  187. s := grid.model.GetCellText(cell, line + 1); (* recycle the string *)
  188. IF s = NIL THEN NEW(s, 64) END;
  189. COPY(str, s^);
  190. grid.model.SetTextAlign(cell, line + 1, GetAlign(cell));
  191. grid.model.SetCellText(cell, line + 1, s)
  192. END SetText;
  193. PROCEDURE GetValues( p: Objects.Process );
  194. VAR bp: ADDRESS;
  195. BEGIN
  196. Objects.UpdateProcessState( p );
  197. mode := p.mode;
  198. pc := p.state.PC;
  199. bp := p.state.BP;
  200. mod := Modules.ThisModuleByAdr( pc );
  201. WHILE (mod = NIL) & (bp # 0) DO
  202. bp := CheckBP( p, bp );
  203. IF bp # 0 THEN
  204. SYSTEM.GET( bp + SIZEOF(ADDRESS), pc ); (* return addr from stack *)
  205. mod := Modules.ThisModuleByAdr( pc );
  206. SYSTEM.GET( bp, bp ); (* follow dynamic link *)
  207. END
  208. END
  209. END GetValues;
  210. BEGIN
  211. t1 := Machine.GetTimer() - lastProcTime;
  212. lastProcTime := Machine.GetTimer();
  213. grid.model.Acquire;
  214. grid.model.SetNofRows(nofProcesses + 1);
  215. FOR i := 0 TO nofProcesses - 1 DO
  216. ASSERT(processes[i] # NIL);
  217. GetValues( processes[i] );
  218. (* PID Process ID - 0 *)
  219. Strings.IntToStr(processes[i].id, str); SetText(i, 0, str);
  220. (* CPU - processor number - 1 *)
  221. Strings.IntToStr(processes[i].procID, str); SetText(i, 1, str);
  222. (* CPU% - 2 *)
  223. Objects.GetCpuCycles(processes[i], cycles, FALSE);
  224. t0 := cycles[0];
  225. Strings.IntToStr(SHORT ((t0 * 100) DIV t1), str);SetText(i, 2, str);
  226. (* priority - 3 *)
  227. Strings.IntToStr(processes[i].priority, str); SetText(i, 3, str);
  228. (* mode - 4 *)
  229. sw.Reset; ProcessInfo.WriteMode( mode, sw ); sw.Get(str); SetText(i, 4, str);
  230. (* PC - 5 *)
  231. relpc := pc;
  232. IF (mod # NIL) & (mod.code # NIL) THEN DEC(relpc, ADDRESSOF(mod.code[0])) END;
  233. Strings.IntToStr(SYSTEM.VAL (LONGINT, relpc), str); SetText(i, 5, str);
  234. (* active object type - 6 *)
  235. sw.Reset; ProcessInfo.WriteActiveObject(processes[i], sw); sw.Get(str);
  236. SetText(i, 6, str);
  237. (* Module - 7 *)
  238. IF mod # NIL THEN SetText(i, 7, mod.name)
  239. ELSE str := "Unknown"; SetText(i, 7, str);
  240. END;
  241. (* Procedure - 8 - Module name (prefix) and "pc=xyz" (suffix) suppressed *)
  242. sw.Reset; Reflection.WriteProc( sw, pc ); sw.Get(str);
  243. IF (str # "NIL") & (mod#NIL) THEN
  244. posP := 0;
  245. REPEAT INC(posP) UNTIL (posP=LEN(str)) OR (str[posP]=0X) OR (str[posP] = "."); (* Skip prefix *)
  246. INC(posP);
  247. beg := 0;
  248. REPEAT
  249. str[beg] := str[posP];
  250. INC(beg); INC(posP);
  251. UNTIL (posP=LEN(str)) OR (str[posP]=0X) OR (str[posP] = " "); (* Here follows "pc=xyz" now suppressed *)
  252. str[beg] := 0X
  253. END;
  254. SetText(i, 8, str);
  255. (* Waiting on condition - 9 *)
  256. sw.Reset; ProcessInfo.WriteWaitingOn(processes[i], sw); sw.Get(str);
  257. SetText(i, 9, str);
  258. (* Flags - 10 *)
  259. sw.Reset; ProcessInfo.WriteFlags(processes[i].flags, sw); sw.Get(str);
  260. SetText(i, 10, str);
  261. END;
  262. grid.model.Release;
  263. lastProcTime := Machine.GetTimer();
  264. END Update;
  265. PROCEDURE Refresh;
  266. VAR proc : ProcessInfo.IsGreaterThanProc;
  267. BEGIN
  268. Acquire;
  269. ProcessInfo.GetProcesses(processes, nofProcesses);
  270. CASE sortI OF
  271. | ID: proc := ProcessInfo.SortByID;
  272. | Priority : proc := ProcessInfo.SortByPriority;
  273. | Mode : proc := ProcessInfo.SortByMode;
  274. ELSE
  275. proc := NIL;
  276. END;
  277. IF (proc # NIL) THEN
  278. ProcessInfo.Sort(processes, nofProcesses, proc);
  279. END;
  280. Release;
  281. END Refresh;
  282. PROCEDURE Finalize*; (* override *)
  283. BEGIN
  284. Finalize^;
  285. BEGIN {EXCLUSIVE}
  286. state := Terminating;
  287. timer.Wakeup
  288. END;
  289. END Finalize;
  290. BEGIN {ACTIVE}
  291. WHILE (state < Terminating) DO
  292. BEGIN {EXCLUSIVE}
  293. AWAIT(state # Paused);
  294. IF (state = RunningRefresh) THEN
  295. nofUpdates := 0; (* forces Refresh *)
  296. state := Running;
  297. END;
  298. currentState := state;
  299. END;
  300. IF (currentState = Running) THEN
  301. IF (nofUpdates MOD interleave = 0) THEN
  302. Refresh;
  303. END;
  304. Update;
  305. INC(nofUpdates);
  306. timer.Sleep(interval);
  307. ELSIF (currentState = Paused) THEN
  308. nofProcesses := 0; ProcessInfo.Clear(processes);
  309. END;
  310. END;
  311. nofProcesses := 0; ProcessInfo.Clear(processes);
  312. BEGIN {EXCLUSIVE} state := Terminated; END
  313. END ProcessSelector;
  314. TYPE
  315. SortInfo = OBJECT
  316. VAR
  317. mode : LONGINT;
  318. name : ARRAY 64 OF CHAR;
  319. PROCEDURE &New*(mode : LONGINT; CONST name : ARRAY OF CHAR);
  320. BEGIN
  321. SELF.mode := mode;
  322. COPY(name, SELF.name);
  323. END New;
  324. END SortInfo;
  325. TYPE
  326. ProcessManager* = OBJECT (WMComponents.VisualComponent)
  327. VAR
  328. processSelector : ProcessSelector;
  329. haltBtn, unbreakHaltBtn, sortBtn, showBtn, cpuLoadBtn : WMStandardComponents.Button;
  330. sortPopup : WMPopups.Popup;
  331. nbrOfProcessesLabel : WMStandardComponents.Label;
  332. toolbar- : WMStandardComponents.Panel;
  333. PROCEDURE &Init*;
  334. VAR font : WMGraphics.Font; dx, dy : LONGINT; sortInfo : SortInfo;
  335. BEGIN
  336. Init^;
  337. SetNameAsString(StrProcessManager);
  338. NEW(toolbar);
  339. toolbar.bounds.SetHeight(20);
  340. toolbar.alignment.Set(WMComponents.AlignBottom);
  341. AddContent(toolbar);
  342. NEW(haltBtn);
  343. haltBtn.alignment.Set(WMComponents.AlignLeft);
  344. haltBtn.SetCaption("Halt process");
  345. haltBtn.onClick.Add(HandleHalt);
  346. toolbar.AddContent(haltBtn);
  347. font := haltBtn.GetFont();
  348. font.GetStringSize(" Halt process ", dx, dy);
  349. haltBtn.bounds.SetWidth(dx);
  350. NEW(unbreakHaltBtn);
  351. unbreakHaltBtn.alignment.Set(WMComponents.AlignLeft);
  352. unbreakHaltBtn.SetCaption("Halt process unbreakable");
  353. unbreakHaltBtn.onClick.Add(HandleUnbreakableHalt);
  354. toolbar.AddContent(unbreakHaltBtn);
  355. font := unbreakHaltBtn.GetFont();
  356. font.GetStringSize(" Halt process unbreakable ", dx, dy);
  357. unbreakHaltBtn.bounds.SetWidth(dx);
  358. NEW(sortBtn);
  359. sortBtn.bounds.SetWidth(80); sortBtn.alignment.Set(WMComponents.AlignLeft);
  360. sortBtn.caption.SetAOC("SortBy:PID");
  361. sortBtn.onClick.Add(HandleSort);
  362. toolbar.AddContent(sortBtn);
  363. NEW(sortPopup);
  364. NEW(sortInfo, None, "SortBy:None"); sortPopup.AddParButton("None", HandleSortPopup, sortInfo);
  365. NEW(sortInfo, ID, "SortBy:ID"); sortPopup.AddParButton("ID", HandleSortPopup, sortInfo);
  366. NEW(sortInfo, Priority, "SortBy:Priority"); sortPopup.AddParButton("Priority", HandleSortPopup, sortInfo);
  367. NEW(sortInfo, Mode, "SortBy:Mode"); sortPopup.AddParButton("Mode", HandleSortPopup, sortInfo);
  368. NEW(showBtn);
  369. showBtn.alignment.Set(WMComponents.AlignLeft);
  370. showBtn.SetCaption(" Show Stack ");
  371. showBtn.onClick.Add(HandleShowStack);
  372. toolbar.AddContent(showBtn);
  373. font := showBtn.GetFont();
  374. font.GetStringSize(" Show Stack ", dx, dy);
  375. showBtn.bounds.SetWidth(dx);
  376. NEW(cpuLoadBtn); cpuLoadBtn.alignment.Set(WMComponents.AlignLeft);
  377. cpuLoadBtn.SetCaption("CPU Load");
  378. cpuLoadBtn.onClick.Add(HandleCpuLoad);
  379. toolbar.AddContent(cpuLoadBtn);
  380. NEW(nbrOfProcessesLabel);
  381. nbrOfProcessesLabel.alignment.Set(WMComponents.AlignClient);
  382. nbrOfProcessesLabel.textColor.Set(WMGraphics.White);
  383. toolbar.AddContent(nbrOfProcessesLabel);
  384. NEW(processSelector); processSelector.alignment.Set(WMComponents.AlignClient);
  385. AddContent(processSelector);
  386. END Init;
  387. PROCEDURE Decision(CONST message : ARRAY OF CHAR) : BOOLEAN;
  388. BEGIN
  389. RETURN WMDialogs.Confirmation("Confirm terminating process", message) = WMDialogs.ResYes;
  390. END Decision;
  391. PROCEDURE HaltThread(unbreakable : BOOLEAN);
  392. VAR selection : Selection; i : LONGINT;
  393. BEGIN
  394. selection := processSelector.GetSelection();
  395. IF (selection # NIL) THEN
  396. FOR i := 0 TO LEN(selection)-1 DO
  397. IF (selection[i] # NIL) THEN
  398. (* Make these checks before acquiring the locks *)
  399. IF (Objects.Resistant IN selection[i].flags) THEN
  400. IF Decision("Teminate a resistant process") THEN
  401. Objects.TerminateThis(selection[i], unbreakable);
  402. END
  403. ELSE
  404. Objects.TerminateThis(selection[i], unbreakable);
  405. END;
  406. END;
  407. END;
  408. END;
  409. END HaltThread;
  410. PROCEDURE HandleHalt(sender, data : ANY);
  411. BEGIN
  412. HaltThread(FALSE);
  413. END HandleHalt;
  414. PROCEDURE HandleUnbreakableHalt(sender, data : ANY);
  415. BEGIN
  416. HaltThread(TRUE);
  417. END HandleUnbreakableHalt;
  418. PROCEDURE HandleSort(sender, data : ANY);
  419. VAR gx, gy : LONGINT;
  420. BEGIN
  421. sortBtn.ToWMCoordinates(0, sortBtn.bounds.GetBottom(), gx, gy);
  422. sortPopup.Popup(gx, gy);
  423. END HandleSort;
  424. PROCEDURE HandleSortPopup(sender, data : ANY);
  425. VAR sortInfo : SortInfo;
  426. BEGIN
  427. IF (data # NIL) & (data IS SortInfo) THEN
  428. sortPopup.Close;
  429. sortInfo := data(SortInfo);
  430. sortBtn.caption.SetAOC(sortInfo.name);
  431. processSelector.sort.Set(sortInfo.mode);
  432. END;
  433. END HandleSortPopup;
  434. PROCEDURE HandleShowStack(sender, data : ANY);
  435. VAR selection : Selection; w: Streams.Writer; i : LONGINT;
  436. BEGIN
  437. selection := processSelector.GetSelection();
  438. IF (selection # NIL) THEN
  439. Streams.OpenWriter(w, KernelLog.Send);
  440. FOR i := 0 TO LEN(selection)-1 DO
  441. IF (selection[i] # NIL) THEN
  442. ProcessInfo.ShowStack(selection[i], w);
  443. w.Ln;
  444. END;
  445. END;
  446. END;
  447. END HandleShowStack;
  448. PROCEDURE HandleCpuLoad(sender, data : ANY);
  449. VAR selection : Selection; i : LONGINT;
  450. BEGIN
  451. selection := processSelector.GetSelection();
  452. IF (selection # NIL) THEN
  453. FOR i := 0 TO LEN(selection) - 1 DO
  454. IF (selection[i] # NIL) THEN
  455. OpenCpuLoadWindow(selection[i].id);
  456. END;
  457. END;
  458. END;
  459. END HandleCpuLoad;
  460. END ProcessManager;
  461. VAR
  462. StrProcessSelector, StrProcessManager : Strings.String;
  463. PrototypeSort : WMProperties.Int32Property;
  464. PROCEDURE GetTitleStr(col : LONGINT; VAR x : ARRAY OF CHAR);
  465. BEGIN
  466. CASE col OF
  467. | 0 : COPY("PID", x)
  468. | 1 : COPY("CPU #", x)
  469. | 2 : COPY("CPU %", x)
  470. | 3 : COPY("Prio", x)
  471. | 4 : COPY("Mode", x)
  472. | 5 : COPY("PC", x)
  473. | 6 : COPY("Active Object", x)
  474. | 7 : COPY("Module", x)
  475. | 8 : COPY("Procedure", x)
  476. | 9 : COPY("Await condition", x)
  477. | 10 : COPY("Flags", x);
  478. ELSE COPY("", x);
  479. END
  480. END GetTitleStr;
  481. PROCEDURE GetAlign(col : LONGINT) : LONGINT;
  482. BEGIN
  483. CASE col OF
  484. | 6, 7, 8, 9, 10 : RETURN WMGraphics.AlignLeft;
  485. | 3, 1 : RETURN WMGraphics.AlignCenter;
  486. | 0, 2, 4, 5 : RETURN WMGraphics.AlignRight;
  487. ELSE RETURN WMGraphics.AlignRight
  488. END
  489. END GetAlign;
  490. PROCEDURE CheckBP( p: Objects.Process; bp: ADDRESS ): ADDRESS;
  491. VAR n: ADDRESS;
  492. BEGIN
  493. IF (bp < Objects.GetStackBottom(p)) & (bp > Objects.GetStackBottom(p) - 256*1024) THEN
  494. SYSTEM.GET(bp, n);
  495. IF ODD(n) THEN INC(bp, SIZEOF(ADDRESS)) END;
  496. RETURN bp
  497. ELSE
  498. RETURN 0
  499. END;
  500. END CheckBP;
  501. PROCEDURE OpenCpuLoadWindow(pid : LONGINT);
  502. VAR commandString, msg : ARRAY 128 OF CHAR; nbr : ARRAY 16 OF CHAR; res : WORD;
  503. BEGIN
  504. commandString := "WMPerfMonPluginProcesses.Install ";
  505. Strings.IntToStr(pid, nbr);
  506. Strings.Append(commandString, nbr);
  507. Commands.Call(commandString, {}, res, msg);
  508. IF (res # Commands.Ok) THEN
  509. KernelLog.String("WMProcessInfo.OpenCpuLoad: Command call failed, res = "); KernelLog.Int(res, 0);
  510. KernelLog.String(" ("); KernelLog.String(msg); KernelLog.String(")"); KernelLog.Ln;
  511. END;
  512. END OpenCpuLoadWindow;
  513. PROCEDURE InitStrings;
  514. BEGIN
  515. StrProcessSelector := Strings.NewString("ProcessSelector");
  516. StrProcessManager := Strings.NewString("ProcessManager");
  517. END InitStrings;
  518. PROCEDURE InitPrototypes;
  519. BEGIN
  520. NEW(PrototypeSort, NIL, Strings.NewString("sort"), Strings.NewString("Sort process list by 0: None, 1: ID, 2: Priority, 3: Mode"));
  521. PrototypeSort.Set(ID);
  522. END InitPrototypes;
  523. PROCEDURE GenProcessSelector*() : XML.Element;
  524. VAR ps : ProcessSelector;
  525. BEGIN
  526. NEW(ps); RETURN ps;
  527. END GenProcessSelector;
  528. PROCEDURE GenProcessManager*() : XML.Element;
  529. VAR pm : ProcessManager;
  530. BEGIN
  531. NEW(pm); RETURN pm;
  532. END GenProcessManager;
  533. BEGIN
  534. InitStrings;
  535. InitPrototypes;
  536. END WMProcessInfo.
  537. System.Free WMProcessInfo ~