What's going on?


R. Clayton (rclayton@monmouth.edu)
(no date)


I'm having problems implementing problem 4 because my join implementation from
problem 1 doesn't work. I ran your os4 on pa1-forkjoin.dsk, but I don't
understand the output.

Process 53 runs and forks process 54. But then process 54 tries to join
process 55 which doesn't yet exist. Then process 55 runs so that 54 can wait
for it to exit. I don't understand how a process can join to another process
that doesn't yet exist. If you then create the new process (55), then what
program does it run?

  It can get mysterious. The easiest way to understand this example is to step
  through it.

    $ /e*/h*/c*/*5/S*/b*/os4 -Dintr,f31 -d /e*/h*/c*/*5/d*/pa1-forkjoin.dsk

    At time 0, on reboot interrupt entry, registers 0-15 are
       0: 0 1: 0 2: 0 3: 0
       4: 0 5: 0 6: 0 7: 0
       8: 0 9: 0 10: 0 pc: 0
      ia: 0 ps: 0x00000000 tp: 0 bs: 0

    At time 0, process 53 runs.

    On reboot interrupt exit, registers 0-15 are
       0: 0 1: 0 2: 0 3: 291800
       4: -12975560 5: -4266728 6: 485236 7: 485648
       8: 485212 9: 508388 10: 485188 pc: 39
      ia: 485164 ps: 0x00000000 tp: 40 bs: 39

  On boot-up the os creates and runs the idle process (process 53; notice the
  pc value) and schedules a disk read for the index block.
    
    At time 10, on disk interrupt entry, registers 0-15 are
       0: 0 1: 0 2: 0 3: 291800
       4: -12975560 5: -4266728 6: 485236 7: 485648
       8: 485212 9: 508388 10: 485188 pc: 39
      ia: 485164 ps: 0x00000000 tp: 40 bs: 39

    At time 10, process 54 runs.

    On disk interrupt exit, registers 0-15 are
       0: -4267260 1: 54 2: 2 3: 485960
       4: 485952 5: 16 6: 0 7: 0
       8: -4267220 9: 485976 10: -4267220 pc: 4000
      ia: -4267228 ps: 0x00003601 tp: 4064 bs: 4000

  Some time later the index block shows up in Primary Store. There are
  programs on the disk, so the os creates and schedules program 1 (at program
  block index 0) for execution as process 54.

  Although it may look like it, the idle process did not fork process 54; 54
  ran as a consequence of being the first program on the batch disk.

    At time 11, on invalid-address interrupt entry, registers 0-15 are
       0: -4267260 1: 54 2: 2 3: 485960
       4: 485952 5: 16 6: 0 7: 0
       8: -4267220 9: 485976 10: -4267220 pc: 4000
      ia: 4000 ps: 0x00003601 tp: 4064 bs: 4000

    At time 11, process 53 runs.

    On invalid-address interrupt exit, registers 0-15 are
       0: 0 1: 0 2: 0 3: 291800
       4: -12975560 5: -4266728 6: 485236 7: 485648
       8: 485212 9: 508388 10: 485188 pc: 39
      ia: 485164 ps: 0x00000000 tp: 40 bs: 39

  The os uses pure demand paging, so process 54 has no pages in User Space,
  which means it throws an immediate page fault when executed. 54 is suspended
  and it's back to the only runnable process in the system.

    At time 22, on disk interrupt entry, registers 0-15 are
       0: 0 1: 0 2: 0 3: 291800
       4: -12975560 5: -4266728 6: 485236 7: 485648
       8: 485212 9: 508388 10: 485188 pc: 39
      ia: 485164 ps: 0x00000000 tp: 40 bs: 39

    At time 22, process 54 runs.

    On disk interrupt exit, registers 0-15 are
       0: -4267260 1: 54 2: 2 3: 485960
       4: 485952 5: 16 6: 0 7: 0
       8: -4267220 9: 485976 10: -4267220 pc: 4000
      ia: 4000 ps: 0x00003601 tp: 4064 bs: 4000

  Eventually the page-in for process 54's first page completes, and 54 can
  continue execution.

    At time 26, on system-call interrupt entry, registers 0-15 are
       0: 3 1: 1 2: 2 3: 485960
       4: 485952 5: 16 6: 0 7: 0
       8: -4267220 9: 801 10: -4267220 pc: 4004
      ia: 4000 ps: 0x00003601 tp: 4064 bs: 4000

    On system-call interrupt exit, registers 0-15 are
       0: 1 1: 55 2: 2 3: 485960
       4: 485952 5: 16 6: 0 7: 0
       8: -4267220 9: 801 10: -4267220 pc: 4004
      ia: 4000 ps: 0x00003601 tp: 4064 bs: 4000

  Process 54 makes a fork call (register 0 is 3) for the second program on the
  batch disk (program block index 1, in register 1). My os does not context
  switch to the new process; the immediately system call returns successfully
  (register 0 is 1); the new process's id is 55 (register 1).

    At time 30, process 55 runs.

    At time 30, on system-call interrupt entry, registers 0-15 are
       0: 4 1: 55 2: 2 3: 485960
       4: 485952 5: 16 6: 0 7: 0
       8: -4267220 9: 801 10: -4267220 pc: 4010
      ia: 4000 ps: 0x00003609 tp: 4064 bs: 4000

    On system-call interrupt exit, registers 0-15 are
       0: 1 1: 1 2: 2 3: 485960
       4: 485952 5: 16 6: 0 7: 0
       8: -4267220 9: 801 10: -4267220 pc: 4000
      ia: -4267212 ps: 0x00003701 tp: 4032 bs: 4000

  Process 54 then makes a join call (register 0 is 4), waiting for process 55
  (register 1) to exit. Process 55 hasn't even started running yet, so 54
  blocks and the os runs 55, the only other non-idle process ready to run.

  It's not quite accurate to say that process 55 doesn't exist at this point.
  It's got an entry in the process table (put there by the fork), and it has
  resources associated with it. It just doesn't have any pages mapped into
  User Space.

    At time 31, on invalid-address interrupt entry, registers 0-15 are
       0: 1 1: 1 2: 2 3: 485960
       4: 485952 5: 16 6: 0 7: 0
       8: -4267220 9: 801 10: -4267220 pc: 4000
      ia: 4000 ps: 0x00003701 tp: 4032 bs: 4000

    At time 31, process 53 runs.

    On invalid-address interrupt exit, registers 0-15 are
       0: 0 1: 0 2: 0 3: 291800
       4: -12975560 5: -4266728 6: 485236 7: 485648
       8: 485212 9: 508388 10: 485188 pc: 39
      ia: 485164 ps: 0x00000000 tp: 40 bs: 39

  Process 55 throws an immediate page fault for its first page (just as process
  54 did when it first ran). The os requests a page-in for 55's first page and
  schedules the only process left, the idle process.

    At time 43, on disk interrupt entry, registers 0-15 are
       0: 0 1: 0 2: 0 3: 291800
       4: -12975560 5: -4266728 6: 485236 7: 485648
       8: 485212 9: 508388 10: 485188 pc: 39
      ia: 485164 ps: 0x00000000 tp: 40 bs: 39

    At time 43, process 55 runs.

    On disk interrupt exit, registers 0-15 are
       0: 1 1: 1 2: 2 3: 485960
       4: 485952 5: 16 6: 0 7: 0
       8: -4267220 9: 801 10: -4267220 pc: 4000
      ia: 4000 ps: 0x00003701 tp: 4032 bs: 4000

  Eventually process 55's page lands in User Space, and the os can return 55
  to the cpu.

    At time 46, on system-call interrupt entry, registers 0-15 are
       0: 2 1: 801 2: 2 3: 485960
       4: 485952 5: 16 6: 0 7: 0
       8: -4267220 9: 801 10: -4267220 pc: 4003
      ia: 4000 ps: 0x00003701 tp: 4032 bs: 4000

    At time 46, process 55 exits with value 801.

    At time 46, process 54 runs.

    On system-call interrupt exit, registers 0-15 are
       0: 1 1: 801 2: 2 3: 485960
       4: 485952 5: 16 6: 0 7: 0
       8: -4267220 9: 801 10: -4267220 pc: 4010
      ia: 4000 ps: 0x00003609 tp: 4064 bs: 4000

  Process 55 doesn't do anything more than make an exit system call (register 0
  is 2) with exit value 801 (register 1). The os can now wake-up and schedule
  the join-blocked process 54, indicating that the join was successful
  (register 0 is 1) and passing along 55's exit value (in register 1).

    At time 53, on system-call interrupt entry, registers 0-15 are
       0: 2 1: 801 2: 801 3: 485960
       4: 485952 5: 16 6: 0 7: 0
       8: -4267220 9: 801 10: -4267220 pc: 4021
      ia: 4000 ps: 0x00003609 tp: 4064 bs: 4000

    At time 53, process 54 exits with value 801.

    At time 53, process 53 runs.

    The system is halted.
    Total execution time: 53 ticks, idle time: 30 ticks (56%).
  
    $

  Once unblocked from the join, process 54 checks 55's exit value and makes an
  exit system call. The os, noticing that the idle process is the only
  potentially executable process available, shuts down the system.



This archive was generated by hypermail 2.0b3 on Fri Aug 23 2002 - 19:30:04 EDT