ain@j.cc.purdue.edu (Patrick White) (06/10/88)
Submitted by: jeff@novavax (Jeffrey Bailey)
Summary: eps -- extended process status, stp -- set task priority
Poster Boy: Patrick White (ain@j.cc.purdue.edu)
Archive Name: sources/amiga/volume5/eps-stp.d.sh.Z binaries/amiga/volume6/eps-stp.d.sh.Z
Tested but not compiled.
NOTES:
This contains two relates programs -- eps which prints out what processes
are running and their priorties, and stp which sets the task priorities.
I redid the shar to separate docs, sources, and binaries.
-- Pat White (co-moderator comp.sources/binaries.amiga)
ARPA/UUCP: j.cc.purdue.edu!ain BITNET: PATWHITE@PURCCVM PHONE: (317) 743-8421
U.S. Mail: 320 Brown St. apt. 406, West Lafayette, IN 47906
[How do you get to heaven? Go to Pluto and hang a left.]
========================================
# This is a shell archive.
# Remove everything above and including the cut line.
# Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar: Shell Archiver
# Run the following text with /bin/sh to create:
# eps.man
# stp.man
# This archive created: Fri Jun 3 12:13:33 1988
# By: Patrick White (PUCC Land, USA)
echo shar: extracting eps.man '(2640 characters)'
cat << \SHAR_EOF > eps.man
NAME
eps - Enhanced ps utility
SYNTAX
eps
DESCRIPTION
This program is an enhanced form of the ps utility. It should be
placed in the C: directory on your workbench disk. It can only
be run from the CLI. When run, it produces output similar to
the following:
Task Name Pri St Address P CLI I Command Name Current Dir
---------------- ---- --- -------- - --- - ---------------- ----------------
Initial CLI 0 RUN c04fd0 P 1 I c:eps ASDG-RAM:
Workbench 1 WAI c0f1a0 P 0 I
Background CLI -1 WAI c27a30 P 3 B c:cron Workbench 1.2:
RAM 0 WAI c1e620 P
Background CLI 5 WAI c23250 P 2 B c:loadavg Workbench 1.2:
File System 10 WAI c05dc0 P
VD0 5 WAI c2a028 P
input.device 20 WAI c02672 T
trackdisk.device 5 WAI c047a6 T
trackdisk.device 5 WAI c01446 T
File System 10 WAI c00a98 P
CON 5 WAI c06a90 P
The following is a brief explanation of each field:
TASK NAME - This is the ASCII name found in the task structure.
PRI - This is the task's current priority printed in decimal.
ST - This is the task's current state. All states are abbreviated
to three letters. For example, RUN means this is the currently
executing task, RDY means that this task is ready for the CPU,
WAI means this task is currently in a wait state, etc.
ADDRESS - This is the address of the task's TCB (Task Control Block)
printed in hexadecimal.
P - This indicates whether the task is a task, or a process. 'T'
indicates a task, 'P' indicates a process.
CLI - If the process is also a CLI process, the CLI task array number
is printed in this field.
I - This field indicates whether the CLI process was started as
an interactive 'I', or a background 'B' process. Background
processes are the result of the RUN command.
COMMAND NAME - This is the name of the command as DOS sees it in
the filing system.
CURRENT DIRECTORY - This is the current working directory of the
CLI process.
SEE ALSO
stp
BUGS
The TASK NAME, COMMAND NAME, and CURRENT DIRECTORY are
truncated to a length of 16 characters each, for formatting
purposes.
AUTHOR
Jeffrey Bailey
Programmer/Analyst
Nova University
Ft. Lauderdale, FL
UUCP:...{ihnp4!codas, ucf-cs, allegra}!novavax!jeff
UUCP:...{ihnp4!codas, ucf-cs, allegra}!novavax!regulus!jeff (Private)
SHAR_EOF
if test 2640 -ne "`wc -c eps.man`"
then
echo shar: error transmitting eps.man '(should have been 2640 characters)'
fi
echo shar: extracting stp.man '(1024 characters)'
cat << \SHAR_EOF > stp.man
NAME
stp - Set Task Priority
SYNTAX
stp <hexadecimal TCB address> <decimal priority>
DESCRIPTION
This command allows the dynamic adjustment of a task's priority for
any task currently in the system. A hexadecimal Task Control
Block (TCB) address must be specified. This address is checked
for validity. A decimal priority in the range of -128 to 127 must
also be specified. This is also checked for validity.
The TCB is specified in hexadecimal, and the priority in decimal,
because, by convention, this is the format used by most 'ps'
type utilities.
SEE ALSO
eps
BUGS
This command allows the priority of ANY task in the system to be
arbitrarily changed. Changing system tasks' priorities is, in
general, a BAD idea.
AUTHOR
Jeffrey Bailey
Programmer/Analyst
Nova University
Ft. Lauderdale, FL 33324
UUCP:...{ihnp4!codas, ucf-cs, allegra}!novavax!jeff
UUCP:...{ihnp4!codas, ucf-cs, allegra}!novavax!regulus!jeff (Private)
SHAR_EOF
if test 1024 -ne "`wc -c stp.man`"
then
echo shar: error transmitting stp.man '(should have been 1024 characters)'
fi
# End of shell archive
exit 0ain@j.cc.purdue.edu (Patrick White) (06/11/88)
Submitted by: jeff@novavax (Jeffrey Bailey)
Summary: eps -- extended process status, stp -- set task priority
Poster Boy: Patrick White (ain@j.cc.purdue.edu)
Archive Name: sources/amiga/volume5/eps-stp.s.sh.Z
Tested but not compiled.
NOTES:
This contains two relates programs -- eps which prints out what processes
are running and their priorties, and stp which sets the task priorities.
I redid the shar to separate docs, sources, and binaries.
-- Pat White (co-moderator comp.sources/binaries.amiga)
ARPA/UUCP: j.cc.purdue.edu!ain BITNET: PATWHITE@PURCCVM PHONE: (317) 743-8421
U.S. Mail: 320 Brown St. apt. 406, West Lafayette, IN 47906
[How do you get to heaven? Go to Pluto and hang a left.]
========================================
# This is a shell archive.
# Remove everything above and including the cut line.
# Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar: Shell Archiver
# Run the following text with /bin/sh to create:
# README
# stp.c
# This archive created: Fri Jun 3 12:15:08 1988
# By: Patrick White (PUCC Land, USA)
echo shar: extracting README '(377 characters)'
cat << \SHAR_EOF > README
I did not include the C source to the eps utility, for the simple
reason that I extensively used routines from my personal library in
this program. It would be more effort than it is worth to extract
the specific sources used from my library. Without these library
routines, the source to eps is virtually useless.
I hope you find these utilities of some use.
--Jeff
SHAR_EOF
if test 377 -ne "`wc -c README`"
then
echo shar: error transmitting README '(should have been 377 characters)'
fi
echo shar: extracting stp.c '(4901 characters)'
cat << \SHAR_EOF > stp.c
#include <stdio.h>
#include <exec/types.h>
#include <exec/exec.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <exec/memory.h>
#include <exec/execbase.h>
#include <exec/tasks.h>
#include <exec/ports.h>
#include <exec/io.h>
/*
Program: stp.c (Set Task Priority)
Purpose: Change a currently existing task's priority.
Author: Jeffrey Bailey
Date: 3/15/88
Usage: stp <hex TCB address> <dec. priority>
Compiler: Lattice C 4.0
Porting: It should be relatively easy to modify this to work
with Aztec C. The only special routine I used was
strtol(), which may or may not exist in Aztec.
I release this program into the public domain. You may use all or
part of the source code for any purpose whatsoever. All I ask is
that you give credit where credit is due.
I do not guarantee this program in any way, shape, or form. Note
that it does work for me, and I have attempted to test it
thoroughly. Use it at your own risk. You can report
any bugs, problems, features, suggestions, etc. to the address below.
I do not promise to change or fix anything, but I will try to
respond to any mail messages I receive - please include a good
return path in your message!
UUCP:...{ihnp4!codas, ucf-cs, allegra}!novavax!jeff
UUCP:...{ihnp4!codas, ucf-cs, allegra}!novavax!regulus!jeff (Private)
(routing through codas preferred)
*/
struct ExecBase *ExecBase;
void main(argc, argv)
int argc;
char *argv [];
{
char *badchar;
struct Task *tad;
long tpri;
int saneaddr;
/*
If started from WorkBench, exit. Don't bother printing an error msg.
*/
if(argc == 0) exit(20);
if(argc < 3)
{
puts("STP: Missing args. Supply a task address and a priority.");
exit(20);
}
if(argc > 3)
{
puts("STP: Too many args. Supply a task address and a priority.");
}
/*
Convert hex string to a pointer value. If strtol() sets badchar to point
to a NULL, then conversion went ok. Otherwise, badchar points at char in
error.
*/
tad = (struct Task *) strtol(argv [1], &badchar, 16);
if(*badchar != NULL)
{
puts("STP: Bad hex string conversion on task address.");
exit(20);
}
/*
Convert decimal string to an integer value. If strtol() sets badchar to
point to a NULL, then conversion went ok. Otherwise, badchar points at
char in error.
*/
tpri = strtol(argv [2], &badchar, 10);
if(*badchar != NULL)
{
puts("STP: Bad decimal string conversion on task priority.");
exit(20);
}
/*
Check priority to make sure it's within proper bounds.
*/
if(tpri < -128)
{
puts("STP: Priority specified is too low. Must be no less than -128.");
exit(20);
}
if(tpri > 127)
{
puts("STP: Priority specified is too high. Must be no greater than 127.");
exit(20);
}
/*
Get ExecBase pointer. We need this to do sanity checking on the TCB
address supplied.
*/
if( (ExecBase = (struct ExecBase *) OpenLibrary("exec.library",0)) == 0 )
{
puts("STP: Couldn't open Exec Library.");
exit(20);
}
/*
Disable interrupts. The RKM says this is necessary when scanning exec
lists. Apparently Forbid() isn't good enough in this instance.
*/
Disable();
/*
Do our TCB address sanity checking. Set the new task priority if the
address is valid.
*/
if( (saneaddr = sane_address(tad)) )
{
SetTaskPri(tad, tpri);
}
/*
Enable interrupts again.
*/
Enable();
/*
If we couldn't find the TCB, complain. Can't do this inside the Disable()
Enable() pair, 'cause we can't keep interrupts disabled for very long, plus
the RKM warns against printing when you disable interrupts.
*/
if(!saneaddr)
{
puts("STP: Can't find TCB at specified address.");
}
exit(0);
}
sane_address(taskaddr)
register struct Task *taskaddr;
{
register struct Task *task;
/*
Check to see if we're trying to modify the current task's priority.
*/
if(taskaddr == ExecBase->ThisTask) return(1);
/*
Check the ready queue for our TCB.
*/
for(task = (struct Task *)ExecBase->TaskReady.lh_Head; task->tc_Node.ln_Succ;
task = (struct Task *)task->tc_Node.ln_Succ)
{
if(task == taskaddr) return(1);
}
/*
Check the wait queue for our TCB.
*/
for(task = (struct Task *)ExecBase->TaskWait.lh_Head; task->tc_Node.ln_Succ;
task = (struct Task *)task->tc_Node.ln_Succ)
{
if(task == taskaddr) return(1);
}
/*
If we got to this point, we haven't found our TCB. Return failure.
*/
return(0);
}
SHAR_EOF
if test 4901 -ne "`wc -c stp.c`"
then
echo shar: error transmitting stp.c '(should have been 4901 characters)'
fi
# End of shell archive
exit 0