1\ifx\undefined\selectfont
2
3\documentstyle[11pt,reduce,twoside]{article}
4
5\newcommand{\dotitlepage}{%
6  \vspace*{\fill}
7  \nopagebreak
8  \begin{center}
9    \Huge
10    PSL 4.2\\
11    \huge
12    Installation Guide and\\
13    Addendum to the PSL\\
14    User's Manual\\[40mm]
15    \LARGE
16    Winfried Neun\\[80mm]
17    \Large
18    Konrad-Zuse-Zentrum Berlin 1995
19  \end{center}
20}
21
22\newcommand{\VERYLARGE}{\Huge}
23
24\else
25\documentstyle[11pt,epsfig,reduce,nfltxsym,twoside]{article}
26\makeatletter
27
28\define@nomathsize{70}
29\define@nomathsize{40}
30
31\makeatother
32
33\renewcommand{\encodingdefault}{T1}
34\renewcommand{\familydefault}{ptm}
35\renewcommand{\rmdefault}{ptm}
36\renewcommand{\sfdefault}{phv}
37\renewcommand{\ttdefault}{pcr}
38\renewcommand{\bfdefault}{b}
39
40\newcommand{\dotitlepage}{%
41  \vspace*{\fill}
42  \nopagebreak
43  \begin{center}
44    \fontsize{70}{75pt}\selectfont
45    PSL 4.2\\
46    \fontsize{40}{65pt}\selectfont
47    Installation Guide and\\
48    Addendum to the\\
49    PSL User's Manual\\[40mm]
50    \LARGE
51    Winfried Neun\\[45mm]
52    \mbox{\epsfig{file=ziblogo.eps,width=21mm}}\\[10mm]
53    \Large
54    Konrad-Zuse-Zentrum Berlin 1995
55  \end{center}
56}
57
58\newcommand{\VERYLARGE}{\fontsize{40}{65pt}\selectfont}
59
60\fi
61
62\def\xr{{\tt XR}}
63
64\makeatother
65
66\setlength{\oddsidemargin}{5mm}
67\setlength{\evensidemargin}{-5mm}
68\setlength{\textwidth}{159.2mm}
69\setlength{\textheight}{235mm}
70\addtolength{\topmargin}{-18mm}
71
72\date{}
73\sloppy
74
75\parindent 0pt
76\parskip 6pt
77\pagestyle{empty}
78\setlength{\topsep}{0.5\baselineskip}  % above and below environments
79\setlength{\itemsep}{\topsep}
80\setlength{\abovedisplayskip}{\topsep}  % for "long" equations
81\setlength{\belowdisplayskip}{\topsep}
82
83\renewcommand{\arraystretch}{1.3}
84
85\begin{document}
86\pagestyle{empty}
87\begin{titlepage}
88   \dotitlepage
89\end{titlepage}
90
91\vspace*{1cm}
92\begin{center}
93\VERYLARGE
94{\bf PSL 4.2} Installation \\
95Guide and Addendum to\\
96the PSL User's Manual\\
97\normalsize
98\vspace*{.5cm}
99{\large by} \\[0.3cm]
100{\Large Winfried Neun}\\
101{\large ZIB} \\
102{\large D-10711 Berlin-Wilmersdorf} \\[0.3cm]
103{\large Federal Republic of Germany} \\[0.5cm]
104{\large email: neun@sc.ZIB-Berlin.de} \\[0.3cm]
105{\large October 1995}\\[0.5cm]
106\vfill
107\newpage
108\end{center}
109\section{Abstract}
110This document
111contains instructions for the installation of PSL 4.2 on UNIX systems
112and it summarizes the differences between PSL 4.2, as
113described in the USERS MANUAL plus the Addendum by Stoller and Carr
114from the University of Utah (Utah Pass Opnote 07, 1987)
115and PSL Version 4.2 distributed by the
116Konrad-Zuse-Zentrum Berlin (ZIB), the version that
117is delivered on the tape (or diskettes).
118
119\section{Introduction}
120
121Since its earlier versions starting in the 80's, Portable Standard LISP
122has undergone several changes.
123
124PSL was developed for mainframe systems
125e.g. of /370 and Vax type running proprietary operating systems of the
126manufacturers. Today most PSL versions run on workstations with RISC processors
127running a Unix type operating system.
128
129Today PSL is mostly used a deliverly vehicle for LISP based systems, e.g.
130the computer algebra system REDUCE and not as a LISP dialect of its own
131right.
132
133The support and maintainance for PSL is mostly done at ZIB in Berlin.
134
135Recently, the internal representation of identifiers was changed in order
136to support a 256 character set and case sensitivity. This causes a
137binary incomptibility of .b files with older versions such as PSL 3.4.
138
139This document describes the changes and newer developments for PSL
140done at ZIB in order to improve performance and to work with new
141application types such as parallel processing.
142
143\section{Installation}
144
145This section gives instructions for the Installation of PSL 4.2 on
146your UNIX system. It does not apply for other operating systems such
147as VMS, MVS, DOS etc, and it does not apply for distribution on
148diskettes (e.g. all PC systems, IBM RS/6000, NeXT). Please read
149special instructions (below) for the system mentioned above.
150
151The Installation procedure described below uses {\tt csh} syntax.
152If you don't have csh installed on your system, please change the
153commands accordingly.
154
155PSL is stored as a single file tree with two directories on the
156top level, called bin and dist, where the later contains all sources
157and some more binary files.
158
159The installation is relatively simple.
160
161\subsection{Reading the tape}
162
163The tape contains a compressed file tree. Please cd to the directory
164where you want to store the files (called PSL root directory later on)
165and enter
166
167\begin{verbatim}
168dd if=/dev/tape ibs=51200 | uncompress | tar -xf -
169\end{verbatim}
170
171Please replace /dev/tape in the above command with the correct
172name of your tape drive.
173
174\subsection{Reading the tape for IBM RS/6000}
175
176The PSL file tree for the IBM RS/6000 is configured in the same way as for
177other Unix type workstations. The installation needs an additional
178step.
179
180The installation procedure described below assumes that you use the
181C-Shell. If you use different shells please change commands accordingly.
182
183To read the tape, make a directory with a name like .../psl, cd to that
184directory, and do, after putting the tape into the drive,
185
186\begin{verbatim}
187     tar -xf /dev/rfd0
188\end{verbatim}
189
190You first need to install a syscall into the AIX system.
191{\bf In order to do this, YOU NEED SUPER USER PRIVILEGE.}
192To install the syscall, do
193
194\begin{verbatim}
195   su
196   cd ./dist/kernel/ibmrs/syscall
197   ./install
198   ./installsysc
199   exit
200\end{verbatim}
201
202The script install compiles and installs the required system call.
203The script installsysc in the same directory installs the system call only.
204With any reboot of the system it is mandatory to run installsysc in the
205directory ./dist/kernel/ibmrs/syscall.
206It is suggested that this is included into the AIX boot files. The sources
207of the syscall can be found in ./dist/kernel/ibmrs/syscall  too.
208
209\subsection{Reading Diskettes for LINUX 386}
210
211The PSL file tree for LINUX is compressed on to 3 diskettes for
212distribution. The 3 diskettes require about 4 megabytes of disk space to
213dump.  However, you must then rebuild the binary files for your machine
214before you can do anything. Instructions on doing this are given below.
215If the files for your machine are built, the file tree then requires
216about 30 megabytes during the build (but less when complete).
217
218To read the diskettes, make a directory with a name like .../psl, cd to that
219directory, and do, after putting DISK \# 1 into the floppy disk reader,
220
221\begin{verbatim}
222     tar -xf /dev/fd0H1440
223     install_psl
224\end{verbatim}
225
226The script install\_psl prompts for the other disks and will uncompress the
227files.
228
229If there is an incompatibility between the delivered exeutable and
230your Linux version, or when you upgrade your Linux version
231and {\small PSL} becomes inoperable, you must recompile the
232executable $bpsl$:
233\begin{verbatim}
234    cd $pxk/linux
235    cclnk
236\end{verbatim}
237After this step you should rebuild the image files using the
238scripts in \verb+$psl/distrib+.
239
240\subsection{Customizing Makefiles and scripts}
241
242In the next step the system must get knowledge about the PSL root directory
243and the machine architecture. The correct name for the architecture in the
244PSL file tree can be found in the table below.
245\begin{verbatim}
246
247        Machine        Operating system      PSL MACHINE name
248
249        CDC 4xxx        EP/IX                   mips_cdc     ++
250        Convex Cxxxx                            convex       ++
251        Convex SPP                              convex_spp
252        Cray 1, X-MP    UNICOS                  crayxmp
253        Cray Y-MP       UNICOS                  crayymp
254        Cray C90        UNICOS                  crayymp
255        Crat T3D        UNICOS                  cray_t3d
256        DECStation      ULTRIX                  Mips_dec
257        DEC Alpha       OSF/1                   Alpha
258        DEC VAX         ULTRIX                  vax
259        DG AViiON       DG-UX                   88k-aviion    ++
260        HP9000/300 400  HP-UX                   bobcat        ++
261        HP9000/700      HP-UX                   Snake
262        HP9000/800      HP-UX                   spectrum      ++
263        IBM RS/6000     Aix                     Ibmrs
264        IBM SP2         * not yet available *
265        Intel 386 +     Linux                   Linux
266        SGI Iris/Indigo Irix                    Mips_iris
267        Sun 3           SunOS                   sun           ++
268        Sparc           SunOS (Solaris1.x)      Sun4
269        Sparc           Solaris (2.x)           Solaris
270
271++ This version may be not supported in future version.
272
273\end{verbatim}
274
275The script dist/distrib/newroot.csh will modify various Makefiles and
276scripts, especially dist/psl-names. It must be started with the
277PSL root directory and MACHINE name as parameter, e.g. for a Sparc under
278SUNOS:
279
280\begin{verbatim}
281dist/distrib/newroot.csh `pwd` Sun4
282\end{verbatim}
283
284After that the file dist/psl-names contains the settings for the
285PSL specific environment variables such as \$psys. It must be
286read in by the PSL user to insure correct operation,e.g. for a
287Sparc machine under SunOS:
288
289\begin{verbatim}
290setenv MACHINE Sun4
291source <PSL root directory>/dist/psl-names
292\end{verbatim}
293
294This installation is designed for usage with multiple machine types,
295it saves disk space by sharing the PSL code (.sl files).
296The vaariable  {\bf MACHINE} is used to specify the machine type.
297If you install a single version of PSL it may be useful to
298replace {\bf MACHINE} by the correct value in the file
299$<PSL root directory>$/dist/psl-names. In this case the
300user does not need to specify the MACHINE environment variable.
301
302To test the installation, you can try the following commands which
303are supposed to run without error message:
304
305\begin{verbatim}
306$psys/psl
307(load inum)
308(quit)
309\end{verbatim}
310
311If you change files, e.g. when you receive a bug fix, please
312put the file into the correct place , cd to the directory \$psl and
313simply say {\tt make}. This will compile the file (and maybe some
314files which depend on this), and produce new binaries.
315
316\subsection{Printing Documentation}
317
318The documentation for PSL (User's Manual and some more documents)
319can be found in the directories
320dist/doc and dist/lpt (in {\LaTeX} or plain ASCII print format)
321
322\section{New unexec procedure, Image model}
323
324PSL's former unexec model (Savesystem) was to produce executables
325in the sense of the operating system (mostly a.out files).
326This has led into maintainance
327problems with various new file formats (e.g. ELF, COFF) and dynamic
328loading. Influenced by the model developed for the PSL on Personal
329Computers, for all new PSL versions for new architectures the
330so called {\bf image model} is used. This simply means that
331the command {\tt savesystem} does not write an executable file but
332it puts all the LISP data into a file such that the information
333can be reloaded afterwards. The reload is done by the program
334{\tt \$pxk/bpsl} when the -f parameter is used.
335The dumpfiles names get the suffix {\tt .img}, e.g. the command
336
337\begin{verbatim}
338(savesystem "Banner" "dir/file" initform)
339\end{verbatim}
340
341produces a file {\tt dir/file.img} which can be restarted by
342issueing the command
343
344\begin{verbatim}
345$pxk/bpsl -f dir/file.img
346\end{verbatim}
347
348The LISP data written to the file are:
349{\tt SYMVAL, SYMPRP, SYMFNC, SYMNAM and SYMGET, hashtable}  and
350the allocated parts of {\tt bps and heap.}
351This reduces the amount of disk storage used drastically.
352
353To insure proper reloading, the program bpsl can be used for reloading
354of images only if these were written from its own core image.
355A check for this
356is provided using a datetag scheme which must be the same in bpsl
357and image file. The error message {\bf Cant start image with this bpsl}
358means that the check was not successful and you have to produce a new
359image file. This normally happens when the file bpsl is rebuild.
360
361In very rare cases after dramatic changes in the environment (generally
362speaking), you may get the message {\bf Cant relocate the image}.
363In this case, please try to rebuild the images. If this fails
364(it should not), please try
365
366\begin{verbatim}
367$pxk/bpsl -f dir/file.img -g 1000000
368\end{verbatim}
369
370If this works properly, you may try to reduce the g value.
371In any case please send a note the the author of this document.
372
373\def \thing #1#2#3#4 {{\noindent {\tt(#1): #2} \hfill {\it #3}}
374                      \begin{itemize}\item[] #4
375                      \end{itemize}}
376
377\section{Dynamic configuration of Heap Size and Binding Stack}
378
379The PSL workspaces {\tt Heap and Bindingstack}
380can be enlarged at run time. This is often necessary for
381programs that allocate a lot dynamic storage (heap)
382or use variable
383binding intensively.
384
385If heap space gets low, the garbage collector tries to
386increase heap size automatically. This is a reaction to an
387emergency situation though and it is tried after many garbage
388collections.  Moreover, depending on the history of the PSL session,
389the system may find itself unable to allocate the requested memory causing
390an LISP error condition. A manual increase of heap size
391is much better for overall performance.
392
393The Binding stack is not enlarged automatically, because
394in case of on infinite loop the PSL memory would blow up
395and it would take a very long time until the user would
396see a problem (if at all).
397
398Two functions have been added to PSL
399for handling heap and binding stack size:
400
401\thing{set-heap-size N:Integer or NIL}{Integer or NIL}{expr}{If called
402with NIL it returns the number of LISP items in heap.
403If called with a number (which is counted in items and should be
404bigger that the current size in items) PSL tries to allocate the
405memory. If successful, the argument is returned, if not, NIL is
406returned.}
407
408\thing{set-bndstk-size N:Integer or NIL}{Integer or NIL}{expr}{If called with NIL
409it returns the number of LISP items in bndstk.
410If called with a number (which is counted in items and should be
411bigger that the current size in items) PSL tries to allocate the
412memory. If successful, the argument is returned, if not, NIL is
413returned.}
414
415\section{Size of Address Space}
416
417The tradition PSL model is {\tt high tagged}, i.e. a tag which describes
418the data type is stored in the high bits of a LISP item. In most cases
419the number of bits used for tagging is 5, which limits the address space
420to bitsperword - 5 bits. This has not been a problem for a long time
421for the widely used 32 bit microprocessor architectures,
422since the swap space available was much less that this number. E.g
423on a Sparc system you can use about 100 MB LISP workspace, about 7000000
424LISP items.
425
426For the time being the 64 bit microprocessors do not suffer from this
427limitation. A {\tt low tagged} version of PSL is under development
428already since 1990.
429
430\section{Arbitrary Precision Integer Support}
431
432The efficient support of Arbitrary Precision Integers ("Bignums")
433is crucial for a computer algebra system. This version of PSL tries to
434exploit the given machine hardware as far as possible, e.g. using double
435size multiplication and division in hardware where available. Because of
436the different processor architectures the optimal internal representation
437of bignums may vary between workstations even with same number
438of bits per word.
439
440The PSL manual mentions the modules ``big'' and ``nbig'' which are
441written in the true spirit of portable software but these are unfortunately
442not very efficient. We recommend to use the load module
443{\bf zbig} instead. In all versions this load module contains
444the bignum version which we have found to be optimal.
445
446\section{Monitoring of Performance}
447
448\subsection{SPY (Unix only)}
449
450The Unix profil system call provides a facility to get information
451about the cpu consumption in a LISP program. A simple interface was
452build to be able to turn profiling on and off and to map the results
453on to the LISP address space. For details, please refer to the source
454code in \verb+$pxu/spy.sl+.
455\\
456
457\thing{spywhole N:Integer}{void}{expr}{Turns on profiling for the
458whole bps space. N must be a power of 2, defining the grain for the
459profil call. Typical values are 4 and 8.
460Returns {\tt nil}.}
461
462\thing{spyprint}{void}{expr}{Turns off the profiler.
463Prints profiler information
464after mapping it to the LISP address space, i.e  the names of
465LISP functions are printed together with their relative cpu consumption.
466The variable \&spyminimum\& defines the cutoff
467for spyprint, i.e. functions with less than \&spyminimum\& ticks will
468not be printed.
469Returns {\tt nil}.}
470
471\thing{spyon fwa lwa tslice bucketsize power}{void}{expr}{This is a complete
472interface for the profil call. Allocates
473Warray space for the Unix profiler and turns on profiling. fwa and lwa are the
474addresses of the first and last word of code memory which should be
475inspected, tslice is the timeslice and not suported on most Unix systems.
476It is a parameter for compatibility reasons.
477Bucketsize must be a power of 2 and power is the base 2 logarithm of
478bucketsize.  Typical values are 4 or 8 for bucketsize and 2 or 3 for
479power resp.  Returns {\tt nil}.}
480
481\thing{spyoff}{void}{expr}{Turns off profiling using the Unix
482profil system call.  Returns {\tt nil}.}
483
484Example:
485\begin{verbatim}
486(load spy zbig)
487
488NIL
489
490(spywhole 4)
491
492NIL
493
494(null (setq aa(expt 3000 10000)))
495
496NIL
497
498(spyprint)  % This was done on a SUN4 PSL
499
500	214       39.5%     BPLUSA2
501	204       37.7%     INITCODE
502	67        12.3%     WTIMESDOUBLE
503	15        2.7%      COPYFROMONESTATICHEAP
504	12        2.2%      XXCOPYFROMSTACK
505	12        2.2%      SET_HEAP_SIZE
506NIL
507\end{verbatim}
508
509It is easy to see that the command \verb+(null (setq aa(expt 3000 10000)))+
510leads to a lot of bignum computations. The spyprint output proves that.
511Please note that \verb+INITCODE+ sums up all the functions that belong
512to PSL's C runtime support. In this case the high percentage is due
513to the fact that the SPARC implementation performs integer multiply and
514divide in software i.e. in non LISP code.
515
516\subsection{Qualified timing}
517
518Qualified counting is used to measure the cpu time spend between
519call and return from a function, not necessarily spend within the
520body of the function. It gives an overview about the costs that
521a call of particular function causes. The sum shown as result may
522be bigger that 100 percent, if a function and its callee are both
523measured or if gc time is accumulated.
524\\
525
526\thing{qualtime S:list}{void}{macro}{Starts qualified timing for the
527list of functions contained in list.  Returns {\tt nil}.}
528
529\thing{print!-qualtime}{void}{expr}{Prints the accumulated timings
530and number of calls for all functions. Resets counters.  Returns {\tt nil}.}
531
532Example:
533
534\begin{verbatim}
535(load qualified-timing zbig)
536(off usermode)
537
538(qualtime gtpos times2)
539
540 (null (setq aa(expt 3000 10000))) % this will be measured
541
542(print-qualtime)
543 *********** Qualified Timing **************
544 **** Overall Cpu time :  5083  *****
545
546 *** TIMES2                    * calls : 18        * time : 5797  * % 114
547 *** GTPOS                     * calls : 5560      * time : 935   * % 18
548
549\end{verbatim}
550
551\subsection{Qualified counting}
552
553For our own applications it had turned out to be useful to know the
554callers of a function especially when the function is called very,
555very often, e.g. basic routines like generic arithmetic. To
556provide this a module qualified counting was generated using a similar
557syntax like qualified timing.
558\\
559
560\thing{qualcount S:list}{void}{macro}{Starts qualified counting for the
561list of functions contained in list.  Returns {\tt nil}.}
562
563\thing{print!-qualcount}{void}{expr}{Prints the accumulated call
564counting and the callers for all functions. Resets counters.
565Printing will be suppressed if the number of calls is less than
566\*bordervalue\* (default = 20)
567Returns {\tt nil}.}
568
569\thing{reset!-qualcount}{void}{expr}{Resets the accumulated call
570counting and the callers for all functions.
571Returns {\tt nil}.}
572
573Example:
574
575\begin{verbatim}
576 (load qualified-counting)
577 (off usermode)
578
579 (qualcount faslin intern)
580*** Function `G0003' has been redefined
581*** Function `FASLIN' has been redefined
582*** Function `G0025' has been redefined
583*** Function `INTERN' has been redefined
584
585 (load nbig30) % this will be counted
586
587(print-qualcount)
588************* calls for function FASLIN *************
589
590************* calls for function INTERN *************
591
592number of calls : 306 from READ-ID-TABLE
593\end{verbatim}
594
595
596\section{Compiler Modifications}
597
598In order to optimize the code generation for the RISC processors which
599(in most cases) have a concept of delayed branches a speciaal optimization
600phase for the PSL compiler was build to fill the delay slots. This
601new compiler phase is called {\bf lapopt} it collects several optimizations
602which work on the generated stream of instructions
603(the lap code). This  optimization phase is enabled by default,
604it is controled by the switch {\bf lapopt}, and it can be turned off and on by
605\begin{verbatim}
606(on lapopt)    and  (off lapopt)
607\end{verbatim}
608
609A sample of optimized code can be found in the following section
610on disassemble.
611
612\section{Disassembler}
613
614For most implementations of PSL a disassembler for compiled functions
615is available which gives insight into the 'real' code. It is a tool
616for code optimization only and not meant to give insight for the
617'normal' LISP user.  \\
618Example:
619\begin{verbatim}
620(load disassemble)
621NIL
622(disassemble 'get)
623( ** Function  GET  at 16#36110)
624
62500036110    9DE3BFA0    save       r14,-x'60,r14
62600036114    3B3E0000    sethi      -x'20000,r29
62700036118    21360002    sethi      -x'9FFFE,r16             Alloc 2
6280003611C    A2100002    or         r0,r2,r17                (frame 1)
62900036120    9930601B    srl        r1,x'1B,r12
63000036124    80A3201E    subcc      r12,x'1E,r0
63100036128    32800007    bne,a      L0003
6320003612C    82100006    or         r0,r6,r1
63300036130    9930A01B    srl        r2,x'1B,r12
63400036134    80A3201E    subcc      r12,x'1E,r0
63500036138    22800005    be,a       L0004
6360003613C    88100006    or         r0,r6,r4
63700036140    82100006    or         r0,r6,r1
638                    L0003:
63900036144    81C7E008    jmpl       r31+8,r0
64000036148    81E82000    restore    r0,0,r0
641
642              ... etc ...
643\end{verbatim}
644
645\section{More unsupported software}
646
647A few parts of the PSL system or applications are no longer useful
648or cant be supported.
649
650\subsection{Oload not supported}
651
652We discontinue the support of OLOAD, which allows on some versions
653to link in external routines into PSL at run time using the system loader.
654As alternative we recommend the usage of shared memory (see below).
655An example how to use an shared memory based oload substitute is under
656development.
657
658\subsection{Portable Common Lisp Subset (PCLS) not supported}
659
660If you want Common LISP , please use Common LISP.
661
662\section{Shared Memory Interface (Unix only)}
663
664The PSL shared memory interface provides all function for
665operating with shared memory regions and semaphores
666(See e.g. Unix man pages for shmop,shmget,shmctl,semop,semctl,semget etc.)
667The definitions of these man pages are used in the paragraph.
668Using the memory address map mechanism described below,it
669is easy to write one's own shared memory application.
670
671In the rest of this paragraph we describe a simple model
672implementation of a 'pipe' using shared memory and a semaphore.
673This code is contained in the file \$pu/shmem.sl.
674\\
675
676\thing{shm!-open S:pair M:Mode}{any}{expr}{If S = 0 a new shared
677memory area is allocated. Otherwise S is expected to be a dotted pair
678of shmid and semid of an existing shared memory. Legal modes are
679{\bf input\_create, output\_create, input and output}.
680A list consisting of channelnumber shmid and semid is returned.}
681
682\thing{independentdetachshm C:channel}{any}{expr}{Detaches the
683shared memory region used by C, closes the channel.}
684
685\thing{readfromshm C:channel}{any}{expr}{Waits until
686the shared memory region is readable, reads an expression and
687resets the mode to writable. Returns the expression.}
688
689\thing{writetoshm C:channel E:expression}{list}{expr}{Waits until
690the shared memory region is writeable, prints the expression
691using prin2. Returns the value of prin2.}
692
693
694The following C program works together with the PSL part
695such that it prints the messages read from shared memory
696when they are ready for printing. It must be started with
697two paramemters, namely the shmid and the semid to synchronize
698with the PSL part.
699
700\begin{verbatim}
701
702#include <stdio.h>
703#include <sys/types.h>
704#include <sys/ipc.h>
705#include <sys/sem.h>
706
707struct sembuf ;
708
709struct sembuf sembu;
710struct sembuf *sembuptr;
711
712main (argc,argv)
713     int argc;
714     char *argv[];
715
716{ int sema , shmemid;
717  char * shmaddress;
718
719  sembuptr = &sembu;
720
721  sscanf(argv[1],"%d",&shmemid);
722  sscanf(argv[2],"%d",&sema);
723
724  /* open shared memory */
725
726 printf("the data is : %d %d\n",shmemid,sema);
727  shmaddress = shmat(shmemid,0,0);
728
729  while (1)
730  { waitsema(sema) ; /* wait for a 0 */
731    printf("the message is : %s \n",shmaddress +4);
732    setsema (sema,2) ; /* ok, eaten */
733  }
734}
735
736setsema (sema,val)
737int sema,val;
738{ semctl(sema,0,SETVAL,val); }
739
740waitsema (sema)
741
742int sema;
743{
744  sembu.sem_num =0; sembu.sem_op = 0; sembu.sem_flg =0;
745
746  semop (sema, sembuptr , 1);
747}
748\end{verbatim}
749
750\section{Socket interface (Unix only)}
751
752to be added....
753
754\section{Pipe Interface (Unix only)}
755
756The Pipe interface establishes a pipe as a PSL channel from which
757(or to which) normal PSL read/write operations can be used.
758Pipes are specially useful to supply data to other processes, e.g.
759REDUCE uses it to send data to a plot program.
760\\
761
762\thing{pipe!-open S:string M:Mode}{integer}{expr}{Starts a process and
763executes the command in <string>. The mode must be either Input or Output.
764Returns a channel.}
765
766Pipes are closed with a normal close call. This will kill the process
767that has been started. If this process should survive, you have to use
768abandonpipe.
769\\
770
771\thing{abandonpipe channel}{void}{expr}{Closes channel without killing
772the process started by pipe!-open. Returns {\tt nil}.}
773
774Example:
775\begin{verbatim}
776(load pipes)
777(setq chn (pipe!-open "uname"))
778(channelread chn)
779(close chn)
780\end{verbatim}
781
782\section{Mapping of LISP Addresses to C addresses}
783
784This paragraph applies for some architectures only, e.g.
785the {\tt IBM/RS, HP PA-Risc and MIPS} where the system architecture
786uses 'high' bits in the addresses which conflict with the
787PSL tagging mechanism.(See the paragraph on the Size of the
788Address space above).  The consequence of this is that using the
789inf operation
790for calculating the C equivalent from a LISP address does not
791work here. The easiest way (without explaining the reason)
792of mapping for the architectures is:
793
794\begin{tabular}{rl}
795	IBM/RS&(mkstr item) \\
796	HP PA-Risc&(mkvec item)\\
797	Mips&(wshift (inf item) 2)
798\end{tabular}
799
800On Convex systems the 'high' bit is the leftmost one. Therefore the
801tag bits start at bit 1 and the inf range is limited by 26 bits.
802The inf operation works as expected.
803
804\end{document}
805
806