Article View: comp.sys.transputer
Article #1064Re: Changing process priorities?
From: Rob Kurver
Date: Wed, 24 Oct 1990 21:21
Date: Wed, 24 Oct 1990 21:21
87 lines
3144 bytes
3144 bytes
Recently, Naranker Dulay wrote:
> In transputer assembly code how does a low priority process become a
> high priority process?
Try the following code. Unshar, edit to suit your favorite assembler,
assemble and link in with the rest of your code. Now, you can call
stpri() at any time with the priority you want to be at. It works both
ways, i.e. stpri (0) switches to high priority, and stpri (1) switches to
low.
Sorry, no man page... :-)
#!/bin/sh
# This is a shell archive (shar 3.47)
# made 10/24/1990 21:16 UTC by rob@pact
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 1333 -rw-r--r-- stpri.s
#
# ============= stpri.s ==============
if test -f 'stpri.s' -a X"$1" != X"-c"; then
echo 'x - skipping stpri.s (File already exists)'
else
echo 'x - extracting stpri.s (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'stpri.s' &&
; Set priority of current process to argument given.
; Actually, we start a new process at the requested priority, and stop
; the current one.
X
; Assembly, so edit for your favorite assembler...
X
X
; static int Dummy[10]
;
; Couple of words to use as dummy workspace for original process before
; it is stopped.
X
X .dseg
X .bword 0, 10 ; workspace for old process
X .cseg
X
;
; void stpri (int pri)
;
; Set priority to argument given (0 is hi, 1 is high)
X
X .public stpri
stpri:
X stl 0
X ldc stpri2-stpri1 ; start of high priority process
X ldpi
stpri1:
X stl -1 ; store IPtr (to switch to high priority)
X ldlp 0 ; get current WPtr
X ldl 2
X ldc 1
X and ; get priority (1st argument)
X or ; make process decriptor with requested priority
X ldl 1
X ldnlp Dummy+8 ; load Dummy workspace address
X gajw ; switch to Dummy workspace
X rev ; get process descriptor in Areg
X runp ; run process at new priority
X stopp ; stop current ('old') process
stpri2:
X ret ; new process continues here
SHAR_EOF
chmod 0644 stpri.s ||
echo 'restore of stpri.s failed'
Wc_c="`wc -c < 'stpri.s'`"
test 1333 -eq "$Wc_c" ||
echo 'stpri.s: original size 1333, current size' "$Wc_c"
fi
exit 0
Enjoy. - Rob
--
PACT Rob Kurver
Foulkeslaan 87 rob@pact.nl
2625 RB Delft
The Netherlands +31 15 616864
Technical Details
Message-ID:
<m0iRsXZ-0000fSC@pact.pact.nl>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!ogicse!ucsd!ucbvax!pact.nl!robReferences:
<2391@gould.doc.ic.ac.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!ogicse!ucsd!ucbvax!pact.nl!rob From: rob@pact.nl (Rob Kurver) Newsgroups: comp.sys.transputer Subject: Re: Changing process priorities? Message-ID: <m0iRsXZ-0000fSC@pact.pact.nl> Date: 24 Oct 90 21:21:34 GMT References: <2391@gould.doc.ic.ac.uk> Sender: daemon@ucbvax.BERKELEY.EDU Organization: PACT, Foulkesln 87, 2625RB Delft, The Netherlands, +31 15 616864 Lines: 87