Write a program to simulate managing les on disk

Assignment Help Programming Languages
Reference no: EM132211481

Question: Write a program to simulate managing les on disk. De ne the disk as a onedimensional array disk of size numOfSectors*sizeOfSector, where sizeOfSector indicates the number of characters stored in one sector. (For the sake of debugging, make it a very small number.) A pool of available sectors is kept in a linked list sectors of three eld structures: two elds to indicate ranges of available sectors and one next eld. Files are kept in a linked list les of four eld structures: lename, the number of characters in the le, a pointer to a linked list of sectors where the contents of the le can be found, and the next eld.

1. In the rst part, implement functions to save and delete les. Saving les requires claiming a sucient number of sectors from pool, if available. The sectors may not be contiguous, so the linked list assigned to the le may contain several nodes. Then the contents of the le have to be written to the sectors assigned to the le. Deletion of a le only requires removing the nodes corresponding with this le (one from les and the rest from its own linked list of sectors) and transferring the sectors assigned to this le back to pool. No changes are made in disk.

2. File fragmentation slows down le retrieval. In the ideal situation, one cluster of sectors is assigned to one le. However, after many operations with les, it may not be possible. Extend the program to include a function together() to transfer les to contiguous sectors; that is, to create a situation illustrated in Figure below. Fragmented les le1 and le2 occupy only one cluster of sectors after together() is nished. However, particular care should be taken not to overwrite sectors occupied by other les. For example, le1 requires eight sectors; ve sectors are free at the beginning of pool, but sectors 5 and 6 are occupied by le2. Therefore, a le f occupying such sectors has to be located rst by scanning les.

The contents of these sectors must be transferred to unoccupied positions, which requires updating the sectors belonging to f in the linked list; only then can the released sectors be utilized. One way of accomplishing this is by copying from the area into which one le is copied chunks of sectors of another le into an area of the disk large enough to accommodate these chunks. In the example in Figure below, contents of le1 are rst copied to sectors 0 through 4, and then copying is temporarily suspended because sector 5 is occupied. Thus, contents of sectors 5 and 6 are moved to sector 12 and 14, and the copying of le1 is resumed.

Reference no: EM132211481

Questions Cloud

Create an array to hold average house price : Create an array to hold average house price for the each of past 25 years for a single family residence of 1500 square feet. Initialize the array.
Create a trigger : CP5503 - Enterprise Database Systems - Oracle - write an anonymous block (PL/SQLstatements) to call the function to test
Write the program to show how depth-first search works : Write the program to show how depth-first search works on the following graph. Assume that the DFS procedure considers the vertices in alphabetical order.
WAP that takes integer as number of both rows and columns : Write a program ShiftNumbers.java that takes integer M as the number of both rows and columns for your 2D array. Create the same exact following 2D array.
Write a program to simulate managing les on disk : Write a program to simulate managing les on disk. De ne the disk as a onedimensional array disk of size numOfSectors*sizeOfSector, where sizeOfSector indicates.
Write a program to read the salary for ten employees : Write a program to read the Salary for 10 employees. Calculate average of Salary. Calculate the Max Salary and Min Salary.
Discuss ethics in research : Discuss Ethics in Research - you need to be concerned about protection for those participants. As seen in 45 CFR 46 in the Code of Federal Regulations
Calculate area of a circle and of a rectangle : Write a program that uses two functions to calculate area of a circle and of a rectangle. Instruction: Declare P1 as a global constant.
Compute the width of each column based upon the precision : Compute the width of each column based upon the precision. All columns after the rst should have the same width. All columns should be separated by a blank.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd