Article View: comp.sys.transputer
Article #1102Unix Occam Compiler (Part 3 of 4)
From: Terry Torkelson
Date: Wed, 14 Nov 1990 19:41
Date: Wed, 14 Nov 1990 19:41
441 lines
9044 bytes
9044 bytes
----------test.shar----------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# test
# This archive created: Thu Apr 19 16:54:38 1990
export PATH; PATH=/bin:$PATH
if test ! -d 'test'
then
mkdir 'test'
fi
cd 'test'
if test -f 'semaphore.oc'
then
echo shar: will not over-write existing file "'semaphore.oc'"
else
cat << \SHAR_EOF > 'semaphore.oc'
-- counting semaphore handler using buffered-channels in Occam.
extern proc pnum(value n):
def MAXSEM = 5:
def MAXN = 100: -- maximum size of buffer of semaphores
que sempool(MAXN)[MAXSEM]:
var nsem:
var s:
proc setsem(value v, var sn) =
seq
sn := nsem
nsem := nsem + 1
seq j = [0 for v]
sempool[sn] ! ANY :
proc p(value sn) =
sempool[sn] ? ANY :
proc v(value sn) =
sempool[sn] ! ANY :
seq
setsem(3, s)
-- first run without semahpores
par p = [0 for 2]
seq q = [0 for 10]
pnum(p)
-- then run with semaphores
par i = [0 for 2]
seq k = [0 for 10]
seq
p(s)
pnum(i)
v(s)
SHAR_EOF
fi # end of overwriting check
if test -f 'SEM'
then
echo shar: will not over-write existing file "'SEM'"
else
cat << \SHAR_EOF > 'SEM'
Executed 126 instructions in 66 time
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
0
0
1
0
1
1
0
0
1
1
0
0
1
0
1
SHAR_EOF
fi # end of overwriting check
if test -f 'RAND'
then
echo shar: will not over-write existing file "'RAND'"
else
cat << \SHAR_EOF > 'RAND'
Panic: [8 ,101]: deadlock
5
9
6
6
5
3
5
6
8
1
5
6
1
8
7
2
7
5
9
3
8
6
3
8
7
1
3
3
4
4
9
3
8
5
1
9
5
6
3
4
0
9
8
5
1
3
8
8
3
4
SHAR_EOF
fi # end of overwriting check
if test -f 'TRACE'
then
echo shar: will not over-write existing file "'TRACE'"
else
cat << \SHAR_EOF > 'TRACE'
[0 , 0]<FORK> create 1 at 0x48
[1 , 0]<IO> opened 0(0)
[1 , 0]<IO> opened 1(0)
[1 , 0]<IO> opened 2(0)
[1 , 0]<IO> open channel table at 0x4E4C - 5
[1 , 0]<IO> opened 3(0)
[1 , 0]<IO> opened 4(0)
[1 , 0]<IO> opened 5(0)
[1 , 0]<IO> opened 6(0)
[1 , 0]<IO> opened 7(0)
[1 , 0]<IO> opened 8(0)
[1 , 0]<FORK> create 2 at 0xA8
[1 , 0]<FORK> create 3 at 0xBE
[2 , 0]<IO> read on 8
[3 , 0]<FORK> create 4 at 0xD8
[3 , 0]<FORK> create 5 at 0xD8
[3 , 0]<FORK> create 6 at 0xD8
[3 , 0]<FORK> create 7 at 0xD8
[3 , 0]<FORK> create 8 at 0xD8
[6 ,2000]<IO> write on 8
[8 ,4000]<IO> write on 8
[5 ,1000]<IO> write on 8
[4 , 0]<IO> write on 8
[ Sys ]<IO> [8] sent 4 bytes from [4 , 0] to [2 , 0]
[4 , 1]<IO> read on 3
[2 , 1]<IO> read on 8
[7 ,3000]<IO> write on 8
[ Sys ]<IO> [8] sent 4 bytes from [5 ,1000] to [2 , 1]
[5 ,1001]<IO> read on 4
[2 ,1001]<IO> read on 8
[ Sys ]<IO> [8] sent 4 bytes from [6 ,2000] to [2 ,1001]
[6 ,2001]<IO> read on 5
[2 ,2001]<IO> read on 8
[ Sys ]<IO> [8] sent 4 bytes from [7 ,3000] to [2 ,2001]
[7 ,3001]<IO> read on 6
[2 ,3001]<IO> read on 8
[ Sys ]<IO> [8] sent 4 bytes from [8 ,4000] to [2 ,3001]
[8 ,4001]<IO> read on 7
[2 ,4001]<IO> write on 3
[ Sys ]<IO> [3] sent 4 bytes from [2 ,4001] to [4 , 1]
[2 ,4002]<IO> write on 4
[4 ,4002]<IO> write on 8
[ Sys ]<IO> [4] sent 4 bytes from [2 ,4002] to [5 ,1001]
[2 ,4003]<IO> write on 5
[5 ,5003]<IO> write on 8
[ Sys ]<IO> [5] sent 4 bytes from [2 ,4003] to [6 ,2001]
[2 ,4004]<IO> write on 6
[6 ,6004]<IO> write on 8
[ Sys ]<IO> [6] sent 4 bytes from [2 ,4004] to [7 ,3001]
[2 ,4005]<IO> write on 7
[7 ,7005]<IO> write on 8
[ Sys ]<IO> [7] sent 4 bytes from [2 ,4005] to [8 ,4001]
[2 ,4006]<IO> read on 8
[8 ,8006]<IO> write on 8
[ Sys ]<IO> [8] sent 4 bytes from [4 ,4002] to [2 ,4006]
[2 ,4007]<IO> read on 8
[4 ,4007]<IO> read on 3
[ Sys ]<IO> [8] sent 4 bytes from [5 ,5003] to [2 ,4007]
[5 ,5004]<IO> read on 4
[2 ,5004]<IO> read on 8
[ Sys ]<IO> [8] sent 4 bytes from [6 ,6004] to [2 ,5004]
[6 ,6005]<IO> read on 5
[2 ,6005]<IO> read on 8
[ Sys ]<IO> [8] sent 4 bytes from [7 ,7005] to [2 ,6005]
[7 ,7006]<IO> read on 6
[2 ,7006]<IO> read on 8
[2 ,7006]<IO> read on 8
b[ Sys ]<IO> [8] sent 4 bytes from [8 ,8006] to [2 ,7006]
[8 ,8007]<IO> read on 7
[2 ,8007]<IO> write on 3
[ Sys ]<IO> [3] sent 4 bytes from [2 ,8007] to [4 ,4007]
[2 ,8008]<IO> write on 4
[4 ,8009]<FORK> ended
[ Sys ]<IO> [4] sent 4 bytes from [2 ,8008] to [5 ,5004]
[2 ,8009]<IO> write on 5
[5 ,8010]<FORK> ended
[ Sys ]<IO> [5] sent 4 bytes from [2 ,8009] to [6 ,6005]
[2 ,8010]<IO> write on 6
[6 ,8011]<FORK> ended
[ Sys ]<IO> [6] sent 4 bytes from [2 ,8010] to [7 ,7006]
[2 ,8011]<IO> write on 7
[7 ,8012]<FORK> ended
[ Sys ]<IO> [7] sent 4 bytes from [2 ,8011] to [8 ,8007]
[2 ,8013]<FORK> ended
[8 ,8013]<FORK> ended
[3 ,8013]<FORK> ended
[1 ,8013]<IO> closed 8
[1 ,8013]<IO> close channel table at 0x4E4C - 5
[1 ,8013]<IO> closed 3
[1 ,8013]<IO> closed 4
[1 ,8013]<IO> closed 5
[1 ,8013]<IO> closed 6
[1 ,8013]<IO> closed 7
[1 ,8013]<FORK> ended
Executed 20046 instructions in 8013 time
SHAR_EOF
fi # end of overwriting check
if test -f 'RESULTS'
then
echo shar: will not over-write existing file "'RESULTS'"
else
cat << \SHAR_EOF > 'RESULTS'
** compiling simple
** running simple
** compiling pr459
SHAR_EOF
fi # end of overwriting check
if test -f 'itoa.oc'
then
echo shar: will not over-write existing file "'itoa.oc'"
else
cat << \SHAR_EOF > 'itoa.oc'
-- convert (positive) integer to string (decimal representation) and print it.
extern proc chassign(chan c, value fd, mode):
def MAX = 200: -- should be enough..
var str[BYTE MAX]:
var x:
proc convert(value n, var pos) =
var tmp:
var nn:
seq
nn := n
pos := MAX -1
while (nn > 0 and pos > 0)
seq
tmp := nn / 10
tmp := nn - tmp*10
nn := nn / 10
str[BYTE pos] := '0' + tmp
pos := pos - 1 :
seq
chassign(OUTPUT, 1, 1)
convert(1223, x)
OUTPUT ! str[BYTE x for MAX-x]
OUTPUT ! "*n"
SHAR_EOF
fi # end of overwriting check
if test -f 'simple.oc'
then
echo shar: will not over-write existing file "'simple.oc'"
else
cat << \SHAR_EOF > 'simple.oc'
-- some simple OCCAM constructs.
var a:
chan c:
def N = 20:
seq
a := 1
while (a < N)
a := a + 1
par
c ? ANY
c ! N
seq i = [0 for N]
a := a / 2
SHAR_EOF
fi # end of overwriting check
if test -f 'RESULTS.good'
then
echo shar: will not over-write existing file "'RESULTS.good'"
else
cat << \SHAR_EOF > 'RESULTS.good'
** compiling simple
** running simple
Executed 62 instructions in 61 time
** compiling pr459
** running pr459
Executed 1 instructions in 1 time
459
** compiling randgen
** running randgen
** compiling prog
** running prog with tracing
** compiling itoa
** running itoa
seq j = [0 for 1000*n]
skip
sync ! DONE
c ? ANY :
proc manager =
seq h = [0 for N]
seq
seq k = [0 for NPROC]
sync ? ANY
seq l = [0 for NPROC]
chtab[l] ! ACK :
par
manager
par p = [0 for NPROC]
worker(chtab[p], p)
SHAR_EOF
fi # end of overwriting check
if test -f 'randgen.oc'
then
echo shar: will not over-write existing file "'randgen.oc'"
else
cat << \SHAR_EOF > 'randgen.oc'
-- random number generator using 'ALT'. produces a random series of N numbers
-- in the range 0..MAX.
extern proc pnum(value n):
def MAX = 10:
def N = 50:
chan chtab[MAX]:
proc select =
seq i = [0 for N]
alt j = [0 for MAX]
chtab[j] ? ANY
pnum(j) :
proc foreversend(chan c) =
while TRUE
c ! ANY :
par
select
par k = [0 for MAX]
foreversend(chtab[k])
SHAR_EOF
fi # end of overwriting check
if test -f 'pnum.c'
then
echo shar: will not over-write existing file "'pnum.c'"
else
cat << \SHAR_EOF > 'pnum.c'
pnum(n)
{
printf("%d\n", n);
}
SHAR_EOF
fi # end of overwriting check
if test -f 'pr459.oc'
then
echo shar: will not over-write existing file "'pr459.oc'"
else
cat << \SHAR_EOF > 'pr459.oc'
extern proc pnum(value n):
pnum(459)
SHAR_EOF
fi # end of overwriting check
cd ..
# End of shell archive
exit 0
----------end of test.shar----------
--
-
- Terry Torkelson Internet: ttork%ewu@uunet.uu.net
- Eastern Washington University uucp: uunet!isc-br!ewu!ttork
- tellynet: 509-359-6016
Technical Details
Message-ID:
<1339@ewu.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cmcl2!yale!think.com!sdd.hp.com!usc!apple!olivea!oliveb!isc-br!ewu!ttorkShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cmcl2!yale!think.com!sdd.hp.com!usc!apple!olivea!oliveb!isc-br!ewu!ttork From: ttork@ewu.UUCP (Terry Torkelson) Newsgroups: comp.sys.transputer Subject: Unix Occam Compiler (Part 3 of 4) Keywords: Occam Message-ID: <1339@ewu.UUCP> Date: 14 Nov 90 19:41:17 GMT Distribution: usa Organization: Eastern Washington Univ. Cheney WA Lines: 441