Lect13_queue_apps - ITI 1121. Introduction to Computing II...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
ITI 1121. Introduction to Computing II * Marcel Turcotte School of Information Technology and Engineering Version of March 3, 2010 Abstract Queues-based algorithms Asynchronous processes Simulations State-space search * These lecture notes are meant to be looked at on a computer screen. Do not print them unless it is necessary.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Summary Queues are implemented with arrays or linked elements. In the case of circular arrays, modulo arithmetic is used when incrementing the index so that the queue wraps around the array when it reaches the end. index = ( index + 1 ) % MAX_QUEUE_SIZE; One must be careful to detect the case when the array gets full and avoid overriding any elements as well as distinguishing between the full and empty queues. Several implementations are possible: using sentinel values , destroying the array, using a boolean value to indicate if the queue is full/empty or to maintain a count of the number of elements in the queue. Of course, the details of the implementation of each method will vary with the implementation. The operation dequeue() is sometimes called serve() ; because queues are often used in the context of client/server applications.
Background image of page 2
Asynchronous processes Applications such as producer/consumer , client/server or sender/receiver necessitate using a queue for asynchronous processing of the data. Asynchronous processing means that the client and the server are not synchronized, which would occur if the server is not ready or capable of receiving the data at that time or speed. Asynchronous processes: The client insert data into a queue (enqueue); The server removes data from the queue (dequeue) whenever it’s ready for processing. In this context, the queue is sometimes called a buffer .
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Asynchronous processes In particular, inter-process communications in operating systems work like this. 1. printer spooler ; 2. buffered i/o ; 3. disk accesses; 4. sending messages (packets) across the network.
Background image of page 4
Time-shared applications CPU rear front new process dequeue() enqueue() All modern operating systems operate in time-shared mode. One of the frequent techniques to share time is called round-robin . The first process in the queue is allocated a slice of time (dequeue) after which it is suspended and put at the end of the queue (enqueue), time is allocated for the next process.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/06/2011 for the course ITI 1121 taught by Professor Samaan during the Spring '10 term at University of Ottawa.

Page1 / 39

Lect13_queue_apps - ITI 1121. Introduction to Computing II...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online