/*request_list is a list of requests ordered by SCAN order. |
schedule_list is a list of schedules that have a sequence of requests. |
group_list is a list of groups that consist of adjacent best-effort requests. |
is a schedule with the minimum seek time.*/ |
procedure ADD_REQUEST(request R) |
/* insert R into request_list by SCAN order. */ |
for each request in request_list |
if (.track_num > .track_num) then |
insert_request(); /* insert request R in front of . */ |
break; |
end if |
end for |
/* group adjacent best-effort requests. */ |
GROUP_REQUESTS(); |
/*expand existing schedules by inserting . */ |
EXPAND_SCHEDULES(); |
/* remove schedules whose seek time is larger than that of |
by a disk’s full sweep time, . */ |
for each schedule in schedule_list |
if (.seektime − .seektime > ) then |
remove_schedule(, schedule_list); /* remove from schedule_list*/ |
end if |
end for |
end procedure |
procedure GROUP_REQUESTS(request ) |
if (.type = real-time) then |
for each group in group_list |
/* if is located in , split the into two groups */ |
if (.start_track_num < .track_num and .track_num < .end_track_num) then |
split_group (, ); |
return; |
end if |
end for |
else /*R.type is best-effort. */ |
/* and are left and right neighbour requests of , respectively, |
and is a threshold for grouping. */ |
if (.type = best-effort and .type = best-effort) then |
if (.track_num − .track_num < ) then |
insert_into_group(, ); /* add to the group including both |
and . */ |
return; |
else if (.track_num − .track_num < and .track_num −.track_num < ) then |
merge_groups(, ); /* merge group including and group |
including . */ |
return; |
else if (.track_num − .track_num < ) then |
insert_into_group (, ); /* add to the group including . */ |
return; |
else if (.track_num − .track_num < ) then |
insert_into_group (, ); /* add to the group including . */ |
return; |
end if |
else if (.type = best-effort and .type = real-time) then |
if (.track_num − .track_num < ) then |
insert_into_group (, ); /* add to the group including . */ |
return; |
end if |
else if (.type = real-time and .type = best-effort) then |
if (.track_num − .track_num < ) then |
insert_into_group (, ); /* add to the group including . */ |
return; |
end if |
else |
create_group (); /* creates a new group including . */ |
end if |
end if |
end procedure |
procedure EXPAND_SCHEDULES(request ) |
old_schedule_list ←schedule_list; |
for each schedule in old_schedule_list |
remove_schedule (, old_schedule_list); /* remove from old_schedule_list. */ |
for each position in request sequences of |
← a new schedule created by inserting into position . |
deadline_missed ← FALSE; |
temp ← 0; |
for each request in |
temp + = .servicetime; |
if (.deadline < temp) then |
deadline_missed ← TRUE; |
break; |
end if |
end for |
if (deadline_missed = FALSE) then |
insert_schedule (, new_schedule_list); /* insert into |
new_schedule_list. */ |
if (.seektime < .seektime) then |
← ; |
end if |
end if |
end for |
end for |
schedule_list ←new_schedule_list; |
end procedure |