Seminar 4
Seminar 4
SEMINAR
CS3353-C PROGRAMMING AND DATA STRUCTURES
Introduction:
Semaphores
FCFS ( first come first serve) scheduling, example: FIFO queue
Spooling in printers
Buffer for devices like keyboard
CPU Scheduling
Memory management
Applications of Queue in Networks:
Applied as waiting lists for a single shared resource like CPU, Disk, and
Printer.
Applied as buffers on MP3 players and portable CD players.
Applied on Operating system to handle the interruption.
Applied to add a song at the end or to play from the front.
Applied on WhatsApp when we send messages to our friends and they don’t
have an internet connection then these messages are queued on the server of
WhatsApp.
Traffic software ( Each light gets on one by one after every time of interval
of time.)
1. Queue overflow: If a queue has a fixed size, it can become full, leading to a
queue overflow. This can happen if elements are added to the queue faster
than they are removed. To prevent overflow, some implementations use
dynamic resizing or circular buffers.
2. Queue underflow: If a queue is empty and an attempt is made to remove an
element, this can lead to a queue underflow. This can happen if elements are
removed from the queue faster than they are added. To prevent underflow,
some implementations use sentinel values or null pointers to represent an
empty queue.
3. Blocking queues: In some applications, a queue may become blocked if it is
full or empty. This can cause delays in processing or deadlock. To address
this, some implementations use bounded queues or non-blocking queues.
4. Priority inversion: In some applications, a higher priority element can get
stuck behind a lower priority element in the queue. This can lead to priority
inversion and result in reduced performance. To prevent this, some
implementations use priority queues or multiple queues with different
priorities.
5. Synchronization issues: In concurrent applications, multiple threads may
access the same queue simultaneously. This can lead to synchronization
issues like race conditions, deadlocks, and livelocks. To address this, some
implementations use locking mechanisms like mutexes or semaphores.
6. Memory management: In some implementations, a queue may allocate and
deallocate memory frequently, leading to memory fragmentation and
reduced performance. To address this, some implementations use memory
pools or pre-allocated buffers.
Advantages of Queue:
Disadvantages of Queue:
The operations such as insertion and deletion of elements from the middle
are time consuming.
In a classical queue, a new element can only be inserted when the existing
elements are deleted from the queue.
Searching an element takes O(N) time.
Maximum size of a queue must be defined prior in case of array
implementation.