






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







DISK
MEMORY
DISK
Read from disk
Write to disk
Merge
DISK
MEMORY
DISK
I0 I
O0 O
Loser Tree
… Ib
Output buffers
Input buffer queues k=
F0 F1 F2 F3 F4 F5 F6 F7 F
R0 R1 R2 R3 R4 R5 R6 R7 R
Pool of free input buffers
kWayMerge; wait for input/output to complete; add new input buffer (if any) to queue for its run; determine run that will exhaust first; if (there is more input from this run) initiate read of next block for this run; initiate write of active output buffer; activeOutputBuffer = 1 – activeOutputBuffer;
kWayMerge; wait for input/output to complete; add new input buffer (if any) to queue for its run; determine run that will exhaust first; if (there is more input from this run) initiate read of next block for this run; initiate write of active output buffer; activeOutputBuffer = 1 – activeOutputBuffer;
There may be no free input buffer to read into.
initiate read of next block for this run;
Change if (there is more input from this run) initiate read of next block for this run; to if (there is more input from this run) initiate read of next block for this run; else initiate read of a block for the next k-way merge;