Due Due: Feb 12, 10am. No late assignments will be accepted.
Submit your solution using CMS. Prepare your solution using Word (.doc) or some ascii editor (.txt), as follows:
s that initially equals 0.
VAR s : INTEGER INITIAL(0)
p1: PROCESS;
VAR i : INTEGER;
FOR i:= 1 TO 5 BY 1
s := s + 1
END
END PROCESS p1
p2: PROCESS;
VAR j : INTEGER;
FOR j:= 1 TO 5 BY 1
s := s - 1
END
END PROCESS p2
s could have when
these 2 processes terminate?
s could have when
these 2 processes terminate?
evenize(s,t).
load
and store) are assumed to execute atomically.
evenize(s,t) is assumed to execute atomically.
evenize(s,t) is assumed to have the following effect:
evenize(s,t): t := s
s := shift_left_by_1(s)
evenize(s,t) in conjunction with the usual (non-interlock) instructions found
on a processor and implement entry and exit protocols for solving
the critical section problem.
Or explain why no such protocol can be constructed.
Feel free to present your solution using a high-level language notation instead
of assembly language.
evenize(s,t), the following instruction were
added.
incr(s,t): s := s + 1
t := s
Assume a word size of 32 bits.
Use
incr(s,t) in conjunction with the usual (non-interlock) instructions found
on a processor and implement entry and exit protocols for solving
the critical section problem.
Or explain why no such protocol can be constructed.
Feel free to present your solution using a high-level language notation instead
of assembly language.
process_states[1 .. n] of processorState
where each element of the array stores a process state (i.e., the registers, program counter (pc), status word defining which interrupts are disabled, etc). Note, the interval timer is not considered part of a process state.
running to indicate
which element of process_states most recently was loaded by the
kernel into the processor registers.
LDST addr causes the process state starting at
address addr to be loaded into the processor registers.
LDIT val causes the interval timer to be loaded
with value val.
timer and
inp-out) is:
old_int, a corresponding interrupt "old" area
where the process state is stored by hardware
when the interrupt occurs,
new_int, a corresponding interrupt "new" area
that is initialized by the operating system
kernel and from which a process state is loaded by hardware when an
interrupt occurs (so that control transfers to the appropriate interrupt handler), and
IntEn_int
and IntDis_int.
Instruction IntEn_int causes interrupts of type int
to become enabled and any pending interrupts of type int are delivered;
IntDis_int causes interrupts of type int
to become disabled (so they remain pending when they occur).
SelectNextReady implements a short-term scheduler
and thus returns an integer between 1 and n
that corresponds to a process that can next be loaded into the processor
registers and executed.
Below is proposed code for an I/O interrupt handler.
Thus, you can assume
the value corresponding to pc
in new_inp-out contains the address
of io_intrpt_handler.
io_intrpt_handler:
IntDis inp-out
process_states[ running ] := old_inp-out
... i/o device specific actions ...
running := SelectNextReady
LDIT 100000
LDST process_states[ running ]
io_intrpt_handler,
one of the engineers complained that it seemed as though
inp-out interrupts are being disabled but never re-enabled
and argued that an IntEn_inp-out instruction should be
added to this code segment.
Argue that adding such an instruction is not necessary (and therefore
the reviewer is wrong) by explaining how the desired effect of re-enabling
inp-out interrupts is (presumably) being achieved by other means.