0% found this document useful (0 votes)
11 views4 pages

Week 15 - OS

WOS

Uploaded by

deepak kumbhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

Week 15 - OS

WOS

Uploaded by

deepak kumbhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Week 15 – Operating System

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:

1. First-Come, First-Served (FCFS):

Functionality:

FCFS schedules disk requests in the order they arrive.

It services requests in the order of their arrival, without considering the position of the disk head.

Example:

Consider a disk with tracks numbered from 0 to 199.

Requests arrive in the order: 98, 183, 37, 122, 14, 124, 65, 67.

The disk head starts at track 53.

Disk Movement:

Total head movement: 640 tracks.

FCFS simply services requests in the order they arrive:

Head moves from 53 to 98 (45 tracks)

Head moves from 98 to 183 (85 tracks)

Head moves from 183 to 37 (146 tracks)

Head moves from 37 to 122 (85 tracks)

Head moves from 122 to 14 (108 tracks)

Head moves from 14 to 124 (110 tracks)

Head moves from 124 to 65 (59 tracks)

Head moves from 65 to 67 (2 tracks)

2. Shortest Seek Time First (SSTF):

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:

Using the same request sequence and disk parameters as FCFS.


Disk Movement:

Total head movement: 236 tracks.

SSTF selects the next request based on the shortest seek time from the current head position:

Head moves from 53 to 65 (12 tracks)

Head moves from 65 to 67 (2 tracks)

Head moves from 67 to 37 (30 tracks)

Head moves from 37 to 14 (23 tracks)

Head moves from 14 to 98 (84 tracks)

Head moves from 98 to 122 (24 tracks)

Head moves from 122 to 124 (2 tracks)

Head moves from 124 to 183 (59 tracks)

3. Circular SCAN (C-SCAN):

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.

It ensures fairness in serving requests by always starting from one end.

Example:

Using the same request sequence and disk parameters as FCFS.

Disk Movement:

Total head movement: 238 tracks.

C-SCAN moves the head in one direction, servicing requests along the way:

Head moves from 53 to 98 (45 tracks)

Head moves from 98 to 122 (24 tracks)

Head moves from 122 to 183 (61 tracks)

Head moves from 183 to 199 (16 tracks)

Head jumps to 0 and moves to 14 (14 tracks)

Head moves from 14 to 37 (23 tracks)

Head moves from 37 to 65 (28 tracks)

Head moves from 65 to 67 (2 tracks)

4. Circular LOOK (C-LOOK):

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:

Using the same request sequence and disk parameters as FCFS.

Disk Movement:

Total head movement: 236 tracks.

C-LOOK moves the head in one direction, servicing requests along the way:

Head moves from 53 to 65 (12 tracks)

Head moves from 65 to 67 (2 tracks)

Head moves from 67 to 98 (31 tracks)

Head moves from 98 to 122 (24 tracks)

Head moves from 122 to 124 (2 tracks)

Head moves from 124 to 183 (59 tracks)

Head moves from 183 to 199 (16 tracks)

Head jumps to 14 and moves to 37 (23 tracks)

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 for Files:

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 (Random Access):

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.

You might also like