CS444 HW4 Preemption: optional to implement it, but need to understand it!

uprog[123].c, running on hw4 provided files

 

GO 100100

*aaaaaa**********cccccccc*ccaaaazz*z*********AAA*AAAAAAAbb*bbSHUTTING DOWN

*bbbbbb*

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|(0-1)|(1b-2)|(2b-3)~a~a~a~a~a~a~S*3*3*3*3*3*3*3*3*3*3~c|(3b-1)|(1b-2)|(2b-0)~

c|(0-3)|(3b-1)|(1b-2)|(2b-0)~c|(0-3)|(3b-1)|(1b-2)|(2b-0)~c|(0-3)|(3z-1)|(1b-2)|

(2b-0)~c|(0-1)|(1b-2)|(2b-0)~c|(0-1)|(1b-2)|(2b-0)~c|(0-1)|(1b-2)|(2b-0)~c|(0-1)

*1|(1b-2)|(2b-0)~c|(0-1)|(1b-2)|(2b-0)~c|(0-1)|(1b-2)|(2b-0)~a|(0-1)~a~a~a~z~z*1

~z~S*1*1*1*1*1*1*1*1*1~A|(1b-2)|(2b-0)~A|(0-1)|(1b-2)|(2b-0)~A|(0-1)|(1b-2)|(2b-

0)*0~A|(0-1)|(1z-2)|(2b-0)~A|(0-2)|(2b-0)~A|(0-2)|(2b-0)~A|(0-2)|(2b-0)~A|(0-2)|

(2b-0)~A|(0-2)|(2b-0)~A|(0-2)|(2b-0)~b|(0-2)|(2b-0)~b|(0-2)|(2b-0)*0~b|(0-2)|(2b

-0)~b|(0-2)|(2z-0)*0~b~b~b~b~b~b~S*0*0*0*0*0

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

 

LEAVE KERNEL!

 

With preemption implemented—

GO 100100

system up

*aaaaaa****aaaazz****z****bbbbbb**ccccc*cc***bbbbcc***AAAAASHUTTING DOWN

*AAAAAc*

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

   %   quantum has run out, calling scheduler()

  |(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|(0-1)|(1b-2)|(2b-3)~a~a~a~a~a~a~S*3*3*3*3%|(3-1)|(1b-2)|(2b-3)~a~a~a~a~z~z~S*

3*3*3*3%|(3-1)~z~S*1*1*1*1%|(1-2)|(2b-3)~b~b~b~b~b~b~S*3*3~c|(3b-1)~c~c~c~c*1~c~

c~S*1*1*1%|(1-2)|(2z-3)|(3b-1)~b~b~b~b~c~c~S*1*1*1~A|(1b-3)|(3b-0)~A|(0-1)|(1b-3

)|(3b-0)~A|(0-1)|(1b-3)|(3b-0)~A|(0-1)|(1z-3)|(3b-0)~A|(0-3)|(3z-0)*0~A~A~A~A~A~

c*0~S*0*0*0

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

 

LEAVE KERNEL!

 

Analysis of non-preemptive case: remove SHUTTING DOWN, written by kprintf

 

*aaaaaa**********cccccccc*ccaaaazz*z*********AAA*AAAAAAAbb*bb*bbbbbb

         ^ note pause here with no output, as main3 does CPU loop

                                 ^main1 does its CPU loop

                  ^proc 3 exit (6 c’s in Q)

                                           ^proc 1 exit (6 A’s in Q)

                                                   ^proc 2 exit (6 b’s in Q)

 

 

Total runtime: 26 stars, so 26 ticks, 260 ms

10 stars per user-loop, so 100 ms delay loop (in main1 and main3)

 

By themselves:

main 1 runs like this: aaaaaaaaa*azzz**********AAAAAAA*AAA

main 2 runs like this: bbbbbbb*bbbb

main 3 runs like this: *********ccccccc*cccc

 

 

Find CPU bound intervals: delay loops, including when doing write-behind output

 

|-----------------|           |-------------|    CPU bound periods (22 ticks)

*aaaaaa**********cccccccc*ccaaaazz*z*********AAA*AAAAAAAbb*bb*bbbbbb

 

 

Find i/o bound intervals: all three processes blocked on output

 

                  |-----------|             |-------------| i/o bound periods
*aaaaaa**********cccccccc*ccaaaazz*z*********AAA*AAAAAAAbb*bb*bbbbbb        (4 ticks)

 

 

18 chars output during write-behind, overlapped with other activities

25 chars output during i/o bound time, CPU nearly idle (about 25 ms)

Total runtime: 26 stars, so 260 ms

 

With preemption:

 

*aaaaaa****aaaazz****z****bbbbbb**ccccc*cc***bbbbcc***AAAAA*AAAAAc

      ^proc 3 starts running CPU loop, with 6 a’s in Q, gets preempted

         ^proc 1 enq’s 6 chars, blocks, 2 blocks too

              ^proc 3 continues running CPU loop, gets preempted

                  ^proc 1 enq’s last char, start its loop, gets preempted

                     ^proc 2 runs, enqueues 6 b’s, gets blocked

                     ^proc 3 runs loop again, finishes it, enq’s c’s

No i/o bound time:

18 chars output as write-behind

25 chars output overlapped with CPU-bound processes because of preemption

Total runtime: 23 ticks, so 230 ms

Faster because of more i/o overlap with computation.