| void p() { A; B; C; } |
void q() { D; E; } |
boolean choosing[n];
int number[n];
while (true)
{
choosing[i] = true;
number[i] = 1 = getmax( number[], n );
choosing[i] = false;
for (int j=0; j < n; j++ )
{
while (choosing[j])
{ };
while ((number[j]!=0) &&(number[j],j)<(number[i],i))
{ };
}
/* critical section*/;
number[i] = 0;
/* remainder */;
}
The arrays choosing and number are initialized to false and 0 respectively.
The ith element of each array may be read and written by process i but only read by
other processes. The notation (a,b) < (c,d) is defined as
resource Jurassic_Park()
sem car_avail:=0, car_taken:=0, car_filled:=0, passenger_released:=0
process passenger(i:=1 to num_passengers )
do true -> nap( int(1000*wander_time)))
P(car_avail); V(car_taken); P(car_filled)
P(passenger_released)
od
end passenger
process car(j:=1 to num_cars)
do true -> V(car_avail); P(car_taken); V(car_filled)
nap( int(1000*ride_time)))
V(passenger_released)
od
end car
end Jurassic_Park
Construct a new program that will be more efficient under these circumstances. Hints: Allow n to have the value -1, which is to mean that not only is the buffer empty but that the consumer has detected this fact and is going to block until the producer supplies fresh data. The solution does not require the use of the local variable m found in Figure 5.10.
The shaded areas are allocated blocks; the white areas are free blocks. The next three memory requests are for 40M, 20M, and 10M. Indicate the starting address for each of the three blocks using the following placement algorithms:
| Starting Address | Length (bytes) |
|---|---|
| 660 | 248 |
| 1752 | 422 |
| 222 | 198 |
| 996 | 604 |
For each of the following logical addresses, determine the physical address or indicate if a segment fault occurs:
| Virtual Page number | Valid bit | Reference bit | Modify bit | Page frame number |
|---|---|---|---|---|
| 0 | 1 | 1 | 0 | 4 |
| 1 | 1 | 1 | 1 | 7 |
| 2 | 0 | 0 | 0 | - |
| 3 | 1 | 0 | 0 | 2 |
| 4 | 0 | 0 | 0 | - |
| 5 | 1 | 0 | 1 | 0 |
1, 0, 2, 2, 1, 7, 6, 7, 0, 1, 2, 0, 3, 0, 4, 5, 1, 5, 2, 4, 5, 6, 7, 6, 7, 2, 4, 2, 7, 3, 3, 2, 3
Define the mean working set size after the kth reference as
and define the missing page probability after the kth reference as
,
where F( t, Δ ) = 1 if a page fault occurs at virtual time t and 0 otherwise.
Create a program that will allow the user to input the execution time and period for up to ten periodic real-time tasks. Then your program should determine if they can be successfully scheduled using Rate Monotonic Scheduling. Note since we are starting all tasks at time 0, you need only check until every task has finished its first period. You should output a message indicating that the tasks can be scheduled successfully, or the first task that fails to meet its deadline.
Note: Rate Monotonic Scheduling is a preemptive algorithm!
Example 1 (successful)
|
Example 2 (successful)
| |||||||||||||||||||||||||||||||||||||||||||
Example 3 (P4 misses its first deadline)
|
Example 4 (P4 misses its first deadline)
| |||||||||||||||||||||||||||||||||||||||||||
Example 5 (successful)
|
Example 6 (P6 misses its first deadline)
| |||||||||||||||||||||||||||||||||||||||||||
Example 7 (successful)
|
Example 8 (P5 misses its first deadline)
|
The new specification revises this to say
The change was made to fix a problem referred to as the "Sorcerer's Apprentice." Deduce and explain the problem.