454066OS exp10
454066OS exp10
PART A
(PART A: TO BE REFFERED BY STUDENTS)
A-2 Prerequisite
Knowledge about C/C++ programming language.
A.3 Outcome
A.4 Theory:
SEQUENTIAL FILE ALLOCATION
ALGORITHM:
Step 1: Start the program.
Step 2: Get the number of files.
Step 3: Get the memory requirement of each file.
Step 4: Allocate the required locations to each in sequential order.
a). Randomly select a location from available location s1= random(100);
b). Check whether the required locations are free from the selected location.
c). Allocate and set flag=1 to the allocated locations.
Step 5: Print the results fileno, length , Blocks allocated.
Step 6: Stop the program.
LINKED FILE ALLOCATION
ALGORITHM:
Step 1: Start the Program
Step 2: Get the number of files.
Step 3: Allocate the required locations by selecting a location randomly
Step 4: Check whether the selected location is free.
Step 5: If the location is free allocate and set flag =1 to the allocated locations.
Step 6: Print the results file no, length, blocks allocated.
Step 7: Stop the execution
Disk Scheduling:
DESCRIPTION
One of the responsibilities of the operating system is to use the hardware efficiently. For the disk
drives, meeting this responsibility entails having fast access time and large disk bandwidth. Both
the access time and the bandwidth can be improved by managing the order in which disk I/O
requests are serviced which is called as disk scheduling. The simplest form of disk scheduling is,
of course, the first-come, first served (FCFS) algorithm. This algorithm is intrinsically fair, but it
generally does not provide the fastest service. In the SCAN algorithm, the disk arm starts at one
end, and moves towards the other end, servicing requests as it reaches each cylinder, until it gets
to the other end of the disk. At the other end, the direction of head movement is reversed, and
servicing continues. The head continuously scans back and forth across the disk. C-SCAN is a
variant of SCAN designed to provide a more uniform wait time. Like SCAN, C-SCAN moves the
head from one end of the disk to the other, servicing requests along the way. When the head reaches
the other end, however, it immediately returns to the beginning of the disk without servicing any
requests on the return trip.
1. FCFS: FCFS is the simplest of all the Disk Scheduling Algorithms. In FCFS,
the requests are addressed in the order they arrive in the disk queue.Let us
understand this with the help of an example.
Example:
Suppose the order of request is- (82,170,43,140,24,16,190)
And current position of Read/Write head is : 50
Grade:
B 3. Conclusion:
In conclusion, the FCFS, SCAN, and C-SCAN disk scheduling algorithms offer different
approaches to optimizing disk access and seek times. FCFS serves requests in the order they
arrive, while SCAN and C-SCAN prioritize efficient movement of the disk arm to reduce seek
times. SCAN moves the arm back and forth, while C-SCAN restricts movement to one direction,
enhancing performance in certain scenarios. Understanding these algorithms helps in selecting the
most suitable disk scheduling strategy based on specific system requirements and disk access
patterns.
B 4. Question of Curiosity
Q 1. Write advantages and disadvantages of FCFS, SCAN and C-SCAN algorithms.
Advantages and Disadvantages of FCFS, SCAN, and C-SCAN Algorithms
First Come First Serve (FCFS) Algorithm:
Advantages:
1. Simplicity: FCFS is easy to implement and understand, making it user-friendly for all levels of
experience.
2. Ease of Implementation: It can be quickly integrated into existing systems with minimal effort
and cost.
3. Sequence Integrity: Orders are processed in the exact order they are received, ensuring
fairness.
Disadvantages:
1. Not Suitable for Time-Sharing Systems: FCFS is not ideal for time-sharing systems where
processes need fixed access to the CPU at regular intervals.
2. Inefficiency for Short Processes: Short processes may have to wait for long processes to finish,
reducing throughput efficiency.
3. Limited Input-Output Efficiency: FCFS is more compatible with CPU-centric systems than
input-output systems.
SCAN Algorithm:
Advantages:
1. Simple Implementation: SCAN is straightforward to implement and understand.
2. Avoids Starvation: Ensures that all requests are eventually serviced, preventing starvation.
3. Low Variance in Waiting and Response Time: Provides consistent performance in terms of
waiting and response times.
Disadvantages:
1. Long Waiting Time: Cylinders recently visited by the head may experience extended waiting
times.2. Inefficient Head Movement: The head moves to the end of the disk even when no
requests are present, impacting efficiency.
C-SCAN Algorithm:
Advantages:
1. Improved Version of SCAN: C-SCAN enhances the SCAN algorithm by reducing waiting
times for recently visited cylinders.
2. Uniform Waiting Time: Provides consistent waiting times for all requests.
3. Better Response Time: Offers improved response times compared to SCAN.
Disadvantages:
1. Increased Seek Movements: C-SCAN may cause more seek movements compared to SCAN.
2. Unnecessary Head Travel: The head travels to the end of the disk even when no requests are
left to be serviced.