Newsgroups: comp.os.minix
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!news.UVic.CA!sol.UVic.CA!pmacdona
From: pmacdona@sol.uvic.ca (Peter MacDonald)
Subject: IDE fix for wini.c problem
Message-ID: <1991Mar27.080437.6998@sol.UVic.CA>
Sender: pmacdona@sol.UVic.CA (Peter MacDonald)
Organization: University of Victoria, Victoria B.C. CANADA
Date: Wed, 27 Mar 91 08:04:37 GMT

The following problem (or variations thereof) has been posted by
a number of people over the last few months.  The problem manifests
itself as unexpected interrupts during disk reads in protected mode, 
causing the 386 to hang, usually with the drive light stuck on.  
In my case, I can invariably induce this condition by running 
fsck /dev/hd2.

I have been wrestling with this problem since last October and think
I finally have a (kludgy) fix.  After all this time, elegance has 
ceased to be an issue.

After reading an article about IDE drives in the Mar 90 issue of byte
(Under The Hood) about how some IDE drives can't keep up with the 
command streams when doing loads of reads in protected mode,
I began to suspect that minix was doing just that to my IDE.  
Therefore, inserting an artificial delay before reading each sector, 
should slow down the entire stream.  Add to w_transfer in wini.c
the lines preceeded with a plus (+):

   if (wn->wn_opcode == DISK_READ) {
     for (i=0; i<BLOCK_SIZE/SECTOR_SIZE; i++) {
  +    int j,k;
  +    for (j=0;j<300;j++)
  +      k=k*3+j;


End of problem.  (Actually I haven't exhastively tested the results,
but rather ran fsck several dozen times both sequentially and
in two different consoles concurrently.)

For those interested, I ran some variations on the upper bound of
j and measured the results with time on fsck.  These results which
are summerized below, indicate that further reductions in this upper
bound has diminishing returns.


j(wini)          time
----------------------------------------
BIOS     real:49  user:2.5   system:46.7
3000     real:48  user:1.7   system:7.8
300      real:41  user:1.9   system:2.3
30       real:41  user:1.6   system:1.8     # Machine locked up later.


