0
0
Operating Systemsknowledge~10 mins

Priority scheduling in Operating Systems - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select the process with the highest priority.

Operating Systems
highest_priority_process = min(processes, key=lambda p: p[1])
Drag options to blanks, or click blank then click option'
A.burst_time
B.pid
C.arrival_time
D.priority
Attempts:
3 left
💡 Hint
Common Mistakes
Using burst time or arrival time instead of priority.
Selecting the process with the maximum priority number.
2fill in blank
medium

Complete the code to check if a process is preempted by a higher priority process.

Operating Systems
if new_process.priority [1] current_process.priority:
Drag options to blanks, or click blank then click option'
A>
B==
C<
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using greater than sign instead of less than.
Checking for equality instead of priority comparison.
3fill in blank
hard

Fix the error in the code that calculates waiting time in non-preemptive priority scheduling.

Operating Systems
waiting_time = start_time - process[1]
Drag options to blanks, or click blank then click option'
Aarrival_time
Bcompletion_time
Cburst_time
Dpriority
Attempts:
3 left
💡 Hint
Common Mistakes
Using burst time or completion time instead of arrival time.
Subtracting in the wrong order causing negative waiting time.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps process IDs to their priorities for processes with priority less than 5.

Operating Systems
{p[1]: p[2] for p in processes if p.priority < 5}
Drag options to blanks, or click blank then click option'
A.pid
B.priority
C.arrival_time
D.burst_time
Attempts:
3 left
💡 Hint
Common Mistakes
Using burst time or arrival time instead of priority as values.
Using priority as keys instead of process IDs.
5fill in blank
hard

Fill all three blanks to create a dictionary of processes with their waiting times, only for processes with waiting time greater than 0.

Operating Systems
waiting_times = {p[1]: p[2] - p[3] for p in processes if p[2] - p[3] > 0}
Drag options to blanks, or click blank then click option'
A.pid
B.start_time
C.arrival_time
D.priority
Attempts:
3 left
💡 Hint
Common Mistakes
Using priority instead of arrival time or start time.
Including processes with zero or negative waiting time.