[comp.os.minix] Various comments

ast@botter.UUCP (02/23/87)

In article <1276@husc6.UUCP> ddl@husc6.UUCP (Dan Lanciani) writes:
>
>	With all the discussion of how you can't use the PC BIOS because
>it can only handle one disk operation at a time, has anyone noticed that
>the MINIX file system process runs single-threaded for normal file requests?

This is true, but while the file system is waiting for a disk operation
to complete, another process can run.  For example, parts of the C compiler
work as a pipeline, so while one pass is blocked on the disk, another
pass can run.  Of course if the other pass also tries to do disk I/O it
will be suspended until the first operation is finished (although a third
process could run, if there was one).  I haven't thought at all about
multi-threading the file system.  This left as is an exercise for the reader.


The person who wrote the assembler-loader (asld) has fixed it to handle
separate I & D.  I am now in the process of testing it.  When I am
finished, I will post an encoded binary to this group, along with my version
of uuencode and uudecode.  Although I am not wild about binary postings in
general, the source of asld, being part of the compiler stuff, is not in
the standard MINIX distribution, and is only available from UniPress and
Transmediair.  When I post asld, I will also send copies to both companies
so that their compiler distributions will contain the new version from that
point on.

Lots of people are having trouble getting through to me and I am having
trouble replying to lots of people.  If you send me mail asking specific
questions and don't get a response within a week, chalk it up to the net.
My proper address in the domain naming system is: ast@cs.vu.nl
With source routing, use: ...!seismo!mcvax!vu44!ast
My phone number is (country code 31) (area code 20) 548 2975.
The dept. office phone number is 31 20 548 8080.  If you call this number
you will get Marja, Betty, Marijke, Anjo, or Edith, all of whom are nice
ladies who speak English and can take a message for me if need be.  Keep
in mind that Columbus was right and the earth is round and that this means
that the time in Amsterdam is not necessarily the same as your local time.
A short international call is preferable to using the net to send me mail
since (1) thousands of people will have to read something they are not
interested in, and (2) broadcasting the mail worldwide costs a lot of money.

P-H tells me that the diskettes will be going out the door starting March 6.
Sorry for the delay, but the amount of interest in MINIX caught everyone by
surprise.  It took them a while to get the production geared up.

Andy Tanenbaum 

ast@cs.vu.nl (Andy Tanenbaum) (01/01/90)

The file is lib.doc is junk.  Ditch it if you have it.

There is still only one library, libc.a, even though the sources were split
by popular demand.  The reason for splitting the sources is that ls didn't
work any more in lib.

If you have installed all the headers correctly, ctime and everything else
in the library should compile, although a couple of files give warnings.
Since the final word has not yet been said on stdio, I haven't worried about that
too much.  On a PC, everything is 16 bit anyway, but be careful on an Atari.

The xxx.s files in libc.a like sti.s were all originally written in assembler.
There is no source.  Use libupack to make them readable.

I may well be missing strcoll.c and a few other ANSI string routines.  I don't
even know what they do.  For the more exotic ones, I probably don't want to.

There have been several requests for the IBM assembler routines.  I believe
they are unchanged since 1.3.  In any event, here they are.  They go in
lib/ibm.

So far there have been remarkably few problems.  Probably because everybody
is away until after New Year's.  Stay tuned.

Happy 1990 everybody!

Andy Tanenbaum (ast@cs.vu.nl)

P.S. I just heard that another leap second has been added because the earth
has been rotating at the wrong rate.  I think this is the 15th one since 1970.
Unfortunately, both MINIX and UNIX think they can get the number of seconds
in a non-(leap year) by multiplying 365 * 24 * 60 * 60, which is incorrect.
The ancient Egyptians did this for all years, and it wasn't hacked until
Julius Caesar decided he didn't like January falling in the early Autumn.
THUS: PLEASE DO NOT USE MINIX TO CALCULATE THE START OF THE ANNUAL NILE FLOODS.

: This is a shar archive.  Extract with sh, not csh.
: This archive ends with exit, so do not worry about trailing junk.
: --------------------------- cut here --------------------------
PATH=/bin:/usr/bin:/usr/ucb
echo Extracting 'brksize.s'
sed 's/^X//' > 'brksize.s' << '+ END-OF-FILE ''brksize.s'
X.define _brksize
X.data
X.globl endbss, _brksize
X_brksize: .word endbss
+ END-OF-FILE brksize.s
chmod 'u=rw,g=r,o=r' 'brksize.s'
set `wc -c 'brksize.s'`
count=$1
case $count in
70)	:;;
*)	echo 'Bad character count in ''brksize.s' >&2
		echo 'Count should be 70' >&2
esac
echo Extracting 'catchsig.s'
sed 's/^X//' > 'catchsig.s' << '+ END-OF-FILE ''catchsig.s'
X.define _begsig
X.globl _begsig
X.globl _vectab, _M
Xmtype = 2			| M+mtype = &M.m_type
X_begsig:
X	push ax			| after interrupt, save all regs
X	push bx
X	push cx
X	push dx
X	push si
X	push di
X	push bp
X	push ds
X	push es
X	mov bx,sp
X	mov bx,18(bx)		| bx = signal number
X	mov ax,bx		| ax = signal number
X	dec bx			| vectab[0] is for sig 1
X	add bx,bx		| pointers are two bytes on 8088
X	mov bx,_vectab(bx)	| bx = address of routine to call
X	push _M+mtype		| push status of last system call
X	push ax			| func called with signal number as arg
X	call (bx)
Xback:
X	pop ax			| get signal number off stack
X	pop _M+mtype		| restore status of previous system call
X	pop es			| signal handling finished
X	pop ds
X	pop bp
X	pop di
X	pop si
X	pop dx
X	pop cx
X	pop bx
X	pop ax
X	pop dummy		| remove signal number from stack
X	iret
X
X.data 
Xdummy: .word 0
+ END-OF-FILE catchsig.s
chmod 'u=rw,g=r,o=r' 'catchsig.s'
set `wc -c 'catchsig.s'`
count=$1
case $count in
814)	:;;
*)	echo 'Bad character count in ''catchsig.s' >&2
		echo 'Count should be 814' >&2
esac
echo Extracting 'crtso.s'
sed 's/^X//' > 'crtso.s' << '+ END-OF-FILE ''crtso.s'
X| This is the C run-time start-off routine.  It's job is to take the
X| arguments as put on the stack by EXEC, and to parse them and set them up the
X| way _main expects them.
X
X.globl _main, _exit, crtso, _environ
X.globl begtext, begdata, begbss, endtext, enddata, endbss
X.text
Xbegtext:
Xcrtso:		mov	bx,sp
X		mov	cx,(bx)
X		add	bx,*2
X		mov	ax,cx
X		inc	ax
X		shl	ax,#1
X		add	ax,bx
X		mov	_environ,ax	| save envp in environ
X		push	ax	| push environ
X		push	bx	| push argv
X		push	cx	| push argc
X		call	_main
X		add	sp,*6
X		push	ax	| push exit status
X		call	_exit
X
X.data
Xbegdata:
X_environ:	.word 0
X.bss
Xbegbss:
+ END-OF-FILE crtso.s
chmod 'u=rw,g=r,o=r' 'crtso.s'
set `wc -c 'crtso.s'`
count=$1
case $count in
598)	:;;
*)	echo 'Bad character count in ''crtso.s' >&2
		echo 'Count should be 598' >&2
esac
echo Extracting 'end.s'
sed 's/^X//' > 'end.s' << '+ END-OF-FILE ''end.s'
X.globl endtext, enddata, endbss, _end, _edata
X.text
Xendtext:
X.data
Xenddata:
X_edata:
X.bss
Xendbss:
X_end:
+ END-OF-FILE end.s
chmod 'u=rw,g=r,o=r' 'end.s'
set `wc -c 'end.s'`
count=$1
case $count in
103)	:;;
*)	echo 'Bad character count in ''end.s' >&2
		echo 'Count should be 103' >&2
esac
echo Extracting 'getutil.s'
sed 's/^X//' > 'getutil.s' << '+ END-OF-FILE ''getutil.s'
X.define _get_base, _get_size, _get_tot_mem
X.globl _get_base, _get_size, _get_tot_mem
X.globl endbss
X
X|*========================================================================*
X|                           utilities                                     *
X|*========================================================================*
X_get_base:			| return click at which prog starts
X	mov ax,ds
X	ret
X
X_get_size:			| return prog size in bytes (text+data+bss)
X	mov ax,#endbss		| end is compiler label at end of bss
X	ret
X
X| Find out how much memory the machine has, including vectors, kernel MM, etc.
X_get_tot_mem:
X	cli
X	push es
X	push di
X	mov ax,#16384		| start search at 256K (16384 clicks)
X	sub di,di
XL1:	mov es,ax
X	seg es
X	mov (di),#0xA5A4	| write random bit pattern to memory
X	xor bx,bx
X	seg es
X	mov bx,(di)		| read back pattern just written
X	cmp bx,#0xA5A4		| compare with expected value
X	jne L2			| if different, no memory present
X	add ax,#4096		| advance counter by 64K
X	cmp ax,#0xA000		| stop seaching at 640K
X	jne L1
XL2:	pop di
X	pop es
X	sti
X	ret
+ END-OF-FILE getutil.s
chmod 'u=rw,g=r,o=r' 'getutil.s'
set `wc -c 'getutil.s'`
count=$1
case $count in
1045)	:;;
*)	echo 'Bad character count in ''getutil.s' >&2
		echo 'Count should be 1045' >&2
esac
echo Extracting 'head.s'
sed 's/^X//' > 'head.s' << '+ END-OF-FILE ''head.s'
X.globl _main, _stackpt, begtext, begdata, begbss, _data_org, _exit, .fat, .trp
X.text
Xbegtext:
X	jmp L0
X	.zerow 13		| stack for inital IRET when common I&D
X				| also padding to make INIT_SP same as
X				| for separate I&D
XL0:	mov sp,_stackpt
X	call _main
X_exit:				| dummy for library functions - never executed
X.fat:				| dummy
X.trp:				| dummy
XL1:	jmp L1			| this should never be executed either
X.data
Xbegdata:
X_data_org:			| fs needs to know where build stuffed table
X.word 0xDADA			| magic number for build
X.word 8				| CLICK_SHIFT to check - must match h/const.h
X.word 0,0,0			| used by FS only for sizes of init
X				| stack for separate I&D follows
X.word 0,0,0			| for ip:ss:f pushed by debugger traps
X.word 0,0,0			| for cs:ds:ret adr in save()
X				| this was missing - a bug as late as V1.3c
X				| for ds for new restart() as well
X.word 0,0,0			| for ip:ss:f built by restart()
X				| so INIT_SP in const.h must be 0x1C
X.bss
Xbegbss:
+ END-OF-FILE head.s
chmod 'u=rw,g=r,o=r' 'head.s'
set `wc -c 'head.s'`
count=$1
case $count in
937)	:;;
*)	echo 'Bad character count in ''head.s' >&2
		echo 'Count should be 937' >&2
esac
echo Extracting 'prtso.s'
sed 's/^X//' > 'prtso.s' << '+ END-OF-FILE ''prtso.s'
X| Pascal Run Time Start Off routine (analogous to crtso.s for C programs)
X| This routine is used only with the MINIX Pascal compiler.
X
X.globl _m_a_i_n, _exit, prtso, _environ
X.globl begtext, begdata, begbss
X.globl hol0
X.text
Xbegtext:
Xprtso:
Xmov bx,sp
Xmov cx,(bx)
Xadd bx,*2
Xmov ax,cx
Xinc ax
Xshl ax,#1
Xadd ax,bx
Xmov _environ,ax 
Xpush ax 
Xpush bx 
Xpush cx 
Xcall _m_a_i_n
Xadd sp,*6
Xpush ax 
Xcall _exit
X
X.data
Xbegdata:
X_environ: .word 0
Xhol0:
X.word  0,0
X.word  0,0
X
X.bss
Xbegbss:
+ END-OF-FILE prtso.s
chmod 'u=rw,g=r,o=r' 'prtso.s'
set `wc -c 'prtso.s'`
count=$1
case $count in
474)	:;;
*)	echo 'Bad character count in ''prtso.s' >&2
		echo 'Count should be 474' >&2
esac
echo Extracting 'sendrec.s'
sed 's/^X//' > 'sendrec.s' << '+ END-OF-FILE ''sendrec.s'
X.define _send, _receive, _sendrec
X
X| See ../h/com.h for C definitions
XSEND = 1
XRECEIVE = 2
XBOTH = 3
XSYSVEC = 32
X
X|*========================================================================*
X|                           send and receive                              *
X|*========================================================================*
X| send(), receive(), sendrec() all save bp, but destroy ax, bx, and cx.
X.globl _send, _receive, _sendrec
X_send:	mov cx,*SEND		| send(dest, ptr)
X	jmp L0
X
X_receive:
X	mov cx,*RECEIVE		| receive(src, ptr)
X	jmp L0
X
X_sendrec:
X	mov cx,*BOTH		| sendrec(srcdest, ptr)
X	jmp L0
X
X  L0:	push bp			| save bp
X	mov bp,sp		| can't index off sp
X	mov ax,4(bp)		| ax = dest-src
X	mov bx,6(bp)		| bx = message pointer
X	int SYSVEC		| trap to the kernel
X	pop bp			| restore bp
X	ret			| return
X
+ END-OF-FILE sendrec.s
chmod 'u=rw,g=r,o=r' 'sendrec.s'
set `wc -c 'sendrec.s'`
count=$1
case $count in
811)	:;;
*)	echo 'Bad character count in ''sendrec.s' >&2
		echo 'Count should be 811' >&2
esac
echo Extracting 'setjmp.s'
sed 's/^X//' > 'setjmp.s' << '+ END-OF-FILE ''setjmp.s'
X.define _setjmp,_longjmp
X.globl _setjmp, _longjmp
X.text
X_setjmp:	mov	bx,sp
X		mov	ax,(bx)
X		mov	bx,*2(bx)
X		mov	(bx),bp
X		mov	*2(bx),sp
X		mov	*4(bx),ax
X		xor	ax,ax
X		ret
X
X_longjmp:	xor	ax,ax
X		push	bp
X		mov	bp,sp
X		mov	bx,*4(bp)
X		mov	ax,*6(bp)
X		or	ax,ax
X		jne	L1
X		inc	ax
XL1:		mov	cx,(bx)
XL2:		cmp	cx,*0(bp)
X		je	L3
X		mov	bp,*0(bp)
X		or	bp,bp
X		jne	L2
X		hlt
XL3:
X		mov	bp,*0(bp)
X		mov	sp,*2(bx)
X		mov	cx,*4(bx)
X		mov	bx,sp
X		mov	(bx),cx
X		ret
X
X
+ END-OF-FILE setjmp.s
chmod 'u=rw,g=r,o=r' 'setjmp.s'
set `wc -c 'setjmp.s'`
count=$1
case $count in
445)	:;;
*)	echo 'Bad character count in ''setjmp.s' >&2
		echo 'Count should be 445' >&2
esac
exit 0