CS444 Discussion of hw3 Solution

 

::::::::::::::

uprog1.c

::::::::::::::

#include "tunistd.h"

#include "tty_public.h"

 

#define MILLION 1000000

#define DELAY (400 * MILLION)

 

int main1()

{

  int i;

 

  write(TTY1,"aaaaaaaaaa",10);

  write(TTY1, "zzz", 3);   /* was fprintf in hw3 */

  for (i=0;i<DELAY;i++) /* enough time to drain output q */

    ;

  write(TTY1,"AAAAAAAAAA",10);  /* see it start output again */

  return 2;

}

::::::::::::::

uprog2.c

::::::::::::::

#include <stdio.h>

#include "tunistd.h"

#include "tty_public.h"

 

int main2(void);

 

int main2()

{

  write(TTY1,"bbbbbbbbbb",10);

  return 4;

}

::::::::::::::

uprog3.c

::::::::::::::

#include <stdio.h>

#include "tunistd.h"

#include "tty_public.h"

 

int main3(void);

 

int main3()

{

  write(TTY1,"cccccccccc",10);

  return 6;

}

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

C:\cs\cs444\hw3>more tunix.script
Script started on Sun Nov 12 12:42:12 2006
warning: could not update utmp entry

u17(1)%
u17(1)% mtip -f tunix.lnx -b 10
For command help, type ~?
For help on args, rerun without args
Code starts at 0x100100
Using board # 10

Tutor> ~downloading tunix.lnx
...........Done.

Download done, setting EIP to 100100.
Tutor> go 100100
aaaaaaaaaazzzAAAAAAAAAAbbbbbbbbbbccccSHUTTING DOWN
cccccc
EXIT CODE OF PROCESS 1: 2

EXIT CODE OF PROCESS 2: 4

EXIT CODE OF PROCESS 3: 6
SHUTTING THE SYSTEM DOWN!
Debug log from run:
Marking kernel events as follows:
  ^a   COM2 input interrupt, a received
  ~a   COM2 output interrupt, a output
  ~e   COM2 output interrupt, echo output
  ~S   COM2 output interrupt, shutdown TX ints
  |(1z-2) process switch from 1, now a zombie, to 2
  |(1b-2) process switch from 1, now blocked, to 2
  |(0-1) process switch from 0 to 1
-----------------DEBUGLOG-------------------------------------
|(0-1)|(1b-2)|(2b-3)|(3b-0)~a|(0-1)|(1b-2)|(2b-3)|(3b-0)~a|(0-1)|(1b-2)|(2b-3)|(3b-0)~a|(0-1)|(1b-2)|(2b-3)|(3b-0)~a|(0-
1)|(1b-2)|(2b-3)|(3b-0)~a|(0-1)|(1b-2)|(2b-3)|(3b-0)~a|(0-1)|(1b-2)|(2b-3)|(3b-0)~a|(0-1)~a~a~a~z~z~z~S~A|(1b-2)|(2b-3)|
(3b-0)~A|(0-1)|(1b-2)|(2b-3)|(3b-0)~A|(0-1)|(1b-2)|(2b-3)|(3b-0)~A|(0-1)|(1z-2)|(2b-3)|(3b-0)~A|(0-2)|(2b-3)|(3b-0)~A|(0
-2)|(2b-3)|(3b-0)~A|(0-2)|(2b-3)|(3b-0)~A|(0-2)|(2b-3)|(3b-0)~A|(0-2)|(2b-3)|(3b-0)~A|(0-2)|(2b-3)|(3b-0)~b|(0-2)|(2b-3)
|(3b-0)~b|(0-2)|(2b-3)|(3b-0)~b|(0-2)|(2b-3)|(3b-0)~b|(0-2)|(2z-3)|(3b-0)~b|(0-3)|(3b-0)~b|(0-3)|(3b-0)~b|(0-3)|(3b-0)~b
|(0-3)|(3b-0)~b|(0-3)|(3b-0)~b|(0-3)|(3b-0)~c|(0-3)|(3b-0)~c|(0-3)|(3b-0)~c|(0-3)|(3b-0)~c|(0-3)|(3z-0)~c~c~c~c~c~c~S
--------------------------------------------------------------

LEAVE KERNEL!

Exception 3 at EIP=0010010b: Breakpoint
Tutor> ~q
Quit handler:
killing process 10327 Leaving board #10
u17(2)% exit
script done on Sun Nov 12 12:42:59 2006

DEBUGLOG analysis:

|(0-1)|(1b-2)|(2b-3)|(3b-0)   This shows 3 processes blocking on output, process 0 runs...
~a|(0-1)  a finally output, all processes waked up, process 1 is chosen to run
|(1b-2)|(2b-3)|(3b-0)    all blocked again...
~a|(0-1)
|(1b-2)|(2b-3)|(3b-0)
~a|(0-1)
|(1b-2)|(2b-3)|(3b-0)
~a|(0-1)
|(1b-2)|(2b-3)|(3b-0)
~a|(0-1)
|(1b-2)|(2b-3)|(3b-0)
~a|(0-1)
|(1b-2)|(2b-3)|(3b-0)
~a|(0-1)
start delay loop in uprog1      process 1 running a long time here (no preemption possible)
~a~a~a~z~z~z~S  drain output Q, shut down ints, all processes have status RUN
~A|(1b-2)|(2b-3)|(3b-0)             A output, more A's enqueued, process 1 finally blocked
~A|(0-1)
|(1b-2)|(2b-3)|(3b-0)
~A|(0-1)
|(1b-2)|(2b-3)|(3b-0)
~A|(0-1)
|(1z-2)    process 1 finishes
|(2b-3)|(3b-0)   blocking like before, but only 2 processes now
~A|(0-2)
|(2b-3)|(3b-0)
~A|(0-2)
|(2b-3)|(3b-0)
~A|(0-2)
|(2b-3)|(3b-0)
~A|(0-2)
|(2b-3)|(3b-0)
~A|(0-2)
|(2b-3)|(3b-0)
~A|(0-2)
|(2b-3)|(3b-0)
~b|(0-2)
|(2b-3)|(3b-0)
~b|(0-2)
|(2b-3)|(3b-0)
~b|(0-2)
|(2b-3)|(3b-0)
~b|(0-2)
|(2z-3)  process 2 exits
|(3b-0)
~b|(0-3) ... more in file