home *** CD-ROM | disk | FTP | other *** search
- /* SWAP.c . Copyright © Kamran karimi. This program tries to bring swapping to
- Amiga without the need of hardware. Compiled with Lattice C 3.1 .
- Should be linked with PatchSignaling.o to produce executable.
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <exec/types.h>
- #include <exec/execbase.h>
- #include <exec/memory.h>
- #include <exec/ports.h>
- #include <libraries/dos.h>
- #include <libraries/dosextens.h>
- #include <intuition/intuitionbase.h>
- #include <intuition/intuition.h>
-
- #define RastPort (MainWin->RPort)
-
- #define SUCCESS 0
- #define FAILER 1
-
- #define TASKS 0
- #define WINSCR 1
- #define MEMORY 2
- #define INFO 3
-
- #define NOMEM 0
- #define FAILED 1
- #define DONE 2
- #define NOTME 3
- #define NOTFOUND 4
- #define NOTASK 5
- #define NOSUICIDE 6
- #define CONFIRM 7
- #define CANCELED 8
- #define NEWPRI 9
- #define OUTRANGE 10
- #define SIGMASK 11
- #define NOGRAPH 12
- #define NOFILE 13
- #define NOSEG 14
- #define NOSPC 15
- #define WERROR 16
- #define RERROR 17
- #define OCCUPIED1 18
- #define OCCUPIED2 19
- #define SWAPPED 20
- #define NSWAPPED 21
- #define NOTIMP 22
- #define WAIT 23
- #define NSWAPME 24
- #define FREED 25
- #define NOKILL 26
- #define NOBREAK 27
- #define NOSIGNAL 28
- #define NOFREEZE 29
- #define INTRUDER 30
- #define INTNFOUND 31
-
- static UWORD ColourTable[] = {0x99a,0xfff,0x000,0x082};
-
- struct NewScreen MyScreen = {0,0,640,200,2,0,1,HIRES,CUSTOMSCREEN,NULL,
- " SWAP By Kamran Karimi",NULL,NULL};
-
-
- UBYTE UNDOBuff[100];
-
- UBYTE SBuff[100];
-
- UBYTE Temp[100];
-
- UBYTE CRam[12],FRam[12],SwapS[12],SelTask[80];
-
- struct TextAttr MyFont = {
- (STRPTR)"topaz.font",TOPAZ_EIGHTY,FS_NORMAL,FPF_ROMFONT};
-
- struct StringInfo GadgetSInfo = {SBuff,UNDOBuff,0,100,0,0,0,0,0,0,0,0,NULL};
-
- struct PropInfo PGInfo = {AUTOKNOB|FREEVERT,-1,-1,0,0,0,0,0,0,0,0};
-
- struct Image Image1 = {0,0,12,67,0,NULL,0x0000,0x0000,NULL};
-
- USHORT Up[] = {
- 0x0200, /* 0000001000000 */
- 0x0700, /* 0000011100000 */
- 0x0f80, /* 0000111110000 */
- 0x1fc0, /* 0001111111000 */
- 0x3fe0, /* 0011111111100 */
- 0x7ff0 /* 0111111111110 */
- };
-
- USHORT Down[] = {
- 0x7ff0, /* 0111111111110 */
- 0x3fe0, /* 0011111111100 */
- 0x1fc0, /* 0001111111000 */
- 0x0f80, /* 0000111110000 */
- 0x0700, /* 0000011100000 */
- 0x0200 /* 0000001000000 */
- };
-
- USHORT *UpData,*DownData;
-
- struct Image UpArrow = {0,1,13,6,1,Up,1,0,NULL};
-
- struct Image DownArrow = {0,84,13,6,1,Down,1,0,(struct Image *)&UpArrow};
-
- SHORT BorderPairs[][6] = {
- {0,8,0,0,18,0},
- {18,0,18,8,0,8},
- {0,8,0,0,18,0},
- {18,0,18,8,0,8},
- {0,0,0,0,0,0},
- {0,0,0,0,0,0},
- {0,11,0,0,65,0}, /* keys */
- {65,0,65,11,0,11},
- {0,12,0,0,66,0},
- {66,0,66,12,0,12},
- {0,11,0,0,148,0}, /* big key */
- {148,0,148,11,0,11},
- {0,12,0,0,149,0},
- {149,0,149,12,0,12},
- {0,15,0,0,70,0}, /* exit */
- {70,0,70,15,0,15},
- {0,16,0,0,71,0},
- {71,0,71,16,0,16},
- {0,10,0,0,341,0}, /* string */
- {341,0,341,10,0,10},
- {0,11,0,0,343,0},
- {343,0,343,11,0,11},
- {0,95,0,26,595,26}, /* big area */
- {595,26,595,95,0,95},
- {0,96,0,26,597,26},
- {597,26,597,96,0,96},
- {0,108,0,98,595,98},
- {595,98,595,108,0,108},
- {0,198,0,155,254,155}, /* message area */
- {254,155,254,198,0,198},
- {0,199,0,155,256,155},
- {256,155,256,199,0,199},
- {0,152,0,142,254,142},
- {254,142,254,152,0,152},
- {1,22,1,0,160,0}, /* RAM */
- {160,0,160,22,1,22},
- {0,11,0,0,200,0},
- {200,0,200,11,0,11},
- {0,11,0,0,595,0},
- {595,0,595,11,0,11},
- {625,24,625,94,608,94},
- {624,24,624,94,607,94}
-
- }; /* end of BorderPairs structure */
-
- struct Border RevBorder[] = {
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[0],NULL},
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[1],(struct Border *) &RevBorder[0]},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[2],NULL},
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[3],(struct Border *) &RevBorder[2]},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[6],NULL},
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[7],(struct Border *) &RevBorder[6]},
- {-3,-2,2,0,JAM1,3,(SHORT *) BorderPairs[8],(struct Border *) &RevBorder[7]},
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[9],(struct Border *) &RevBorder[8]},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[10],NULL},
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[11],(struct Border *) &RevBorder[10]},
- {-3,-2,2,0,JAM1,3,(SHORT *) BorderPairs[12],(struct Border *) &RevBorder[11]},
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[13],(struct Border *) &RevBorder[12]},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[14],NULL},
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[15],(struct Border *) &RevBorder[14]},
- {-3,-2,2,0,JAM1,3,(SHORT *) BorderPairs[16],(struct Border *) &RevBorder[15]},
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[17],(struct Border *) &RevBorder[16]}
-
- }; /* end of struct RevBorder */
-
- struct Border Borders[] = {
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[0],NULL},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[1],(struct Border *) &Borders[0]},
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[2],NULL},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[3],(struct Border *) &Borders[2]},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[6],NULL},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[7],(struct Border *) &Borders[6]},
- {-3,-2,2,0,JAM1,3,(SHORT *) BorderPairs[8],(struct Border *) &Borders[7]},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[9],(struct Border *) &Borders[8]},
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[10],NULL},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[11],(struct Border *) &Borders[10]},
- {-3,-2,2,0,JAM1,3,(SHORT *) BorderPairs[12],(struct Border *) &Borders[11]},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[13],(struct Border *) &Borders[12]},
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[14],NULL},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[15],(struct Border *) &Borders[14]},
- {-3,-2,2,0,JAM1,3,(SHORT *) BorderPairs[16],(struct Border *) &Borders[15]},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[17],(struct Border *) &Borders[16]},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[18],NULL},
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[19],(struct Border *) &Borders[18]},
- {-3,-2,1,0,JAM1,3,(SHORT *) BorderPairs[20],(struct Border *) &Borders[19]},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[21],(struct Border *) &Borders[20]},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[22],NULL},
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[23],(struct Border *) &Borders[22]},
- {-3,-2,1,0,JAM1,3,(SHORT *) BorderPairs[24],(struct Border *) &Borders[23]},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[25],(struct Border *) &Borders[24]},
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[26],(struct Border *) &Borders[25]},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[27],(struct Border *) &Borders[26]},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[28],(struct Border *) &Borders[27]},
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[29],(struct Border *) &Borders[28]},
- {-3,-2,1,0,JAM1,3,(SHORT *) BorderPairs[30],(struct Border *) &Borders[29]},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[31],(struct Border *) &Borders[30]},
- {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[32],(struct Border *) &Borders[31]},
- {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[33],(struct Border *) &Borders[32]},
- {262,163,2,0,JAM1,3,(SHORT *) BorderPairs[34],(struct Border *) &Borders[33]},
- {262,163,1,0,JAM1,3,(SHORT *) BorderPairs[35],(struct Border *) &Borders[34]},
- {262,188,2,0,JAM1,3,(SHORT *) BorderPairs[36],(struct Border *) &Borders[35]},
- {262,188,1,0,JAM1,3,(SHORT *) BorderPairs[37],(struct Border *) &Borders[36]},
- {-2,11,1,0,JAM1,3,(SHORT *) BorderPairs[38],(struct Border *) &Borders[37]},
- {-2,11,2,0,JAM1,3,(SHORT *) BorderPairs[39],(struct Border *) &Borders[38]},
- {-6,0,2,0,JAM1,3,(SHORT *) BorderPairs[40],(struct Border *) &Borders[39]},
- {-6,0,2,0,JAM1,3,(SHORT *) BorderPairs[41],(struct Border *) &Borders[40]}
-
- }; /* end of Borders structure */
-
-
- struct IntuiText Texts[] = {
- {0,0,0,0,0,0,0,0}, /* 0 */
- {0,0,0,0,0,0,0,0}, /* 1 */
- {0,0,0,0,0,0,0,0}, /* 2 */
- {2,0,JAM2,8,1,&MyFont,"Update",NULL}, /* 3 */
- {2,0,JAM2,16,1,&MyFont,"Info",NULL}, /* 4 */
- {2,0,JAM2,8,1,&MyFont,"Freeze",NULL}, /* 5 */
- {2,0,JAM2,14,1,&MyFont," Pri ",NULL}, /* 6 */
- {2,0,JAM2,17,1,&MyFont,"Kill",NULL}, /* 7 */
- {2,0,JAM2,2,1,&MyFont,"Swap In",NULL}, /* 8 */
- {2,0,JAM2,-1,1,&MyFont,"Swap Out",NULL},/* 9 */
- {2,0,JAM2,8,1,&MyFont,"Signal",NULL}, /* 10 */
- {2,0,JAM2,12,1,&MyFont,"Break",NULL}, /* 11 */
- {2,0,JAM2,12,1,&MyFont,"Segs ",NULL}, /* 12 */
- {2,0,JAM2,8,1,&MyFont,"Memory",NULL}, /* 13 */
- {2,0,JAM2,11,1,&MyFont," W&S ",NULL}, /* 14 */
- {2,0,JAM2,21,1,&MyFont,"Find Intruder",NULL}, /* 15 */
- {2,0,JAM2,17,3,&MyFont,"Exit",NULL}, /* 16 */
- {2,0,JAM2,400,99,&MyFont,"At Address:",NULL},
- {2,0,JAM2,5,99,&MyFont,"Selected Task: ",(struct IntuiText *) &Texts[17]},
- {2,0,JAM2,100,142,&MyFont,"Message",(struct IntuiText *) &Texts[18]},
- {2,0,JAM2,270,190,&MyFont,"Swap Space:",(struct IntuiText *) &Texts[19]},
- {2,0,JAM2,272,176,&MyFont,"FastMem:",(struct IntuiText *) &Texts[20]},
- {2,0,JAM2,272,165,&MyFont,"ChipMem:",(struct IntuiText *) &Texts[21]},
- {2,0,JAM2,268,140,&MyFont,"Swap Out File: ",
- (struct IntuiText *) &Texts[22]},
- {2,0,JAM2,5,14,&MyFont,
- " Name Pri State Stack Type Signals Address",
- (struct IntuiText *) &Texts[23]},
- {1,0,JAM2,335,176,&MyFont,FRam,NULL},
- {1,0,JAM2,335,165,&MyFont,CRam,(struct IntuiText *) &Texts[25]},
- {1,0,JAM2,360,190,&MyFont,SwapS,NULL},
- {1,0,JAM2,118,99,&MyFont,SelTask,NULL},
- {2,0,JAM2,268,140,&MyFont,"Enter New Priority:",NULL},
- {2,0,JAM2,268,140,&MyFont,"Enter Signal Mask: ",NULL},
- {2,0,JAM2,5,1,&MyFont," Tasks ",NULL},
- {2,0,JAM2,5,14,&MyFont,
- " (TASK INFORMATION)",
- NULL},
- {2,0,JAM2,5,14,&MyFont,
- " Start Address End Address Size Type (SEGMENT INFORMATION)",
- NULL},
- {2,0,JAM2,5,14,&MyFont,
- " ",
- NULL},
- {2,0,JAM2,5,14,&MyFont,
- " Name IDCMP Address",
- NULL},
- {2,0,JAM2,400,99,&MyFont,"At Address:",(struct IntuiText *) &Texts[35]},
- {2,0,JAM2,5,99,&MyFont,"Selected Element: ",(struct IntuiText *) &Texts[36]},
- {2,0,JAM2,12,1,&MyFont,"Close",NULL},
- {2,0,JAM2,12,1,&MyFont,"Merge",NULL},
- {2,0,JAM2,5,14,&MyFont,
- " Chunk Addr Size Type # (MEMORY INFORMATION)",
- NULL},
- {2,0,JAM2,5,99,&MyFont,"Selected Chunk Address: ",
- (struct IntuiText *) &Texts[40]},
- {2,0,JAM2,8,1,&MyFont," Melt ",NULL},
-
- }; /* end of Texts structure */
-
-
-
- struct IntuiText SelTexts[] = {
- {1,0,JAM2,2,1,&MyFont,NULL,NULL}, /* 0 */
- {1,0,JAM2,2,1,&MyFont,NULL,NULL}, /* 1 */
- {1,0,JAM2,2,1,&MyFont,NULL,NULL}, /* 2 */
- {1,0,JAM2,2,1,&MyFont,NULL,NULL}, /* 3 */
- {1,0,JAM2,2,1,&MyFont,NULL,NULL}, /* 4 */
- {1,0,JAM2,2,1,&MyFont,NULL,NULL}, /* 5 */
- {1,0,JAM2,2,1,&MyFont,NULL,NULL} /* 6 */
-
- };
-
- char ETextAddr[4][32];
-
- struct IntuiText ErrIntuiText[] = {
- {1,0,JAM2,7,157,&MyFont,ETextAddr[0],NULL}, /* 0 */
- {1,0,JAM2,7,167,&MyFont,ETextAddr[1],NULL}, /* 1 */
- {1,0,JAM2,7,177,&MyFont,ETextAddr[2],NULL}, /* 2 */
- {1,0,JAM2,7,187,&MyFont,ETextAddr[3],NULL} /* 3 */
- };
-
- struct Gadget Bools[] = {
- {(struct Gadget *) &Bools[1],617,15,15,7,GADGHIMAGE,GADGIMMEDIATE|RELVERIFY,
- BOOLGADGET,(APTR)&Borders[1],(APTR)&RevBorder[1],NULL,NULL,NULL,0,NULL},
-
- {(struct Gadget *) &Bools[2],617,97,15,7,GADGHIMAGE,GADGIMMEDIATE|RELVERIFY,
- BOOLGADGET,(APTR)&Borders[3],(APTR)&RevBorder[3],NULL,NULL,NULL,1,NULL},
-
- {(struct Gadget *) &Bools[3],615,24,20,71,NULL,RELVERIFY,PROPGADGET,
- (APTR)&Image1,NULL,NULL,NULL, (APTR)&PGInfo,2,NULL},
-
- {(struct Gadget *) &Bools[4],43,112,62,10,GADGHIMAGE,RELVERIFY,BOOLGADGET,
- (APTR)&Borders[9],(APTR)&RevBorder[9],(struct IntuiText *) &Texts[3],
- NULL,NULL,3,NULL},
-
- {(struct Gadget *) &Bools[5],127,112,62,10,GADGHIMAGE|GADGDISABLED,
- RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
- (struct IntuiText *) &Texts[4],NULL,NULL,4,NULL},
-
- {(struct Gadget *) &Bools[6],214,112,62,10,GADGHIMAGE|GADGDISABLED,
- RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
- (struct IntuiText *) &Texts[5],NULL,NULL,5,NULL},
-
- {(struct Gadget *) &Bools[7],300,112,62,10,GADGHIMAGE|GADGDISABLED,
- RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
- (struct IntuiText *) &Texts[6],NULL,NULL,6,NULL},
-
- {(struct Gadget *) &Bools[8],384,112,62,10,GADGHIMAGE|GADGDISABLED,
- RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
- (struct IntuiText *) &Texts[7],NULL,NULL,7,NULL},
-
- {(struct Gadget *) &Bools[9],466,112,62,10,GADGHIMAGE|GADGDISABLED,
- RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
- (struct IntuiText *) &Texts[8],NULL,NULL,8,NULL},
-
- {(struct Gadget *) &Bools[10],549,112,62,10,GADGHIMAGE|GADGDISABLED,
- RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
- (struct IntuiText *) &Texts[9],NULL,NULL,9,NULL},
-
- {(struct Gadget *) &Bools[11],43,127,62,10,GADGHIMAGE|GADGDISABLED,
- RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
- (struct IntuiText *) &Texts[10],NULL,NULL,10,NULL},
-
- {(struct Gadget *) &Bools[12],127,127,62,10,GADGHIMAGE|GADGDISABLED,
- RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
- (struct IntuiText *) &Texts[11],NULL,NULL,11,NULL},
-
- {(struct Gadget *) &Bools[13],214,127,62,10,GADGHIMAGE|GADGDISABLED,
- RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
- (struct IntuiText *) &Texts[12],NULL,NULL,12,NULL},
-
- {(struct Gadget *) &Bools[14],300,127,62,10,GADGHIMAGE,RELVERIFY,BOOLGADGET,
- (APTR)&Borders[9],(APTR)&RevBorder[9],(struct IntuiText *) &Texts[13],
- NULL,NULL,13,NULL},
-
- {(struct Gadget *) &Bools[15],384,127,62,10,GADGHIMAGE,RELVERIFY,BOOLGADGET,
- (APTR)&Borders[9],(APTR)&RevBorder[9],(struct IntuiText *) &Texts[14],
- NULL,NULL,14,NULL},
-
- {(struct Gadget *) &Bools[16],466,127,145,10,GADGHIMAGE|GADGDISABLED,
- RELVERIFY,BOOLGADGET,(APTR)&Borders[13],(APTR)&RevBorder[13],
- (struct IntuiText *) &Texts[15], NULL,NULL,15,NULL},
-
- {(struct Gadget *) &Bools[17],550,183,30,15,GADGHIMAGE,RELVERIFY,BOOLGADGET,
- (APTR)&Borders[17],(APTR)&RevBorder[17],(struct IntuiText *) &Texts[16],
- NULL,NULL,16,NULL},
-
- {NULL,280,150,338,9,NULL,RELVERIFY,STRGADGET,
- (APTR)&Borders[21],NULL,NULL,NULL,(APTR)&GadgetSInfo,17,NULL},
-
- }; /* end of Bools structure */
-
- struct Gadget Select[] = {
- {(struct Gadget *) &Select[1],14,26,594,9,GADGHCOMP,RELVERIFY,
- BOOLGADGET,NULL,NULL,(struct IntuiText *) &SelTexts[0],NULL,NULL,20,NULL},
-
- {(struct Gadget *) &Select[2],14,35,594,10,GADGHCOMP,RELVERIFY,
- BOOLGADGET,NULL,NULL,(struct IntuiText *) &SelTexts[1],NULL,NULL,21,NULL},
-
- {(struct Gadget *) &Select[3],14,45,594,10,GADGHCOMP,RELVERIFY,
- BOOLGADGET,NULL,NULL,(struct IntuiText *) &SelTexts[2],NULL,NULL,22,NULL},
-
- {(struct Gadget *) &Select[4],14,55,594,10,GADGHCOMP,RELVERIFY,
- BOOLGADGET,NULL,NULL,(struct IntuiText *) &SelTexts[3],NULL,NULL,23,NULL},
-
- {(struct Gadget *) &Select[5],14,65,594,10,GADGHCOMP,RELVERIFY,
- BOOLGADGET,NULL,NULL,(struct IntuiText *) &SelTexts[4],NULL,NULL,24,NULL},
-
- {(struct Gadget *) &Select[6],14,75,594,10,GADGHCOMP,RELVERIFY,
- BOOLGADGET,NULL,NULL,(struct IntuiText *) &SelTexts[5],NULL,NULL,25,NULL},
-
- {NULL,14,85,594,9,GADGHCOMP,RELVERIFY,
- BOOLGADGET,NULL,NULL,(struct IntuiText *) &SelTexts[6],NULL,NULL,26,NULL},
-
- };
-
- struct NewWindow MyWindow = {0,0,640,200,0,1,GADGETDOWN|GADGETUP,
- SIMPLE_REFRESH|BACKDROP+BORDERLESS,(struct Gadget *) &Bools[0],NULL,
- NULL,NULL,NULL,5,5,640,200,CUSTOMSCREEN };
-
-
- char *ErrorT[] = {
- "Could not allocate memory! ",
- "Operation failed! ",
- "Operation Done ",
- "I can not freeze myself! ",
- "Task not found! ",
- "No task selected ",
- "I won't commit Suicide! ",
- "Click again to confirm ... ",
- "Operation canceled ",
- "Give new task priority ",
- "Given priority was not valid! ",
- "Give signal mask in hexadecimal",
- "No window or screen selected! ",
- "Could not open swap file! ",
- "No Segment found! ",
- "Not enough space in swap file! ",
- "Could not write to swap file! ",
- "Could not read swap file! ",
- "Task memory occupied! ",
- "Could not swap in the task! ",
- "Task already swapped out ",
- "Task has not been swapped out! ",
- "This Option is not Implemented!",
- "Please Wait ... ",
- "I can not swap out myself! ",
- "Allocated memory freed ",
- "Can't kill a swapped task ",
- "Can't break a swapped task ",
- "Can't Signal a swapped task ",
- "Can't freeze a swapped task ",
- "Intruder task address:00000000 ",
- "Intruder not found! ",
-
- };
-
- struct TInfo {
- struct TInfo *next,*prev;
- struct Task *Addr;
- char *name;
- char tempname[40];
- char data[80];
- };
-
-
- extern struct ExecBase *SysBase;
- struct IntuitionBase *IntuitionBase;
- struct GfxBase *GfxBase;
- struct DOSBase *DOSBase;
- struct Window *MainWin;
- struct Screen *MainScr;
- struct IntuiMessage *message;
- struct Gadget *GadgetPtr;
- struct TInfo *first = NULL,*ItemAddr[7],*tinfo,*current,*GraphPtr = NULL;
- struct Task *task,*PrevSelected = NULL;
- struct MsgPort *MP,*PredMP;
-
- USHORT SelectPos,TaskNum,GadgetNum,Row = 0,OldVPot,SMask;
-
- APTR FirstSeg,SegAddr,CurSeg;
-
- FILE *file;
-
- ULONG State,SSpace,ChipRam,FastRam,class,SigMask,SegSum,SegSize,NumSwap;
-
- UBYTE *state[10] = {"NonVal","Added","Runing","Ready","Waiting","Except",
- "Remove","Error","Frozen","Swapped"};
-
- UBYTE *type[17] = {"Unknown","Task","Interrupt","Device","MsgPort","Message",
- "FreeMsg","ReplyMsg","Resource","Library","Memory","SoftInt","Font",
- "Process","Semaphore","SignalSem","BootNode"};
-
- UBYTE *BCPLtoC();
-
- void Open_UserInterface(),DisplayRam(),CloseAll(),Freeze(),ModifyP(),Pri();
- void UpdateTasks(),FreeList(),GetTaskName(),DisplaySwap(),PropMoved();
- void WipeGadg(),SwapIn(),FindIntruder(),FreeSwap();
- void MoveUp(),MoveDown(),NewSelect(),Update(),Message(),Kill(),Break();
- void SendSig(),GetInfo(),Seg(),ClearSelect(),WinScr(),Mem(),SwapOut();
-
- int GetList(),GetTaskInfo(),Confirm(),PatchSignaling();
-
- APTR FindFirstSegment();
-
- int CXBRK() { return(0); }
-
- void _main()
- {
- strcpy(SBuff,"DF0:");
- Open_UserInterface();
- do {
- WaitPort(MainWin->UserPort);
- message = (struct IntuiMessage *)GetMsg(MainWin->UserPort);
- GadgetPtr = (struct Gadget *)message->IAddress;
- GadgetNum = GadgetPtr->GadgetID;
- ReplyMsg((struct Message *) message);
- switch (GadgetNum)
- {
- case 0: MoveDown(1);
- break;
- case 1: MoveUp(1);
- break;
- case 2: PropMoved();
- break;
- case 3: Update();
- break;
- case 4: GetInfo();
- break;
- case 5: Freeze();
- break;
- case 6: Pri();
- break;
- case 7: Kill();
- break;
- case 8: SwapIn();
- UpdateTasks();
- DisplayRam();
- break;
- case 9: SwapOut();
- DisplaySwap();
- break;
- case 10: SendSig();
- break;
- case 11: Break();
- break;
- case 12: Seg();
- break;
- case 13: Mem();
- break;
- case 14: WinScr();
- break;
- case 15: FindIntruder();
- break;
- case 16: if(Confirm(16)) GadgetNum = 100;
- break;
- case 17: DisplaySwap();
- break;
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- case 26: NewSelect();
- break;
-
- default: break;
- }
- }while(GadgetNum != 16);
- if(first) FreeList();
- CloseAll(0L);
- }
-
-
- void Open_UserInterface()
- {
- if(!(IntuitionBase = (struct IntuitionBase *)
- OpenLibrary("intuition.library",0L))) CloseAll(20L);
-
- if (!(GfxBase = (struct GfxBase *)
- OpenLibrary("graphics.library",0L))) CloseAll(20L);
-
- if (!(DOSBase = (struct DOSBase *)
- OpenLibrary("dos.library",0L))) CloseAll(20L);
-
- UpData = (USHORT *) AllocMem(sizeof(Up),MEMF_CHIP);
- DownData = (USHORT *) AllocMem(sizeof(Down),MEMF_CHIP);
- CopyMem(Up,UpData,sizeof(Up));
- CopyMem(Down,DownData,sizeof(Down));
- UpArrow.ImageData = UpData;
- DownArrow.ImageData = DownData;
- if(!(MainScr = (struct Screen *) OpenScreen(&MyScreen))) CloseAll(10L);
- LoadRGB4(&(MainScr->ViewPort),ColourTable,4);
- MyWindow.Screen = MainScr;
- if(!(MainWin = (struct Window *) OpenWindow(&MyWindow))) CloseAll(10L);
- DrawBorder(RastPort,(struct Border *) &Borders[41],15L,0L);
- PrintIText(RastPort,(struct IntuiText *) &Texts[24],10,0);
- DrawImage(RastPort,&DownArrow,618L,14L);
- SelectPos = AddGList(MainWin,Select,-1,7,NULL);
- Update();
- if(PatchSignaling()) CloseAll(10L);
- State = TASKS;
- }
-
-
- void Update()
- {
- int count;
-
- UpdateTasks();
- DisplayRam();
- DisplaySwap();
- PrevSelected = NULL;
- GraphPtr = NULL;
- strcpy(SelTask,"NONE ");
- PrintIText(RastPort,(struct IntuiText *)&Texts[28],10,0);
- strcpy(SelTask,"N/A ");
- PrintIText(RastPort,(struct IntuiText *)&Texts[28],384,0);
- if((Bools[4].Flags & GADGDISABLED) == NULL)
- {
- RemoveGList(MainWin,&Bools[3],13);
- for (count = 3;count != 16;count++) Bools[count].Flags |= GADGDISABLED;
- Bools[3].Flags &= ~GADGDISABLED;
- Bools[13].Flags &= ~GADGDISABLED;
- Bools[14].Flags &= ~GADGDISABLED;
- AddGList(MainWin,&Bools[3],3,13,NULL);
- RefreshGList(&Bools[3],MainWin,NULL,13);
- }
- }
-
-
- void NewSelect()
- {
- short x1 = 10,x2 = 384;
- UBYTE PrevS,CurS;
- int count;
- struct Task *PS;
-
- if(State != INFO)
- {
- PS = PrevSelected;
- if(State == WINSCR) x1 = 36;
- if(State == MEMORY) x2 = 84;
- if(TaskNum < (GadgetNum - 19))
- {
- PrevSelected = NULL;
- GraphPtr = NULL;
- if(PS == NULL) return;
- RemoveGList(MainWin,&Bools[3],13);
- for (count = 3;count != 16;count++) Bools[count].Flags |= GADGDISABLED;
- if(State != MEMORY)
- {
- strcpy(SelTask,"NONE ");
- PrintIText(RastPort,(struct IntuiText *)&Texts[28],x1,0);
- if(State == WINSCR) Bools[14].Flags &= ~GADGDISABLED;
- if(State == TASKS)
- {
- Bools[3].Flags &= ~GADGDISABLED;
- Bools[13].Flags &= ~GADGDISABLED;
- Bools[14].Flags &= ~GADGDISABLED;
- }
- }
- else Bools[13].Flags &= ~GADGDISABLED;
- AddGList(MainWin,&Bools[3],3,13,NULL);
- RefreshGList(&Bools[3],MainWin,NULL,13);
- strcpy(SelTask,"N/A ");
- PrintIText(RastPort,(struct IntuiText *)&Texts[28],x2,0);
- }
- else
- {
- PrevSelected = ItemAddr[GadgetNum - 20]->Addr;
- GraphPtr = ItemAddr[GadgetNum - 20];
- if(State != MEMORY)
- {
- sprintf(SelTask,"%-35.35s",ItemAddr[GadgetNum -20]->name);
- PrintIText(RastPort,(struct IntuiText *)&Texts[28],x1,0);
- }
- if(PS == NULL)
- {
- RemoveGList(MainWin,&Bools[3],13);
- if(State == TASKS)
- {
- for (count = 3;count != 16;count++) Bools[count].Flags &= ~GADGDISABLED;
- Bools[8].Flags = Bools[9].Flags = Bools[15].Flags |= GADGDISABLED;
- }
- if(State == WINSCR) Bools[7].Flags &= ~GADGDISABLED;
- if(State == MEMORY) Bools[6].Flags &= ~GADGDISABLED;
- AddGList(MainWin,&Bools[3],3,13,NULL);
- WipeGadg();
- RefreshGList(&Bools[3],MainWin,NULL,13);
- }
- if(State == TASKS)
- {
- if(PrevSelected->tc_State == 8) Bools[5].GadgetText = &Texts[42];
- else Bools[5].GadgetText = &Texts[5];
- RefreshGList(&Bools[5],MainWin,NULL,1);
- if(PrevSelected->tc_State == 9 || PrevSelected->tc_State == 2)
- {
- RemoveGList(MainWin,&Bools[3],13);
- for (count = 3;count != 16;count++) Bools[count].Flags |= GADGDISABLED;
- if(PrevSelected->tc_State == 9)
- Bools[4].Flags = Bools[8].Flags = Bools[15].Flags &= ~GADGDISABLED;
- else
- {
- Bools[4].Flags &= ~GADGDISABLED;
- Bools[10].Flags = Bools[11].Flags = Bools[12].Flags &= ~GADGDISABLED;
- }
- Bools[3].Flags = Bools[13].Flags = Bools[14].Flags &= ~GADGDISABLED;
- Bools[6].Flags &=~GADGDISABLED;
- AddGList(MainWin,&Bools[3],3,13,NULL);
- PrevS = PS->tc_State; CurS = PrevSelected->tc_State;
- if(!((PrevS == 2 && CurS == 2) || (PrevS == 9 && CurS == 9))) WipeGadg();
- if(PrevS == 2 && CurS == 9) WipeGadg();
- RefreshGList(&Bools[3],MainWin,NULL,13);
- }
- else if(PS->tc_State == 9 || PS->tc_State == 2)
- {
- RemoveGList(MainWin,&Bools[3],13);
- for (count = 3;count != 16;count++) Bools[count].Flags &= ~GADGDISABLED;
- Bools[9].Flags = Bools[8].Flags = Bools[15].Flags |= GADGDISABLED;
- AddGList(MainWin,&Bools[3],3,13,NULL);
- WipeGadg();
- RefreshGList(&Bools[3],MainWin,NULL,13);
- }
- }
- sprintf(SelTask,"%08lx",PrevSelected);
- PrintIText(RastPort,(struct IntuiText *)&Texts[28],x2,0);
- }
- }
- }
-
-
- void ModifyP(Pos)
- int Pos;
- {
- long vbody;
- USHORT vb;
-
- if (TaskNum < 8) vbody = MAXBODY;
- else vbody = (MAXBODY * 7) / TaskNum;
- vb = (USHORT)vbody;
- NewModifyProp(&Bools[2],MainWin,NULL,PGInfo.Flags,PGInfo.HorizPot,
- Pos,PGInfo.HorizBody,vb,1);
- OldVPot = Pos;
- }
-
-
- void MoveUp(param)
- int param;
- {
- int count;
-
- do
- {
- if (TaskNum < 8) return;
- if (ItemAddr[6]->next == NULL)
- {
- if(param) ModifyP(-1);
- return;
- }
- RemoveGList(MainWin,Select,7);
- for(count = 0;count < 7;count++)
- {
- ItemAddr[count] = ItemAddr[count]->next;
- SelTexts[count].IText = ItemAddr[count]->data;
- }
- AddGList(MainWin,Select,-1,7,NULL);
- RefreshGList(Select,MainWin,NULL,7);
- if(param)
- {
- OldVPot = OldVPot + MAXBODY / (TaskNum - 7);
- NewModifyProp(&Bools[2],MainWin,NULL,PGInfo.Flags,PGInfo.HorizPot,
- OldVPot,PGInfo.HorizBody,PGInfo.VertBody,1);
- }
- if(!param) break;
- message = (struct IntuiMessage *)GetMsg(MainWin->UserPort);
- } while(message == NULL);
- if(param) ReplyMsg((struct Message *) message);
- }
-
-
- void MoveDown(param)
- int param;
- {
- int count;
-
- do
- {
- if (TaskNum < 8) return;
- if (ItemAddr[0]->prev == NULL)
- {
- if(param) ModifyP(0);
- return;
- }
- RemoveGList(MainWin,Select,7);
- for(count = 0;count < 7;count++)
- {
- ItemAddr[count] = ItemAddr[count]->prev;
- SelTexts[count].IText = ItemAddr[count]->data;
- }
- AddGList(MainWin,Select,-1,7,NULL);
- RefreshGList(Select,MainWin,NULL,7);
- if(param)
- {
- OldVPot = OldVPot - MAXBODY / (TaskNum - 7);
- NewModifyProp(&Bools[2],MainWin,NULL,PGInfo.Flags,PGInfo.HorizPot,
- OldVPot,PGInfo.HorizBody,PGInfo.VertBody,1);
- }
- if(!param) break;
- message = (struct IntuiMessage *)GetMsg(MainWin->UserPort);
- } while(message == NULL);
- if(param) ReplyMsg((struct Message *) message);
- }
-
-
- void PropMoved()
- {
- short factor = 1;
-
- if (TaskNum < 8) return;
- if(max(OldVPot,PGInfo.VertPot) == OldVPot) factor = -1;
- if(factor == 1)
- {
- while(OldVPot < PGInfo.VertPot)
- {
- MoveUp(0);
- if(OldVPot > (0xffff - (MAXBODY / (TaskNum - 7))))
- {
- OldVPot = 0xffff;
- break;
- }
- OldVPot = OldVPot + MAXBODY / (TaskNum - 7);
- }
- }
- else
- {
- while(OldVPot > PGInfo.VertPot)
- {
- MoveDown(0);
- if(OldVPot < (MAXBODY / (TaskNum - 7)))
- {
- OldVPot = 0;
- break;
- }
- OldVPot = OldVPot - MAXBODY / (TaskNum - 7);
- }
- }
- NewModifyProp(&Bools[2],MainWin,NULL,PGInfo.Flags,PGInfo.HorizPot,
- OldVPot,PGInfo.HorizBody,PGInfo.VertBody,1);
- }
-
-
- int Confirm(GadgNum)
- int GadgNum;
- {
- Message(CONFIRM);
- WaitPort(MainWin->UserPort);
- message = (struct IntuiMessage *)GetMsg(MainWin->UserPort);
- class = message->Class;
- GadgetPtr = (struct Gadget *)message->IAddress;
- GadgetNum = GadgetPtr->GadgetID;
- ReplyMsg((struct Message *) message);
- switch(GadgetNum)
- {
- case 0: MoveDown(1);
- break;
- case 1: MoveUp(1);
- break;
- case 2: PropMoved();
- break;
- }
- if(GadgetNum == GadgNum) return(SUCCESS);
- Message(CANCELED);
- return(FAILER);
- }
-
-
- void Mem()
- {
- struct MemHeader *memheader;
- struct MemChunk *memchunk;
- struct TInfo *cur,*ti;
- int count,type;
-
- PrevSelected = NULL;
- if(State == MEMORY)
- {
- State = TASKS;
- RemoveGList(MainWin,&Bools[3],13);
- Bools[13].GadgetText = &Texts[13];
- Bools[6].GadgetText = &Texts[6];
- for (count = 3;count != 16;count++) Bools[count].Flags |= GADGDISABLED;
- Bools[3].Flags &= ~GADGDISABLED;
- Bools[13].Flags &= ~GADGDISABLED;
- Bools[14].Flags &= ~GADGDISABLED;
- AddGList(MainWin,&Bools[3],3,13,NULL);
- WipeGadg();
- RefreshGList(&Bools[3],MainWin,NULL,13);
- Texts[24].NextText = NULL;
- PrintIText(RastPort,(struct IntuiText *)&Texts[24],10,0);
- Texts[24].NextText = &Texts[23];
- PrintIText(RastPort,(struct IntuiText *)&Texts[18],10,0);
- strcpy(SelTask,"NONE ");
- PrintIText(RastPort,(struct IntuiText *)&Texts[28],10,0);
- strcpy(SelTask,"N/A ");
- PrintIText(RastPort,(struct IntuiText *)&Texts[28],384,0);
- UpdateTasks();
- return;
- }
- State = MEMORY;
- PrintIText(RastPort,(struct IntuiText *)&Texts[37],10,0);
- RemoveGList(MainWin,&Bools[3],13);
- Bools[13].GadgetText = &Texts[31];
- Bools[6].GadgetText = &Texts[39];
- for (count = 3;count != 16;count++) Bools[count].Flags |= GADGDISABLED;
- Bools[13].Flags &= ~GADGDISABLED;
- AddGList(MainWin,&Bools[3],3,13,NULL);
- RefreshGList(&Bools[3],MainWin,NULL,13);
- PrintIText(RastPort,(struct IntuiText *)&Texts[41],10,0);
- strcpy(SelTask,"N/A ");
- PrintIText(RastPort,(struct IntuiText *)&Texts[28],84,0);
- current = NULL;
- TaskNum = 0;
- if(first) FreeList();
- if(GetList()) return;
- first = tinfo;
- Disable();
- for(memheader = (struct MemHeader *)SysBase->MemList.lh_Head;
- memheader->mh_Node.ln_Succ;
- memheader = (struct MemHeader *)memheader->mh_Node.ln_Succ)
- {
- if(memheader->mh_Attributes & MEMF_CHIP) type = 1;
- else type = 0;
- for(memchunk = memheader->mh_First;memchunk;memchunk = memchunk->mc_Next)
- {
- TaskNum++;
- if(type) strcpy(tinfo->tempname,"CHIP");
- else strcpy(tinfo->tempname,"FAST");
- tinfo->Addr = (struct Task *)memchunk;
- sprintf(tinfo->data," %08lx %10lu %s %10u %-23.23s",
- memchunk,memchunk->mc_Bytes - sizeof(struct MemChunk),
- tinfo->tempname,TaskNum," ");
- if(GetList()) {Enable(); return;}
- }
- }
- Enable();
- ti = tinfo->prev;
- ti->next = NULL;
- FreeMem(tinfo,sizeof(struct TInfo));
- for(cur = first,count = 0;count != min(7,TaskNum);cur = cur->next,count++)
- {
- ItemAddr[count] = cur;
- SelTexts[count].IText = cur->data;
- }
- if(count < 7) ClearSelect(count);
- RefreshGList(Select,MainWin,NULL,7);
- ModifyP(0);
- }
-
-
- void WinScr()
- {
- struct Screen *CurScr;
- struct Window *CurWin;
- struct TInfo *cur,*ti;
- int count;
-
- PrevSelected = NULL;
- if(State == WINSCR)
- {
- State = TASKS;
- RemoveGList(MainWin,&Bools[3],13);
- Bools[14].GadgetText = &Texts[14];
- Bools[7].GadgetText = &Texts[7];
- for (count = 3;count != 16;count++) Bools[count].Flags |= GADGDISABLED;
- Bools[3].Flags &= ~GADGDISABLED;
- Bools[13].Flags &= ~GADGDISABLED;
- Bools[14].Flags &= ~GADGDISABLED;
- AddGList(MainWin,&Bools[3],3,13,NULL);
- WipeGadg();
- RefreshGList(&Bools[3],MainWin,NULL,13);
- Texts[24].NextText = NULL;
- PrintIText(RastPort,(struct IntuiText *)&Texts[24],10,0);
- Texts[24].NextText = &Texts[23];
- PrintIText(RastPort,(struct IntuiText *)&Texts[18],10,0);
- strcpy(SelTask,"NONE ");
- PrintIText(RastPort,(struct IntuiText *)&Texts[28],10,0);
- strcpy(SelTask,"N/A ");
- PrintIText(RastPort,(struct IntuiText *)&Texts[28],384,0);
- UpdateTasks();
- GraphPtr = NULL;
- return;
- }
- State = WINSCR;
- PrintIText(RastPort,(struct IntuiText *)&Texts[37],10,0);
- RemoveGList(MainWin,&Bools[3],13);
- Bools[14].GadgetText = &Texts[31];
- Bools[7].GadgetText = &Texts[38];
- for (count = 3;count != 16;count++) Bools[count].Flags |= GADGDISABLED;
- Bools[14].Flags &= ~GADGDISABLED;
- AddGList(MainWin,&Bools[3],3,13,NULL);
- RefreshGList(&Bools[3],MainWin,NULL,13);
- strcpy(SelTask,"NONE ");
- PrintIText(RastPort,(struct IntuiText *)&Texts[28],36,0);
- strcpy(SelTask,"N/A ");
- PrintIText(RastPort,(struct IntuiText *)&Texts[28],384,0);
- current = NULL;
- TaskNum = 0;
- if(first) FreeList();
- Disable();
- CurScr = IntuitionBase->FirstScreen;
- if(GetList()) {Enable(); return;}
- first = tinfo;
- while(CurScr)
- {
- sprintf(tinfo->data,"Screen:%-54.54s %08lx",
- CurScr->Title,CurScr);
- tinfo->Addr = (struct Task *)CurScr;
- strcpy(tinfo->tempname,"screen");
- tinfo->name = CurScr->Title;
- TaskNum++;
- CurWin = CurScr->FirstWindow;
- while(CurWin)
- {
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"Window:%-45.45s %08lx %08lx",
- CurWin->Title,CurWin->IDCMPFlags,CurWin);
- tinfo->Addr = (struct Task *)CurWin;
- strcpy(tinfo->tempname,"window");
- tinfo->name = CurWin->Title;
- CurWin = CurWin->NextWindow;
- TaskNum++;
- }
- CurScr = CurScr->NextScreen;
- if(GetList()) {Enable(); return;}
- }
- Enable();
- ti = tinfo->prev;
- ti->next = NULL;
- FreeMem(tinfo,sizeof(struct TInfo));
- for(cur = first,count = 0;count != min(7,TaskNum);cur = cur->next,count++)
- {
- ItemAddr[count] = cur;
- SelTexts[count].IText = cur->data;
- }
- if(count < 7) ClearSelect(count);
- RefreshGList(Select,MainWin,NULL,7);
- ModifyP(0);
- }
-
-
- void SwapOut()
- {
- ULONG Lower,Sig[3];
- APTR segment;
- int actual;
-
- if(!PrevSelected) { Message(NOTASK); return;}
- if(!FindTask(PrevSelected->tc_Node.ln_Name)) {Message(NOTFOUND); return;}
- if(PrevSelected->tc_State == 2) { Message(NSWAPME); return; }
- if(!FirstSeg) {Message(NOSEG); return;}
- if(SegSum >= SSpace) {Message(NOSPC); return;}
- if(PrevSelected->tc_State == 9) {Message(SWAPPED); return;}
- if(Confirm(9)) return;
- if(!(file = fopen(SBuff,"w"))) {Message(NOFILE); return;}
- Message(WAIT);
- Forbid();
- PrevSelected->tc_State = 9;
- Remove((struct Node *)PrevSelected);
- Insert(&(SysBase->IntrList),(struct Node *)PrevSelected,NULL);
- memcpy((char *)Sig,(char *)&(PrevSelected->tc_SigWait),12);
- memset((char *)&(PrevSelected->tc_SigWait),0,12);
- Permit();
- segment = FirstSeg;
- while(segment)
- {
- Lower = (ULONG)segment + 4;
- SegSize = ((ULONG *)segment)[-1];
- segment = (APTR)(((ULONG *)segment)[0] * 4);
- if(SegSize < 200) continue;
- CurSeg = (APTR)(Lower - 8);
- actual = fwrite((char *)&CurSeg,4,1,file);
- if(actual != 1) {Message(WERROR); fclose(file); return;}
- actual = fwrite((char *)&SegSize,4,1,file);
- if(actual != 1) {Message(WERROR); fclose(file); return;}
- actual = fwrite((char *)CurSeg,1,SegSize,file);
- if(actual != SegSize) {Message(WERROR); fclose(file); return;}
- FreeMem(CurSeg,SegSize);
- DisplayRam();
- }
- CurSeg = NULL;
- actual = fwrite((char *)&CurSeg,4,1,file);
- if(actual != 1) {Message(WERROR); fclose(file); return;}
- actual = fwrite((char *)Sig,4,3,file);
- if(actual != 3) {Message(WERROR); fclose(file); return;}
- fclose(file);
- RemoveGList(MainWin,&Bools[9],1);
- Bools[9].Flags |= GADGDISABLED;
- AddGList(MainWin,&Bools[9],9,1,NULL);
- RefreshGList(&Bools[9],MainWin,NULL,1);
- Message(DONE);
- }
-
-
- void SwapIn()
- {
- int actual;
- ULONG Sig[3];
-
- if(!PrevSelected) {Message(NOTASK); return;}
- if(PrevSelected->tc_State != 9) {Message(NSWAPPED); return;}
- if(!(file = fopen(SBuff,"r"))) {Message(NOFILE); return;}
- Message(WAIT);
- if(first) FreeList();
- SegSum = 0;
- NumSwap = 0;
- while(TRUE)
- {
- actual = fread((char *)&SegAddr,4,1,file);
- if(actual != 1) {FreeSwap(1); return;}
- if(SegAddr == NULL) break;
- actual = fread((char *)&SegSize,4,1,file);
- if(actual != 1) {FreeSwap(1); return;}
- fclose(file); file = NULL;
- if(!AllocAbs(SegSize,SegAddr))
- {
- FreeSwap(0);
- Message(OCCUPIED1); Message(OCCUPIED2);
- Message(FREED);
- return;
- }
- if(!(file = fopen(SBuff,"r"))) {Message(NOFILE); return;}
- fseek(file,SegSum + (NumSwap + 1) * 8,0);
- actual = fread((char *)SegAddr,1,SegSize,file);
- if(actual != SegSize) {FreeSwap(1); return;}
- NumSwap++;
- SegSum += SegSize;
- }
- actual = fread((char *)Sig,4,3,file);
- if(actual != 3) {FreeSwap(1); return;}
- if(file) fclose(file);
- Forbid();
- PrevSelected->tc_State = 3;
- memcpy((char *)&(PrevSelected->tc_SigWait),(char *)Sig,12);
- Remove((struct Node *)PrevSelected);
- Insert(&(SysBase->TaskReady),(struct Node *)PrevSelected,NULL);
- Permit();
- Update();
- Message(DONE);
- }
-
-
- void FreeSwap(Arg)
- int Arg;
- {
- int count;
-
- if(file) fclose(file);
- if(Arg) Message(RERROR);
- if(!NumSwap) return;
- if(!(file = fopen(SBuff,"r"))) {Message(NOFILE); return;}
- for(count = 0;count <NumSwap;count++)
- {
- fread((char *)&SegAddr,4,1,file);
- if(feof(file)) break;
- fread((char *)&SegSize,4,1,file);
- if(feof(file)) break;
- FreeMem(SegAddr,SegSize);
- DisplayRam();
- fseek(file,SegSize,1);
- }
- fclose(file);
- if(Arg) Message(FREED);
- }
-
-
- void FindIntruder()
- {
- struct TInfo *curtask,*temp,*cur;
- ULONG SegUp,Size,Up,skip,Lower;
- APTR Segment,Seg;
- int actual,NotFound = TRUE;
-
- if(!(file = fopen(SBuff,"r"))) {Message(NOFILE); return;}
- Message(WAIT);
- temp = first;
- if(GetList()) return;
- first = tinfo->prev;
- first->next = NULL;
- first = tinfo;
- while(TRUE)
- {
- curtask = temp;
- actual = fread((char *)&SegAddr,4,1,file);
- if(actual != 1) {Message(RERROR); fclose(file); return;}
- if(SegAddr == NULL) break;
- actual = fread((char *)&SegSize,4,1,file);
- if(actual != 1) {Message(RERROR); fclose(file); return;}
- SegUp = (ULONG)SegAddr + SegSize;
- while(FindTask((curtask->Addr)->tc_Node.ln_Name))
- {
- Segment = FindFirstSegment(curtask->Addr);
- while(Segment)
- {
- Lower = (ULONG)Segment + 4;
- Size = ((ULONG *)Segment)[-1];
- Segment = (APTR)(((ULONG *)Segment)[0] * 4);
- Seg = (APTR)(Lower - 8);
- Up = (ULONG)Seg + Size;
- skip = FALSE;
- if(((Seg > SegAddr) && ((ULONG)Seg < SegUp)) ||
- ((Up > (ULONG)SegAddr) && (Up < SegUp)))
- {
- for(cur = first;cur;cur = cur->next)
- if(curtask->Addr == cur->Addr) skip = TRUE;
- if(!skip)
- {
- sprintf(ErrorT[INTRUDER],"Intruder task address:%08lx ",curtask->Addr);
- tinfo->Addr = curtask->Addr;
- if(GetList()) { FreeList(); first = temp; fclose(file); return;}
- Message(INTRUDER);
- NotFound = FALSE;
- }
- }
- }
- if(!(curtask = curtask->next)) break;
- }
- fseek(file,SegSize,1);
- }
- FreeList();
- fclose(file);
- first = temp;
- if(NotFound) Message(INTNFOUND);
- else Message(DONE);
- }
-
-
- APTR FindFirstSegment(taskptr)
- struct Task *taskptr;
- {
- APTR segment = 0;
- struct Process *proc;
- struct CommandLineInterface *cli;
-
- if(taskptr->tc_State == 9) { return(NULL); }
- proc = (struct Process *)taskptr;
- if(taskptr->tc_Node.ln_Type == 13)
- {
- segment = (APTR)((proc->pr_SegList) << 2);
- segment = (APTR)(((ULONG *)segment)[3] << 2);
- if(!segment)
- {
- cli = (struct CommandLineInterface *) (((ULONG)proc->pr_CLI) << 2);
- segment = (APTR)((ULONG)cli->cli_Module << 2);
- }
- }
- return(segment);
- }
-
-
- void Seg()
- {
- ULONG Lower,Upper,Size;
- APTR segment = 0;
- int count;
- struct Process *proc;
- struct TInfo *cur;
- char type[6];
-
- SegSum = 0;
- FirstSeg = NULL;
- if(State == INFO)
- {
- State = TASKS;
- RemoveGList(MainWin,&Bools[3],13);
- Bools[12].GadgetText = &Texts[12];
- for (count = 3;count != 16;count++) Bools[count].Flags &= ~GADGDISABLED;
- Bools[9].Flags = GADGDISABLED; Bools[8].Flags = GADGDISABLED;
- Bools[15].Flags = GADGDISABLED;
- RemoveGList(MainWin,&Bools[3],13);
- if(PrevSelected->tc_State == 9 || PrevSelected->tc_State == 2)
- {
- for (count = 3;count != 16;count++) Bools[count].Flags |= GADGDISABLED;
- if(PrevSelected->tc_State == 9)
- Bools[4].Flags = Bools[8].Flags = Bools[15].Flags &= ~GADGDISABLED;
- else
- {
- Bools[4].Flags &= ~GADGDISABLED;
- Bools[10].Flags = Bools[11].Flags = Bools[12].Flags &= ~GADGDISABLED;
- }
- Bools[3].Flags = Bools[13].Flags = Bools[14].Flags &= ~GADGDISABLED;
- Bools[6].Flags &= ~GADGDISABLED;
- }
- AddGList(MainWin,&Bools[3],3,13,NULL);
- WipeGadg();
- RefreshGList(&Bools[3],MainWin,NULL,13);
- RemoveGList(MainWin,Select,7);
- for (count = 0;count != 7;count++) Select[count].Flags = GADGHCOMP;
- AddGList(MainWin,Select,-1,7,NULL);
- Texts[24].NextText = NULL;
- PrintIText(RastPort,(struct IntuiText *)&Texts[24],10,0);
- Texts[24].NextText = &Texts[23];
- UpdateTasks();
- return;
- }
- State = INFO;
- if(!PrevSelected) { Message(NOTASK); return; }
- if(PrevSelected->tc_State == 9) { Message(SWAPPED); return; }
- if(!FindTask(PrevSelected->tc_Node.ln_Name)) {Message(NOTFOUND); return;}
- TaskNum = 1;
- RemoveGList(MainWin,&Bools[3],13);
- Bools[12].GadgetText = &Texts[31];
- for (count = 3;count != 16;count++) Bools[count].Flags |= GADGDISABLED;
- Bools[12].Flags &= ~GADGDISABLED;
- if(PrevSelected->tc_State != 2) Bools[9].Flags = GADGHIMAGE;
- AddGList(MainWin,&Bools[3],3,13,NULL);
- WipeGadg();
- RefreshGList(&Bools[3],MainWin,NULL,13);
- RemoveGList(MainWin,Select,7);
- for (count = 0;count != 7;count++) Select[count].Flags = GADGHNONE;
- AddGList(MainWin,Select,-1,7,NULL);
- PrintIText(RastPort,(struct IntuiText *)&Texts[33],10,0);
- if(first) FreeList();
- Disable();
- current = NULL;
- if(GetList()) {Enable(); return;}
- first = tinfo;
- proc = (struct Process *)PrevSelected;
- if(PrevSelected->tc_Node.ln_Type == 13)
- {
- if(PrevSelected->tc_State == 9) {Message(SWAPPED); Enable(); return;}
- if(!FindTask(PrevSelected->tc_Node.ln_Name))
- {Message(NOTFOUND); Enable(); return;}
- segment = FindFirstSegment(PrevSelected);
- FirstSeg = segment;
- while(segment)
- {
- TaskNum++;
- Lower = (ULONG)segment + 4;
- Size = ((ULONG *)segment)[-1];
- Upper = Lower + Size - 8;
- SegSum += Size;
- if(MEMF_CHIP & TypeOfMem(Lower)) strcpy(type,"CHIP");
- else strcpy(type,"FAST");
- sprintf(tinfo->data," %08lx %08lx %10lu %s %-23s",
- Lower,Upper,Size,type," ");
- if(GetList()) {Enable(); return;}
- segment = (APTR)(((ULONG *)segment)[0] * 4);
- }
- }
- Enable();
- if(SegSum == 0) Bools[9].Flags |= GADGDISABLED;
- RefreshGList(&Bools[9],MainWin,NULL,1);
- sprintf(tinfo->data,"Total Memory: %10lu %-21s",
- SegSum," ");
- for(cur = first,count = 0;count != min(7,TaskNum);cur = cur->next,count++)
- {
- ItemAddr[count] = cur;
- SelTexts[count].IText = cur->data;
- }
- if(count < 7) ClearSelect(count);
- ModifyP(0);
- RefreshGList(Select,MainWin,NULL,7);
- }
-
-
- void GetInfo()
- {
- struct Process *proc = (struct Process *)PrevSelected;
- struct Window *PW;
- struct CommandLineInterface *cli;
- struct TInfo *cur;
- UBYTE title[40];
- int count;
- APTR segment;
-
- if(State == INFO)
- {
- State = TASKS;
- RemoveGList(MainWin,&Bools[3],13);
- Bools[4].GadgetText = &Texts[4];
- for (count = 3;count != 16;count++) Bools[count].Flags &= ~GADGDISABLED;
- Bools[9].Flags = GADGDISABLED;
- if(PrevSelected->tc_State == 9 || PrevSelected->tc_State == 2)
- {
- for (count = 3;count != 16;count++) Bools[count].Flags |= GADGDISABLED;
- if(PrevSelected->tc_State == 9)
- Bools[4].Flags = Bools[8].Flags = Bools[15].Flags &= ~GADGDISABLED;
- else
- {
- Bools[4].Flags &= ~GADGDISABLED;
- Bools[10].Flags = Bools[11].Flags = Bools[12].Flags &= ~GADGDISABLED;
- }
- Bools[3].Flags = Bools[13].Flags = Bools[14].Flags &= ~GADGDISABLED;
- Bools[6].Flags &= ~GADGDISABLED;
- }
- AddGList(MainWin,&Bools[3],3,13,NULL);
- WipeGadg();
- RefreshGList(&Bools[3],MainWin,NULL,13);
- RemoveGList(MainWin,Select,7);
- for (count = 0;count != 7;count++) Select[count].Flags = GADGHCOMP;
- AddGList(MainWin,Select,-1,7,NULL);
- Texts[24].NextText = NULL;
- PrintIText(RastPort,(struct IntuiText *)&Texts[24],10,0);
- Texts[24].NextText = &Texts[23];
- UpdateTasks();
- return;
- }
- State = INFO;
- if(!PrevSelected) { Message(NOTASK); return; }
- RemoveGList(MainWin,&Bools[3],13);
- Bools[4].GadgetText = &Texts[31];
- for (count = 3;count != 16;count++) Bools[count].Flags |= GADGDISABLED;
- Bools[4].Flags &= ~GADGDISABLED;
- AddGList(MainWin,&Bools[3],3,13,NULL);
- RefreshGList(&Bools[3],MainWin,NULL,13);
- RemoveGList(MainWin,Select,7);
- for (count = 0;count != 7;count++) Select[count].Flags = GADGHNONE;
- AddGList(MainWin,Select,-1,7,NULL);
- PrintIText(RastPort,(struct IntuiText *)&Texts[32],10,0);
- Disable();
- current = NULL;
- if(first) FreeList();
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"Task Information: %-30.30s",
- " ");
- first = tinfo;
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"IDNestCnt = %08lx TDNestCnt = %08lx %-17s",
- proc->pr_Task.tc_IDNestCnt,proc->pr_Task.tc_TDNestCnt," ");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"SigAlloc = %08lx SigWait = %08lx %-17s",
- proc->pr_Task.tc_SigAlloc,proc->pr_Task.tc_SigWait," ");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"SigRecvd = %08lx SigExcept = %08lx %-17s",
- proc->pr_Task.tc_SigRecvd,proc->pr_Task.tc_SigExcept," ");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"TrapAlloc = %08lx TrapAble = %08lx %-17s",
- proc->pr_Task.tc_TrapAlloc,proc->pr_Task.tc_TrapAble," ");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"ExceptData = %08lx ExceptCode = %08lx %-17s",
- proc->pr_Task.tc_ExceptData,proc->pr_Task.tc_ExceptCode," ");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"SPReg = %08lx %-23s",
- proc->pr_Task.tc_SPReg," ");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"SPLower = %08lx SPUpper = %08lx %-17s",
- proc->pr_Task.tc_SPLower,proc->pr_Task.tc_SPUpper," ");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"Switch() : %08lx Launch() : %08lx %-17s",
- proc->pr_Task.tc_Switch,proc->pr_Task.tc_Launch," ");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"UserData = %08lx %-20s",
- proc->pr_Task.tc_UserData);
- TaskNum = 10;
- if(proc->pr_Task.tc_Node.ln_Type == 13)
- {
- PW = (struct Window *)proc->pr_WindowPtr;
- if(PW != (struct Window *)-1L && PW) strncpy(title,PW->Title,38);
- else strcpy(title,"");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"Process Information: %-20s",
- " ");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"WindowPtr = %08lx Title : %-22.22s",PW,title);
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"CurrentDir = %08lx %-20s",
- proc->pr_CurrentDir << 2," ");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"StackBase = %08lx StackSize = %08lx %-17s",
- proc->pr_StackBase << 2,proc->pr_StackSize," ");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"CIS = %08lx COS = %08lx %-17s",
- proc->pr_CIS << 2,proc->pr_COS << 2," ");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"ConsoleTask = %08lx FileSystemTask = %08lx%-17s",
- proc->pr_ConsoleTask,proc->pr_FileSystemTask," ");
- segment = (APTR) (((ULONG)proc->pr_SegList) << 2);
- segment = (APTR) (((ULONG *)segment)[3] << 2);
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"SegList = %08lx SegPointer = %08lx %-17s",
- proc->pr_SegList << 2,segment," ");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"PktWait = %08lx CLI = %08lx %-17s",
- proc->pr_PktWait,proc->pr_CLI," ");
- TaskNum += 8;
- }
- if(proc->pr_CLI)
- {
- cli = (struct CommandLineInterface *)((ULONG)proc->pr_CLI << 2);
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"CommandLineInterface Information: %-20s",
- " ");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"CommandDir = %08lx %-20s",
- cli->cli_CommandDir << 2," ");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"StdInput = %08lx StdOutput = %08lx %-17s",
- cli->cli_StandardInput << 2 ,cli->cli_StandardOutput << 2," ");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"CurrentInput = %08lx CurrentOutput = %08lx %-17s",
- cli->cli_CurrentInput << 2,cli->cli_CurrentOutput << 2," ");
- if(GetList()) {Enable(); return;}
- sprintf(tinfo->data,"Module = %08lx %-20s",
- cli->cli_Module << 2," ");
- TaskNum += 5;
- }
- Enable();
- for(cur = first,count = 0;count != 7;cur = cur->next,count++)
- {
- ItemAddr[count] = cur;
- SelTexts[count].IText = cur->data;
- }
- RefreshGList(Select,MainWin,NULL,7);
- ModifyP(0);
- }
-
-
- void Kill()
- {
- struct Window *CurWin,*CurWin2;
- struct Screen *CurScr;
-
- if(State == WINSCR)
- {
- if(!GraphPtr) { Message(NOGRAPH); return; }
- if(Confirm(7)) return;
- Disable();
- if(!strcmp(GraphPtr->tempname,"window"))
- {
- CurWin = (struct Window *)GraphPtr->Addr;
- if(CurWin->MenuStrip) ClearMenuStrip(GraphPtr->Addr);
- CloseWindow(GraphPtr->Addr);
- }
- else
- {
- CurScr = (struct Screen *)GraphPtr->Addr;
- CurWin = CurScr->FirstWindow;
- while(CurWin)
- {
- CurWin2 = CurWin->NextWindow;
- if(CurWin->MenuStrip) ClearMenuStrip(CurWin);
- CloseWindow(CurWin);
- CurWin = CurWin2;
- }
- CloseScreen(CurScr);
- }
- Enable();
- Message(DONE);
- DisplayRam();
- GraphPtr = NULL;
- State = TASKS;
- WinScr();
- return;
- }
- if(!PrevSelected) { Message(NOTASK); return; }
- if(FindTask(PrevSelected->tc_Node.ln_Name))
- {
- if(PrevSelected->tc_State == 2) { Message(NOSUICIDE); return; }
- if(PrevSelected->tc_State == 9) { Message(NOKILL); return; }
- if(Confirm(7)) return;
- Disable();
- MP = (struct MsgPort *)SysBase->PortList.lh_Head;
- while(MP->mp_Node.ln_Succ)
- {
- if((MP->mp_SigTask == PrevSelected) && strcmp(MP->mp_Node.ln_Name,"IDCMP"))
- {
- PredMP = (struct MsgPort *)MP->mp_Node.ln_Pred;
- DeletePort(MP);
- if(PredMP == (struct MsgPort *)&(SysBase->PortList))
- MP = (struct MsgPort *)SysBase->PortList.lh_Head;
- else MP = (struct MsgPort *)PredMP->mp_Node.ln_Succ;
- }
- else MP = (struct MsgPort *)MP->mp_Node.ln_Succ;
- }
- RemTask(PrevSelected);
- Enable();
- Update();
- Message(DONE);
- }
- else Message(NOTFOUND);
- }
-
-
- void Pri()
- {
- int NewPri;
-
- if(State == MEMORY) { Message(NOTIMP); return; }
- if(!PrevSelected) { Message(NOTASK); return;}
- strcpy(Temp,SBuff);
- sprintf(SBuff,"%d",PrevSelected->tc_Node.ln_Pri);
- RefreshGList(&Bools[17],MainWin,NULL,1);
- PrintIText(RastPort,(struct IntuiText *) &Texts[29],10,0);
- ActivateGadget(&Bools[17],MainWin,NULL);
- Message(NEWPRI);
- do
- {
- WaitPort(MainWin->UserPort);
- message = (struct IntuiMessage *)GetMsg(MainWin->UserPort);
- class = message->Class;
- GadgetPtr = (struct Gadget *)message->IAddress;
- GadgetNum = GadgetPtr->GadgetID;
- ReplyMsg((struct Message *) message);
- switch(GadgetNum)
- {
- case 0: MoveDown(1);
- break;
- case 1: MoveUp(1);
- break;
- case 2: PropMoved();
- break;
- }
- } while(GadgetNum != 17);
- sscanf(SBuff,"%d",&NewPri);
- if((NewPri > 127) || (NewPri < -128))
- {
- Message(OUTRANGE);
- strcpy(SBuff,Temp);
- RefreshGList(&Bools[17],MainWin,NULL,1);
- Texts[23].NextText = NULL;
- PrintIText(RastPort,(struct IntuiText *) &Texts[23],10,0);
- Texts[23].NextText = &Texts[22];
- DisplaySwap();
- return;
- }
- if(FindTask(PrevSelected->tc_Node.ln_Name))
- {
- SetTaskPri(PrevSelected,NewPri);
- UpdateTasks();
- Message(DONE);
- }
- else Message(NOTFOUND);
- Texts[23].NextText = NULL;
- PrintIText(RastPort,(struct IntuiText *) &Texts[23],10,0);
- Texts[23].NextText = &Texts[22];
- strcpy(SBuff,Temp);
- RefreshGList(&Bools[17],MainWin,NULL,1);
- DisplaySwap();
- }
-
-
- void SendSig()
- {
- if(!PrevSelected) { Message(NOTASK); return; }
- if(PrevSelected->tc_State == 9) { Message(NOSIGNAL); return; }
- if(Confirm(10)) return;
- strcpy(Temp,SBuff);
- strcpy(SBuff,"");
- RefreshGList(&Bools[17],MainWin,NULL,1);
- ActivateGadget(&Bools[17],MainWin,NULL);
- PrintIText(RastPort,(struct IntuiText *) &Texts[30],10,0);
- Message(SIGMASK);
- do
- {
- WaitPort(MainWin->UserPort);
- message = (struct IntuiMessage *)GetMsg(MainWin->UserPort);
- class = message->Class;
- GadgetPtr = (struct Gadget *)message->IAddress;
- GadgetNum = GadgetPtr->GadgetID;
- ReplyMsg((struct Message *) message);
- switch(GadgetNum)
- {
- case 0: MoveDown(1);
- break;
- case 1: MoveUp(1);
- break;
- case 2: PropMoved();
- break;
- }
- } while(GadgetNum != 17);
- sscanf(SBuff,"%08lx",&SigMask);
- if(FindTask(PrevSelected->tc_Node.ln_Name))
- {
- Signal(PrevSelected,SigMask);
- Delay(30);
- UpdateTasks();
- Message(DONE);
- }
- else Message(NOTFOUND);
- Texts[23].NextText = NULL;
- PrintIText(RastPort,(struct IntuiText *) &Texts[23],10,0);
- Texts[23].NextText = &Texts[22];
- strcpy(SBuff,Temp);
- RefreshGList(&Bools[17],MainWin,NULL,1);
- DisplaySwap();
- }
-
-
- void Break()
- {
- if(!PrevSelected) { Message(NOTASK); return; }
- if(PrevSelected->tc_State == 9) { Message(NOBREAK); return; }
- if(Confirm(11)) return;
- if(FindTask(PrevSelected->tc_Node.ln_Name))
- {
- SMask = 0xf000L;
- SMask = SMask & PrevSelected->tc_SigAlloc;
- Signal(PrevSelected,SMask);
- Delay(30);
- UpdateTasks();
- Message(DONE);
- }
- else Message(NOTFOUND);
- }
-
-
- void DisplaySwap()
- {
- struct InfoData *IF;
- struct FileLock *lock;
- char Path[100],*Pos;
-
- strcpy(SwapS,"N/A ");
- IF = (struct InfoData *)
- AllocMem(sizeof(struct InfoData),MEMF_CHIP|MEMF_CLEAR);
- if(!IF)
- {
- Message(NOMEM);
- PrintIText(RastPort,(struct IntuiText *) &Texts[27],10,0);
- return;
- }
- strcpy(Path,SBuff);
- Pos = strchr(Path,':');
- if(Pos) *(Pos + 1) = NULL;
- lock = (struct FileLock *)Lock(Path,ACCESS_READ);
- if(lock)
- {
- if(Info(lock,IF))
- {
- if(IF->id_DiskType == ID_DOS_DISK)
- {
- SSpace = (IF->id_NumBlocks - IF->id_NumBlocksUsed) * IF->id_BytesPerBlock;
- sprintf(SwapS,"%-10lu",SSpace);
- }
- }
- UnLock(lock);
- }
- FreeMem(IF,sizeof(struct InfoData));
- PrintIText(RastPort,(struct IntuiText *) &Texts[27],10,0);
- }
-
-
- void Freeze()
- {
- if(!PrevSelected) { Message(NOTASK); return; }
- if(PrevSelected->tc_State == 9) { Message(NOFREEZE); return; }
- if(PrevSelected->tc_State != 8)
- {
- if(FindTask(PrevSelected->tc_Node.ln_Name))
- {
- Disable();
- if(PrevSelected->tc_State == 2) { Enable(); Message(NOTME); return;}
- Remove((struct Node *)PrevSelected);
- Insert(&(SysBase->IntrList),(struct Node *)PrevSelected,NULL);
- PrevSelected->tc_State = 8;
- MP = (struct MsgPort *)SysBase->PortList.lh_Head;
- while(MP->mp_Node.ln_Succ)
- {
- if(MP->mp_SigTask == PrevSelected) MP->mp_Flags = PA_IGNORE;
- MP = (struct MsgPort *)MP->mp_Node.ln_Succ;
- }
- }
- else { Message(NOTFOUND); return; }
- }
- else
- {
- Disable();
- Remove((struct Node *)PrevSelected);
- Insert(&(SysBase->TaskReady),(struct Node *)PrevSelected,NULL);
- PrevSelected->tc_State = 3;
- MP = (struct MsgPort *)SysBase->PortList.lh_Head;
- while(MP->mp_Node.ln_Succ)
- {
- if(MP->mp_SigTask == PrevSelected) MP->mp_Flags = PA_SIGNAL;
- MP = (struct MsgPort *)MP->mp_Node.ln_Succ;
- }
- }
- Enable();
- if(PrevSelected->tc_State == 8) Bools[5].GadgetText = &Texts[42];
- else Bools[5].GadgetText = &Texts[5];
- RefreshGList(&Bools[5],MainWin,NULL,1 );
- UpdateTasks();
- Message(DONE);
- return;
- }
-
-
- void ClearSelect(count)
- int count;
- {
- char *SPC =
- " ";
- for(;count < 7;count++) SelTexts[count].IText = SPC;
- }
-
-
- void DisplayRam()
- {
- ChipRam = AvailMem(MEMF_CHIP);
- FastRam = AvailMem(MEMF_FAST);
- sprintf(CRam,"%-10lu",ChipRam);
- sprintf(FRam,"%-10lu",FastRam);
- PrintIText(RastPort,(struct IntuiText *) &Texts[26],12,0);
- }
-
-
- void Message(ErrorNum)
- int ErrorNum;
- {
- int count;
-
- if(Row < 4)
- {
- strcpy(ETextAddr[Row],ErrorT[ErrorNum]);
- PrintIText(RastPort,(struct IntuiText *) &ErrIntuiText[Row],10,0);
- Row += 1;
- return;
- }
- for(count = 0;count < 3;count++)
- {
- strcpy(ErrIntuiText[count].IText,ErrIntuiText[count + 1].IText);
- PrintIText(RastPort,(struct IntuiText *) &ErrIntuiText[count],10,0);
- }
- strcpy(ErrIntuiText[3].IText,ErrorT[ErrorNum]);
- PrintIText(RastPort,(struct IntuiText *) &ErrIntuiText[3],10,0);
- }
-
-
- void UpdateTasks()
- {
- int count;
- struct TInfo *cur;
-
- if(first) FreeList();
- current = NULL;
- TaskNum = 1;
- SysBase->IntrList.lh_Type = NT_TASK;
- Disable();
- task = (struct Task *)SysBase->ThisTask;
- if(GetTaskInfo(task)) { Enable(); return; }
- first = tinfo;
- for(task = (struct Task *)SysBase->TaskReady.lh_Head;
- task->tc_Node.ln_Succ;task = (struct Task *)task->tc_Node.ln_Succ)
- {
- TaskNum++;
- if(GetTaskInfo(task)) { Enable(); return; }
- }
- for(task = (struct Task *)SysBase->TaskWait.lh_Head;
- task->tc_Node.ln_Succ;task = (struct Task *)task->tc_Node.ln_Succ)
- {
- TaskNum++;
- if(GetTaskInfo(task)) { Enable(); return; }
- }
- for(task = (struct Task *)SysBase->IntrList.lh_Head;
- task->tc_Node.ln_Succ;task = (struct Task *)task->tc_Node.ln_Succ)
- {
- TaskNum++;
- if(GetTaskInfo(task)) { Enable(); return; }
- }
- Enable();
- for(cur = first,count = 0;count != min(7,TaskNum);cur = cur->next,count++)
- {
- ItemAddr[count] = cur;
- SelTexts[count].IText = cur->data;
- }
- if (count < 7) ClearSelect(count);
- RefreshGList(Select,MainWin,NULL,7);
- ModifyP(0);
- }
-
- void WipeGadg()
- {
- int count;
-
- for (count = 0;count != 3;count++)
- PrintIText(RastPort,(struct IntuiText *)&Texts[34],33,97 + 8 * count);
- PrintIText(RastPort,(struct IntuiText *)&Texts[34],33,115);
- }
-
- int GetTaskInfo(t)
- struct Task *t;
- {
- if(GetList()) return(FAILER);
- GetTaskName(t);
- tinfo->Addr = t;
- sprintf(tinfo->data,"%-21.21s %4d %-7s %7u %-9s %08lx %08lx ",
- tinfo->name,t->tc_Node.ln_Pri,state[(int)t->tc_State],
- (ULONG)t->tc_SPUpper - 2 -(ULONG)t->tc_SPLower,
- type[(int)t->tc_Node.ln_Type],t->tc_SigWait,t);
- return(SUCCESS);
- }
-
-
- int GetList()
- {
- tinfo = (struct TInfo *)AllocMem(sizeof(struct TInfo),MEMF_PUBLIC|MEMF_CLEAR);
- if(!tinfo) { Message(NOMEM); return(FAILER); }
- if(current)
- {
- tinfo->prev = current;
- current->next = tinfo;
- tinfo->next = NULL;
- }
- current = tinfo;
- return(SUCCESS);
- }
-
-
- void GetTaskName(t)
- struct Task *t;
- {
- struct Process *proc;
- struct CommandLineInterface *cli;
- UBYTE *str,*cliname;
- int num;
-
- if(t->tc_Node.ln_Type == 13)
- {
- proc = (struct Process *)t;
- if(proc->pr_TaskNum == 0) tinfo->name = proc->pr_Task.tc_Node.ln_Name;
- else
- {
- num = proc->pr_TaskNum;
- cli = (struct CommandLineInterface *)((long)(proc->pr_CLI) << 2);
- str = (UBYTE *)((long)(cli->cli_CommandName) << 2);
- cliname = (UBYTE *)BCPLtoC(str);
- if(*(cliname) == 0) cliname = "Unloaded CLI";
- sprintf(tinfo->tempname,"[CLI %d] %-25.25s",num,cliname);
- tinfo->name = tinfo->tempname;
- }
- }
- else tinfo->name = t->tc_Node.ln_Name;
- }
-
-
- UBYTE *BCPLtoC(bstring)
- UBYTE *bstring;
- {
- UBYTE strbuffer[256];
- int len = *bstring++;
- strncpy(strbuffer,bstring,len);
- *(strbuffer + len) = NULL;
- return(strbuffer);
- }
-
-
- void FreeList()
- {
- struct TInfo *temp,*next;
-
- temp = first;
- while(temp != NULL)
- {
- next = temp->next;
- FreeMem(temp,sizeof(struct TInfo));
- temp = next;
- }
- first = NULL;
- }
-
- void CloseAll(RetCode)
- int RetCode;
- {
- if(UpData) FreeMem(UpData,sizeof(Up));
- if(DownData) FreeMem(DownData,sizeof(Down));
- if(MainWin) CloseWindow(MainWin);
- if(MainScr) CloseScreen(MainScr);
- if(DOSBase) CloseLibrary(DOSBase);
- if(GfxBase) CloseLibrary(GfxBase);
- if(IntuitionBase) CloseLibrary(IntuitionBase);
- exit(RetCode);
- }
-