Debopriya 033
Debopriya 033
Debopriya 033
SPECIAL ASSIGNMENT
SUBMITTED BY:-
NAME- Pankaj Roy
DEPT.- COMPUTER SCIENCE & ENGINEERING
ROLL NO.- 33200117024
SEMESTER-6th SEM(3RD YEAR)
SUBJECT- OPERATION RESEARCH
SUBJECT CODE- CS-(603)
1
GROUP – A
1.
I. Which of the following page replacement algorithms suffers from Belady’s Anomaly?
Ans:C)FIFO
Ans:A)Logical Address
2
Group – B
Ans: DMA stands for “Direct Memory Access” and is a method of transferring data from the computer‘s RAM to another
part of the computer without processing it using the CPU. While most data that is input or output from your computer is
processed by the CPU, some data does not require processing, or can be processed by another device.
In these situations, DMA can save processing time and is a more efficient way to move data from the computer’s
memory to other devices. In order for devices to use direct memory access, they must be assigned to a DMA channel.
Each type of port on a computer has a set of DMA channels that can be assigned to each connected device. For example,
a PCI controller and a hard drive controller each have their own set of DMA channels.
In this mode block of data from one memory address is moved to another memory address. In this mode current
address register of channel 0 is used to point the source address and the current address register of channel is used to
point the destination address in the first transfer cycle, data byte from the source address is loaded in the temporary
register of the DMA controller and in the next transfer cycle the data from the temporary register is stored in the
memory pointed by destination address. After each data transfer current address registers are decremented or
incremented according to current settings. The channel 1 current word count register is also decremented by 1 after
each data transfer. When the word count of channel 1 goes to FFFFH, a TC is generated which activates EOP output
terminating the DMA service.
Auto initialize
In this mode, during the initialization the base address and word count registers are loaded simultaneously with the
current address and word count registers by the microprocessor. The address and the count in the base registers remain
unchanged throughout the DMA service.After the first block transfer i.e. after the activation of the EOP signal, the
original values of the current address and current word count registers are automatically restored from the base address
and base word count register of that channel. After auto initialization the channel is ready to perform another DMA
service, without CPU intervention.
3
3. What do you mean by Fragmentation? What are the types of Fragmentation?
Ans: In contiguous memory allocation whenever the processes come into RAM, space is allocated to them. These spaces
in RAM are divided either on the basis of fixed partitioning(the size of partitions are fixed before the process gets loaded
into RAM) or dynamic partitioning (the size of the partition is decided at the run time according to the size of the
process). As the process gets loaded and removed from the memory these spaces get broken into small pieces of
memory that it can’t be allocated to the coming processes. This problem is called fragmentation.Fragmentation is an
unwanted problem where the memory blocks cannot be allocated to the processes due to their small size and the blocks
remain unused. It can also be understood as when the processes are loaded and removed from the memory they create
free space or hole in the memory and these small blocks cannot be allocated to new upcoming processes and results in
inefficient use of memory. Basically, there are two types of fragmentation:
• Internal Fragmentation
• External Fragmentation
Internal Fragmentation
In this fragmentation, the process is allocated a memory block of size more than the size of that process. Due to this
some part of the memory is left unused and this cause internal fragmentation.
Example: Suppose there is fixed partitioning (i.e. the memory blocks are of fixed sizes) is used for memory allocation in
RAM. These sizes are 2MB, 4MB, 4MB, 8MB. Some part of this RAM is occupied by the Operating System (OS).
Now, suppose a process P1 of size 3MB comes and it gets memory block of size 4MB. So, the 1MB that is free in this
block is wasted and this space can’t be utilized for allocating memory to some other process. This is called internal
fragmentation.
External Fragmentation
In this fragmentation, although we have total space available that is needed by a process still we are not able to put that
process in the memory because that space is not contiguous. This is called external fragmentation.
Example: Suppose in the above example, if three new processes P2, P3, and P4 come of sizes 2MB, 3MB, and 6MB
respectively. Now, these processes get memory blocks of size 2MB, 4MB and 8MB respectively allocated.
So, now if we closely analyze this situation then process P3 (unused 1MB)and P4(unused 2MB) are again causing internal
fragmentation. So, a total of 4MB (1MB (due to process P1) + 1MB (due to process P3) + 2MB (due to process P4)) is
unused due to internal fragmentation.
4
Group – C
7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1.
Calculate the number of page faults and page fault rate for the following algorithms.
Ans:
FIFO:
Input 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
F1 1 1 1 1 0 0 0 3 3 3 3 3 2 2 2 2 2 1
F2 0 0 0 0 3 3 3 2 2 2 2 2 1 1 1 1 1 0 0
F3 7 7 7 2 2 2 2 4 4 4 0 0 0 0 0 0 0 7 7 7
Faults F F F F F F F F F F F F F F F
No. of page faults: 15 &
LRU:
Input 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
F1 1 1 1 3 3 3 2 2 2 2 2 2 2 2 2 7 7 7
F2 0 0 0 0 0 0 0 0 3 3 3 3 3 3 0 0 0 0 0
F3 7 7 7 2 2 2 2 4 4 4 0 0 0 1 1 1 1 1 1 1
Faults F F F F F F F F F F F F
No. of page faults:12 &
5. Suppose a disk drive has 200 cylinders numbered 0-199.The current position of the arm
i. FCFS Scheduling.
Ans:
1. First Come -First Serve (FCFS) All incoming requests are placed at the end of the queue. Whatever number that is
next in the queue will be the next number served. Using this algorithm doesn't provide the best results. To determine
the number of head movements we would simply find the number of tracks it took to move from one request to the
5
next. For this case it went from 50 to 95 to 180 and so on. From 50 to 95 it moved 45 tracks. If we tally up the total
number of tracks you will find how many tracks it had to go through before finishing the entire request. In this example,
it had a total head movement of 640 tracks. The disadvantage of this algorithm is noted by the oscillation from track 50
to track 180 and then back to track 11 to 123 then to 64. As we will soon see, this is the worse algorithm that one can
use.
3. Elevator (SCAN)
This approach works like an elevator does. It scans down towards the nearest end and then when it hits the bottom it
scans up servicing the requests that it didn't get going down. If a request comes in after it has been scanned it will not be
serviced until the process comes back down or moves back up. This process moved a total of 230 tracks. Once again this
is more optimal than the previous algorithm, but it is not the best.
6
Total Head Movement here is:230