The ModulaTor logo 7KB

The ModulaTor

Oberon-2 and Modula-2 Technical Publication

The ModulaTor
Erlangen's First Independent Modula_2 Journal! Nr. 1/Feb-1992 
_____________________________________________________________

TDir: Lists a directory organized by file types 

by Guenter Dotzel, ModulaWare  

This utility accepts a wildcard directory/file specification via the so-called foreign 
command interface, looks up the directory and reads the file names that match the 
wildcard specification, sorts them with the file type as primary key and with original order 
as secondary key. The listing is produced on the logical device SYS$OUTPUT (by 
importing module Terminal), hence the output device can be redirected to a file (tdir.lis) 
by the command 

$ define sys$output tdir.lis 

The utility is only partly VMS-specific. It uses three system dependent procedures 

1. LIB$GET_FOREIGN to get the program argument 

2. LIB$FIND_FILE to get the name of the first file that matches the wildcard specification 
of the first parameter. The first call also sets a so-called context. This context is used in 
all subsequent calls to get the rest of the files. 

3. LIB$FIND_FILE_END releases the context. 

The directory and file name syntax is also VMS-specific. VMS has the delimiters ";" for 
the version, "." for the file type, "]" for the file name (only when scanned from right to left). 

These operating system dependencies could easily be adapted when porting TDir to 
another system. The only challenging problem could be the functionality of the find-file 
routine, since VMS allows wildcards in the directory name too. 

I've rewritten TDir from VAX-Pascal to Modula-2 and made only one extension: If the 
directory specification contains a wildcard, the directory name is listed each time the 
directory changes within the same file type. Since the original directory order is not 
changed, the files are listed alphabetically grouped by directory (see example below). 

The auxiliary procedures index, substr, Length, equalstr and lesstr were introduced to 
since Modula-2 doesn't have build-in string-functions. Note, that these procedures are 
designed to work only with this program and not fully compatible with their VAX-Pascal 
equivalent. 

Installation:  
  Compile:                      $  mod/nocheck tdir 
  Link:                         $  link/notraceback  tdir
  Install as a foreign command: $  tdir:== $$disk1:[subdir]tdir 
Calling examples:
  There is one optional parameter, a (partial) file specification, with wild cards all
owed. 
  The default is *.*;* 
    $ tdir x.*
    $ tdir [altdir]
    $ tdir [a*]
    $ tdir [a*...]
  For instance, if you want to see only the most recent version of each file, use

    $ tdir ;

Example (assume there is no other directory name with the first character being "A" and 

Directory [AA] contains the files A.DEF;1, A.SYM;1, B.DEF;1, B.SYM;1 

Directory [AB] contains the files A.DEF;1, A.SYM;1, B.DEF;1, B.SYM;1): 

  $ tdir [a*]

  .DEF
    A;1 ---> [AA]
    B;1
    A;1 ---> [AB]
    B;1
  .SYM
    A;1 ---> [AA]
    B;1
    A;1 ---> [AB]
    B;1

Acknowledgement: The original Pascal version was developed by James W. Walker, 
Department of Mathematics, University of South Carolina, Columbia, SC 29208, BITnet 
N410109@univscvm, CompuServe 76367,2271, 1-Jul-1989. 

__________________________________________________________________________________________________ 

MODULE tdir;
(*

*)
FROM SYSTEM IMPORT NOP;
IMPORT Terminal, ASCII;
FROM CommonInputOutputProcedures IMPORT
  LIB$GET_FOREIGN, LIB$FIND_FILE, LIB$FIND_FILE_END;
FROM ConditionHandlingProcedures IMPORT LIB$STOP;

CONST max_files = 20000;
  RMS$_NORMAL = 65537;

TYPE file_index = [1..max_files];
  filespec_string = ARRAY [1..255] OF CHAR;
  filepart_string = ARRAY [1..40] OF CHAR;
  filevers_string = ARRAY [1..6] OF CHAR;

VAR search_spec, result_spec: filespec_string;
  current_line, context: INTEGER;
  name_string, type_string, dir_string, 
    current_dir,current_type: filepart_string;
  vers_string: filevers_string;
  spec_place, begin_place, end_place: INTEGER;
  current_file, i, t, c, L, U: file_index;
  p: ARRAY file_index  OF file_index; (*permutation of indices*)
  status: INTEGER;
  num_files: CARDINAL; (*[0..max_files]*)
  files: ARRAY file_index OF
    RECORD
      nam, typ, dir: filepart_string;
      ver: filevers_string
    END;

PROCEDURE index(VAR s: ARRAY OF CHAR; ch: CHAR): CARDINAL;
VAR i: INTEGER;
BEGIN
  FOR i:=0 TO HIGH(s) DO
    IF ch=s[i] THEN RETURN i+1
    END;
  END;
  RETURN 0
END index;

CONST StringTerm=ASCII.NUL;
PROCEDURE substr(VAR out: ARRAY OF CHAR; inp: ARRAY OF CHAR; 
  from,len: INTEGER);
VAR i: INTEGER;
BEGIN
  IF (from>0) & (len>0) & (from-1+len <= HIGH(inp)) & (len-1 <= HIGH(out)) THEN
    DEC(from);
    FOR i:=from TO from+len-1 DO 
      out[i-from]:=inp[i];
    END;
    FOR i:=len TO VAL(INTEGER, HIGH(out)) DO out[i]:=StringTerm;
    END;
  ELSE (* error *)
    IF len#0 THEN FOR i:=0 TO HIGH(out) DO out[i]:="*" END; END;
  END;
END substr;

PROCEDURE lessstr(VAR one, two: ARRAY OF CHAR): BOOLEAN;
VAR i: INTEGER;
BEGIN
  FOR i:=0 TO VAL(INTEGER,HIGH(one)) DO
    IF one[i]<two[i] THEN RETURN TRUE 
    ELSIF one[i]>two[i] THEN RETURN FALSE
    END;
  END;
  RETURN FALSE;
END lessstr;

PROCEDURE equalstr(VAR one, two: ARRAY OF CHAR): BOOLEAN;
VAR i: INTEGER;
BEGIN
  FOR i:=0 TO VAL(INTEGER,HIGH(one)) DO
    IF one[i]#two[i] THEN RETURN FALSE END;
  END;
  RETURN TRUE;
END equalstr;

PROCEDURE Length(VAR s: ARRAY OF CHAR): INTEGER;
VAR i: INTEGER;
BEGIN
  FOR i:=HIGH(s) TO 0 BY -1 DO
    IF NOT((s[i]=' ') OR (s[i]=StringTerm)) THEN RETURN i+1;
    END;
  END;
  RETURN 0
END Length;

PROCEDURE siftdown (* (L,U: INTEGER) *); (*files[p[L]] sifts down*)
  (* Precondition: Heap(L+1,U)
     Postcondition: Heap(L,U),
      i.e., files[p[i div 2]].typ >= files[p[i]].typ for all i such that 2L <= i <= U 
  *)
BEGIN
  i:= L;
  t:= p[i]; (* files[t] sifts down *)
  LOOP (* Invariant: Heap(L,U) except perhaps between i and its children *)
    c:= 2*i; (* index of first child *)
    IF c > U THEN EXIT (* no children *)
    END;
    IF c+1 <= U THEN (* two children; make c index the bigger one *)
      IF lessstr(files[p[c]].typ, files[p[c+1]].typ) THEN c:= c+1
      ELSIF equalstr(files[p[c]].typ, files[p[c+1]].typ) THEN
        IF (p[c] < p[c+1]) THEN c:=c+1;
        END;
      END;
    END;
    IF lessstr(files[p[c]].typ, files[t].typ) THEN EXIT
    END;
    IF equalstr(files[p[c]].typ, files[t].typ) AND (p[c] < t) THEN EXIT
    END;
    (* Exchange the moving node with its bigger child. *)
    p[i]:= p[c]; (* the child moves up *)
    i:= c;
  END;
  p[i]:= t;
END siftdown;

VAR list_dir: BOOLEAN;
BEGIN
  status:=LIB$GET_FOREIGN(search_spec, NOP,NOP,NOP); (* get program argument *)
  IF search_spec[1] = StringTerm THEN search_spec[1] := '*'; 
    search_spec[2] := 0C;
  END;
  list_dir := search_spec[1]= "[";

  (* Split files into name, type, version, and put into "files" array. *)
  context:= 0; num_files:= 0;   
  status:= LIB$FIND_FILE( search_spec, result_spec, context, '*.*;*', NOP,NOP,NOP);
  IF status <> RMS$_NORMAL THEN LIB$STOP( status );
  END;
  WHILE (context <> 0) AND (index(result_spec,'*') = 0) DO
    num_files:= num_files + 1;
    IF num_files > max_files THEN
      Terminal.WriteString("Oops-- too many files for tdir's array!"); Terminal.WriteLn;
      RETURN;
    END;
    (* Find the last right bracket; that will be followed by the file name.  
       (Under some circumstances, there could be more  than one right bracket.)
    *)
    spec_place:= Length( result_spec );
    WHILE result_spec[spec_place] <> ']' DO
      spec_place:= spec_place - 1;
    END;
    substr( files[num_files].dir, result_spec, 1, spec_place);
    substr( result_spec, result_spec, spec_place + 1, Length(result_spec) - spec_place );
    end_place:= index( result_spec, '.' );
    substr( files[num_files].nam,  result_spec, 1, end_place - 1 );
    begin_place:= end_place + 1;
    end_place:= index( result_spec, ';' );
    substr( files[num_files].typ, result_spec, begin_place, end_place - begin_place );
    begin_place:= end_place + 1;
    substr( files[num_files].ver, result_spec, begin_place, Length(result_spec) - begin_place + 1 );
    p[num_files]:= num_files;
    status:=LIB$FIND_FILE( search_spec, result_spec, context, '*.*;*', NOP,NOP,NOP);
  END;
  status:=LIB$FIND_FILE_END( context );

  (* Sort files according to type, using heapsort.
     Heapsort is not a stable sort, meaning that if we compared files 
     solely by type, THEN files of the same type would not stay in
     their original order. Therefore we use the p array for secondary keys.
  *)
  U:= num_files;
  FOR L:= num_files DIV 2 TO 1 BY -1 DO     (* heapify *)
    siftdown (*(L,num_files)*);
  END;
  L:= 1;
  U:= num_files;
  WHILE U >= 2 DO
    (* Loop invariant: Heap(1,U), sorted(U+1,num_files), and everything in the 
       former group is less than everything in the latter group. 
    *)
    t:= p[1];       (*swap p[1] and p[U] *)
    p[1]:= p[U];
    p[U]:= t;
    U:= U - 1;
    siftdown (*(1,U)*)
  END;

  (* Type output. 5 columns. *)
  current_type[1]:= '?';  
  current_dir [1]:= '?';  
  FOR current_file:= 1 TO num_files DO
    name_string:= files[p[current_file]].nam;
    type_string:= files[p[current_file]].typ;
    vers_string:= files[p[current_file]].ver;
    dir_string := files[p[current_file]].dir;
    IF NOT equalstr(type_string, current_type) THEN
      Terminal.WriteString('.');Terminal.WriteString(type_string); Terminal.WriteLn;
      current_type:= type_string;
    END;
    Terminal.WriteString('   '); Terminal.WriteString(name_string);
    Terminal.WriteString(';'); Terminal.WriteString(vers_string);
    IF list_dir & NOT equalstr(dir_string, current_dir) THEN
      Terminal.WriteString (" ---> "); Terminal.WriteString(dir_string);
      current_dir:= dir_string;
    END;
    Terminal.WriteLn;
  END;
END tdir.

__________________________________________________________________________________________________ 

Letters to the Editor 

__________________________________________________________________________________________________ 

To:        g_dotzel@ame.nbg.sub.org
Organization: MAI
From:        Egorov Igor Ivanovich <egor@air.mai.msk.su>
Date:        Mon, 2 Dec 1991 21:54:15 +0100

Dear Guenter, 

Thank you for your valuable info. Now, a few words about our research group. 

Our group was founded not long ago at Moscow Aviation Institute (Department of Aircraft 
Engines). The primary aim of activity is the research of sophisticated computer systems 
and software technologies. 

A full name of our group is "Advanced Interaction Research" (AIR). At present, the 
following directions of group activity are formed. 

1. Study of advanced software technologies and sophisticated computer systems. 

2. Design of the new software technologies and implementation of the relative 
instrumental tools oriented to development of the multi-process parallel applications. 

3. Development of sophisticated applications by the new software technologies. 

At the moment, the activities related with an implementation of the Lotos Development 
System are in progress. Lotos is the latin abbreviation of the associated russian words 
that means Logic of Operations and Technology for System Organisation. The Lotos 
Project was started about four years ago. 

The characteristic features of this technology is:  

r asynchronous behaviour of application systems components;  

m decomposition all components to 2 non-intersecting class: active components 
 (processes) and passive ones (intermediate data areas - IDA);  

m description of logic of process interaction into IDA by Petri Nets;  

m "guard of resource" notion as an ownership of process;  

m exception handling for parallel processes and its guards;  

m using Petri Net formalism for prototyping stage of application development.  

We selected PC XT/AT (DOS) as instrumental computers; LSI-11/PDP-11 and PC XT/AT 
as target computers. Further we suppose to use VAXstation and DECstation computers, 
and also various transputer systems. 

At present, the Lotos run-time library for RT11 and for DOS are implemented. Moreover, 
we have developed a general-purpose module library, that is Lotos-oriented and 
completely independent from the specific set of libraries that normally accompany a 
Modula-2 compiler. This library include the following facilities (some of ones support an 
object-oriented style):  

r exception handling;  

m storage manager;  

m dynamically linking loader;  

m virtual cache memory (base+EMS+disk);  

m address arithmetic;  

m file system;  

m handling of data base files, Clarion-compatible;  

m DOS interface;  

m mouse, keyboard, speaker;  

m generic sorting and searching;  

m abstract data structures (AVL-tree, B-tree);  

m symbol tables;  

m strings and format conversions;  

m support of many video-modes;  

m text and graphic window system (X-Window like);  

m support of some printers (Epson FX/LQ, LaserJet II/III, Howtek Pixelmaster).  

Applications of the Lotos technology and associated toolkit are development of real-time 
and graphic applications. Now, we are designing the Lotos kernel for multi-computer 
(LAN) and multi-processor systems. 

We are glad to collaborate with any programmer and programming group facing 
analogous problems. 

Sincerely, Igor
 

                    ###  ##  #####    ===============
                  ## ##  ##  ##   ##  ============
                ##   ##  ##  ##   ##  ========
                #######  ##  #####    ======
                ##   ##  ##  ##   ##  ===

                e-mail        : egor@air.mai.msk.su
                organisation  : Moscow Aviation Institute, Moscow, Russia
                phone (voice) : (7)-(095)-158-4969

__________________________________________________________________________________________________ 

Random News

From:        kris graham <graham@fuel.nyo.dec.com>
Newsgroups: comp.arch
Subject: Re: DEC Alpha Risc chip: ISSCC paper abstract
Date:        Wed, 18 Dec 1991 17:48:34 +0100
Organization: Digital Equipment Corporation
Apparently-To: g_dotzel@ame.nbg.sub.org

This is public now...so...some tit bits: 

UNIGRAM-X ROUNDTABLE PRESS 

DEC DETAILS NEXT 25 YEARS - ALPHA FROM LAPTOP TO SUPER 

On a crisp clear day in New England last week, Digital Equipment Corporation began 
detailing for public consumption its plans for world domination. DEC expects Alpha to 
buy it the number one slot in Unix performance. But Alpha is also VAX's eventual 
successor, obviously making it of overweening importance to the company's future. That 
future starts sometime next year, probably the summer, when the first three Alpha boxes 
appear, paving the way for successive generations of 64-bit machines that DEC 
contemplates will take twenty-four months to launch. 

DEC considers Alpha's architecture will take it through the next twenty-five years, 
scalable to all species of machine from the palmtop to supercomputer. The scale of the 
project must put the depth of DEC's commitment to the MIPS architecture into some 
questian, despite ACE and the new machines (see below\207. Commenting, \207PS' John 
Mashey said he expected the Alpha chip to be "fast, but expensive" for the first few 
years. 

CRAY-LIKE ALPHA CHIP HAS THE LEAD OVER VIKING AND IBM's POWER 

Alpha co-architect Dick Sties, seconded to the project in the fall of 1988, described Alpha 
as most closely resembling a Cray 1, comparing Alpha's 150 instructions to Cray's 128. It 
uses a full 64-bit architecture, he said, with a flat nonsegmented 64- bit address and 
64-bit registers, integers and floats. It was built to handle multiple computer languages 
and multiple operating systems. It was also built to be either a single processor or a 
massively parallel system of 400 or 500 processors. 

Apparently they have the thing up and running at 200MHz with a S-nanosecond clock 
cycle, a spec DEC president Ken Olsen quoted at the recent stockholders meeting. Not 
wanting to steal the boss's thunder, that's as much as the DEC engineers would say last 
week, leaving the distinct impression, however, that this was a minimal statistic. Sites 
claimed performance can scale by a factor of a thousand times, a modest boast, he said, 
"it could be 10,000 times." So far the company has produced some 50 Alpha machine 
and is currently using production quantity chips, its first proprietary RISC design based 
on CMOS superscalar technology. 

Alpha is a single-chip implementation and DEC's apparent success fabricating it seems 
to give it a heady lead over challengers such as the finicky Sun Viking and non-existent 
IBM PowerPC. The Alpha VMS port is going better than they expected. Originally 
forecast to be a year behind the hardware, it's now pretty much current with it. Ninety 
percent of the code is already over and running on production hardware, according to 
development manager Kathy Morse. Its eye on the installed VAX base, DEC hotly 
underscores the fact that Alpha's VMS is VMS, not rewritten in C or redesigned, just VMS 
V5.4 on an Alpha platform. 

Resources outside the company such as an Israeli firm staffed with Russian scientists 
and universities have been brought in for regression testing. As previously reported, 
VMS-on-Alpha is for DEC's higher end machines. Lower end high-performance Alphas 
will run a 64-bit version of OSF/l which consolidates Ultrix, System V and OSF streams 
(UX No 361, 360). DEC's cost-conscious OSF/l-on- MlPS machines, announced this 
week, will be its entry level. - Maureen O'Gara 

DEC people said again last week that they are not going to try to elbow into the ACE 
Initiative packing Alpha and portable VMS as still another ACE alternative (UX No 355): 
They are however apparently using the ACE members roster as a hit list of likely Alpha 
hardware/software licensees under a program that DEC, hungry for multiple Alpha 
vendors, will institute next year (UX No 359). Seems they're already talking to some. 

DEC wants to put SCO's Open Desktop for ACE on its Alpha boxes but doesn't know yet 
whether it would be a layered product or part of the actual operating system. It also 
doesn't know yet exactly what ODT for ACE will be: The desktop manager issue for 
instance is still unresolved as the powers that be try to sort out a winner. 

It became apparent last week why ACE is so important to DEC: It hopes the Initiative will 
attract a considerable ISV following. It will then move that software over to Alpha both in 
its OSF/l and VMS species. He who has the most software wins. 

Last year, as a feasibility study, DEC ported a 64-bit BSD to Alpha learning in the 
process, it said, that Unix migration wasn't that complex: That paved the way for the 
64-bit version of OSF/l they are currently moving over (UX No 361). Earlier this month 
they got as far as a user login on a real Alpha system. 

Although VMS-on Alpha somehow started getting called "portable VMS" apparently it 
ain't: DEC last week said the microcode was not in a higher level language and therefore 
lacked the flexibility to slip easily on to another platform. 

DEC has apparently filed some 20 hardware and software patents on Alpha. 

Still no definitive word that NT will be ported to Alpha, only the conclusion of Alpha's 
newly appointed business manager Peter Graham that such a move would be "logical." 

Christopher Graham          
Digital Equipment Corp            
Open Systems Resource Center                                           
  
New York City

Internet: graham@fuel.enet.dec.com 
UUCP:     ...!decwrl!fuel.enet.dec.com!graham

IMPRESSUM: The ModulaTor is an unrefereed journal. Technical papers are to be taken as working papers and personal rather than organizational statements. Items are printed at the discretion of the Editor based upon his judgement on the interest and relevancy to the readership. Letters, announcements, and other items of professional interest are selected on the same basis. Office of publication: The Editor of The ModulaTor is Guenter Dotzel; he can be reached by tel/fax: [removed due to abuse] or by mailto:[email deleted due to spam]
  ModulaWare home page   The ModulaTor download    [Any browser]

Webdesign by www.otolo.com/webworx, 14-Jul-1998