Week 15 - OS
Week 15 - OS
Q1) Compare the functionalities of FCFS, SSTF, C-SCAN and C-LOOK with example.
Ans: - Let's compare the functionalities of the First-Come, First-Served (FCFS), Shortest Seek Time
First (SSTF), Circular SCAN (C-SCAN), and Circular LOOK (C-LOOK) disk scheduling algorithms, along
with examples:
Functionality:
It services requests in the order of their arrival, without considering the position of the disk head.
Example:
Requests arrive in the order: 98, 183, 37, 122, 14, 124, 65, 67.
Disk Movement:
Functionality:
SSTF selects the request with the shortest seek time from the current position of the disk head.
It aims to minimize the seek time and reduce the total head movement.
Example:
SSTF selects the next request based on the shortest seek time from the current head position:
Functionality:
C-SCAN serves requests by scanning the disk in one direction until it reaches the end, then jumps to
the other end and continues scanning.
Example:
Disk Movement:
C-SCAN moves the head in one direction, servicing requests along the way:
Functionality:
C-LOOK is similar to C-SCAN but only scans until it reaches the last request in the current direction,
then jumps back to the first request and continues scanning.
It reduces unnecessary head movement by only serving requests within the current direction.
Example:
Disk Movement:
C-LOOK moves the head in one direction, servicing requests along the way:
Q2) What are files and explain the access methods for files?
Ans: - Files are collections of data that are stored together under a single name, typically on a storage
medium such as a hard drive, SSD, or optical disk. Files are organized into directories within a file
system, allowing users to organize and manage their data efficiently. Each file is identified by a
unique name within its directory, and it may contain various types of data, such as text, images,
audio, video, or executable code.
Access methods define how data within files can be read from or written to by programs or users.
Here are the common access methods:
In Sequential Access:
sequential access, data is read or written sequentially from the beginning to the end of the file.
Reading or writing operations must start from the beginning of the file and proceed linearly through
each data item until reaching the desired location.
This method is analogous to reading a book page by page, from start to finish.
Sequential access is suitable for processing data sequentially, such as reading or writing large
datasets sequentially.
Direct access allows data to be accessed randomly at any point within the file.
Data can be read from or written to any location in the file without the need to traverse through the
entire file sequentially.
It provides more flexibility in accessing specific data items within a file without reading or writing
unnecessary data.
This method is analogous to accessing specific pages in a book by directly flipping to them, rather
than reading through the entire book sequentially.
Direct access is suitable for applications requiring quick access to specific data records or blocks
within a file, such as databases or indexed files.
Indexed Access:
Indexed access uses an index table or directory structure that contains pointers to various data
blocks or locations within the file.
Each index entry corresponds to a specific data item or block within the file.
Indexed access allows for quick lookups and retrieval of data items based on their index or key value.
This method is suitable for applications requiring efficient random access to data items within a file,
such as database systems with secondary indexes or hash tables.