Description
This assignment is on priority inversion (page 458-460), well, a simplified version of
it. You could use any of the common languages C, C++, Java, Python, etc. Assume the
following:
a. There are three kinds of jobs with priorities P(T1) = 3, P(T2) = 2 and P(T3) = 1. A
job with a higher priority means it can preempt another one with a lower priority immediately, except that T1 cannot preempt T3 as they share a common devise.
b. T1 shares a small buffer of length 3 with T3, with an initial value of < 0, 0, 0 > at time
0. When T1 gets hold of it, it changes the content to < 1, 1, 1 > and print out a new line:
T1111T1. When T3 gets hold of it, it changes the content to < 3, 3, 3 > and prints out
a new line: T3333T3. Each of T1 and T3 takes 3ms (1ms = 1 slice) to run, and you can
assume that the enforcement of mutex, etc, takes no time.
c. T2 shares nothing with T1 and T3. When T2 runs to completion with no interruption,
it prints out a new line: T2NNNNNNNNNNT2., where ‘N’ means “normal”. Each T2 takes
10ms to run. When T1 preempts T2, T2 will print out the number of N’s according to the
actual time it has run (in the number of slices). For instance, T2 runs at time 0, then
there is a request at time 6 for T1, then T2 should print out: T2NNNNNNT2. Then, T1 takes
over at time 6. Same rule applies to T3, when it is preempted by T2.
d. The input sequence of jobs are in the form harrival time, ji, where j = 1, 2, 3 is the
index for Tj . When you have a sequence of three inputs: < 1, 1 >, < 3, 2 >, < 6, 3 >, the
output should be like:
time 1, T1111T1.
time 4, T2NNNNNNNNNNT2.
time 14, T3333T3.
(1) To make the debugging easier, you could use random sequences of at most 10 job
requests. Implement the version with priority inversion, i.e., a higher priority job can
always interrupt a lower priority job (except that T1 cannot preempt T3 as they share a
common buffer). Print out one scenario when the priority inversion occurs.
(2) For the following sequence of input print out your output: < 1, 3 >, < 3, 2 >, <
6, 3 >, < 8, 1 >, < 10, 2 >, < 12, 3 >, < 26, 1 >.
Date Due: 8:30pm on Tuesday, November 29, 2022 (on or before 8:30pm,
Nov 29, 2022). Load your source code and output as two separate files on D2L
in the folder Assignment 3, preferably in the form of family name − 3.java and
family name − 3.output (assuming that you are using Java).


