Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3 . This problem studies the interaction between real - time scheduling and mutual exclusion. Consider the following excerpt of code: 1 pthread _ mutex
This problem studies the interaction between realtime scheduling and mutual exclusion.
Consider the following excerpt of code:
pthreadmutext X; Resource X: Radio communication
pthreadmutext Y; Resource Y: LCD Screen
pthreadmutext Z; Resource Z: External Memory slow
void ISRA Safety sensor Interrupt Service Routine
pthreadmutexlock&Y;
pthreadmutexlock&X;
displayalert; Uses resource Y
sendradioalert; Uses resource X
pthreadmutexunlock&X;
pthreadmutexunlock&Y;
void taskB Status recorder task
while
static timet starttime time;
pthreadmutexlock&X;
pthreadmutexlock&Z;
statst stat getstats;
radioreport stat ; uses resource X
recordreport stat ; uses resource Z
pthreadmutexunlock&Z;
pthreadmutexunlock&X;
sleeptimestarttime; schedule next excecution
void taskC UI Updater task
while
pthreadmutexlock&Z;
pthreadmutexlock&Y;
readloganddisplay; uses resources Y and Z
pthreadmutexunlock&Y;
pthreadmutexunlock&Z;
You may assume that the comments fully disclose the resource usage of the procedures. That
is if a comment says uses resource X then the relevant procedure uses only resource X The
scheduler running aboard the system is a prioritybased preemptive scheduler, where taskB is
higher priority than taskC. In this problem, ISR A can be thought of as an asynchronous task
with the highest priority.
The intended behavior is for the system to send out a radio report every ms and for the
UI to update constantly. Additionally, if there is a safety interrupt, a radio report is sent
immediately and the UI alerts the user.
a Every so often, when there is a safety interrupt, the system completely stops working.
In a scheduling diagram like Figure in Lee&Seshia using the tasks fABCg and
resources fXYZg explain the cause of this behavior. Execution times do not have to
be to scale in your diagram. Label your diagram clearly. You will be graded in part on
the clarity of your answer, not just on its correctness.
b Using the priority ceiling protocol, show the scheduling diagram for the same sequence
of events that you gave in part a Be sure to show all resource locks and unlocks until
all tasks are finished or reached the end of an iteration. Does execution stop as before?
c Without changing the scheduler, how could the code in taskB be reordered to fix the
issue? Using an exhaustive search of all taskresource locking scenarios, prove that
this system will not encounter deadlock. Hint: Your proof should enumerate cases
because the tasks each have possible resources they could block on
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started