Lecture13W_F

Lecture13W_F - Queue Data Structure FIFO queue · · Queue...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Queue Data Structure FIFO queue · · Queue buffer—memory space where queue elements are stored. Operations - Enqueue—insert something into a queue. - Dequeue—remove something from a queue. - First item enqueued is first item dequeued. · - Enqueue and dequeue work on opposite ends of queue. Management data - Front/head of queue—location of next item to be removed. - Back/tail of queue—location where next item can be inserted. - Full/empty status of queue · · Number of items in queue. · Maximum capacity of queue. Implementation details - Circular queue—queue insertion/deletion advance forward in memory to end of buffer and then wrap around to beginning. · Queue insertion/deletion advance forward (toward higher memory address) in queue buffer. · After enqueue/dequeue at last buffer position, next enqueue/dequeue at first buffer position. - Queue management record · IN_PTR = Address of location where next item to be inserted. (.W) · OUT_PTR = Address of location where next item to be removed. (.W) · BUF_STRT = Address of beginning of queue buffer. (.W) · BUF_PAST = Address of first item past end of queue buffer. (.W) · BUF_SIZE = Maximum number of items in queue. (.B) · NUM_ENQD = Number of items in queue. (.B) · SZ_ITEM = Size of data unit. (.B) (1=byte; 2=word) Page 1 of 2 Queue Data Structure Page 2 of 2 Queue example · 4-item queue buffer for bytes starting at memory address $1100 · Initial state: empty IN_PTR · Operation sequence - EnQ $20 OUT_PTR - EnQ $12 BUF_STRT - EnQ $72 - EnQ $80 BUF_PAST - EnQ $25 BUF_SIZE - DeQ NUM_ENQD - EnQ $25 - DeQ SZ_ITEM - DeQ - EnQ $18 - DeQ - DeQ - DeQ - DeQ $1100 $1100 $1100 $1104 $0 $0 $1 EnQ $20 EnQ $72 EnQ $80 ¬$20 ¬$20 ¬$20 ® ¬$20 ® $12 $12 $12 ® ®¬ EnQ $12 $72 $72 $80 0 1 2 ® 3 EnQ $25 (X) DeQ ($20) ® ¬$20 ®$20 EnQ $25 $25 DeQ ($12) $25 DeQ ($72) $25 $12 ¬$12 ® ¬$12 ®$12 ®$12 $72 $72 $72 ¬$72 $72 $80 $80 $80 $80 4 3 4 3 ¬$80 2 EnQ $18 $25 DeQ ($80) ¬$25 DeQ ($25) $25 DeQ ($18) $25 DeQ (X) $25 $18 $18 ¬$18 $18 $18 ®$72 ®$72 ®$72 ® ¬$72 ® ¬$72 ¬$80 3 $80 $80 $80 $80 2 1 0 0 4 ...
View Full Document

This note was uploaded on 05/06/2010 for the course EECC 0306-250 taught by Professor Roymelton during the Fall '10 term at RIT.

Ask a homework question - tutors are online