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 program to establish two savings accounts

Write program which establishes two savings accounts with saver1 having account number 10002 with initial balance of $2,000, and saver2 having account 10003 with initial balance of $3,000.

  Write a program that picks a random number

Extend your guessing game from last week. Write a program that picks a random number from 1-100. Then ask the user to guess a number

  Compare and contrast three scripting languages

For this project, students will compare and contrast three scripting languages, the approaches, and techniques used in each to facilitate interactive design

  Write the program which simulates shopping

Write the program which simulates shopping. Program must have a loop which continues as long as user wants to shop. Each time through loop read in name, price, and quantity of the item.

  Program to read an employee-s number from keyboard

Write a program that reads an employee's number from the keyboard, number of hours worked and an hourly rate of pay.

  List the contents of the current directory

List the contents of the current directory. Create the directory structure and create the files as defined in the previous Individual Project.

  Design a project to allow a student to access current grades

Design a project to allow a student to access current grades and/or create a "What-if" situation on a continuing basis to understand where they are at any given point in the semester.

  Write calendar application which allows user to select date

The purpose of this lab is to give you a chance to use some of the data stream tools we have been discussing in a simple application. The assignment is to write a calendar application which allows the user to select a date, and either retrieve a p..

  Create a class structure flow chartfor yourprogram

Create a class structure,algorithmsand flow chartfor yourprogram, and then do several iterations of tests. You'll turn that document in with the program.

  Write down the xml file with markup tags

Write down the XML file with markup tags and some sample data to represent list of invoices. Write the XML tags for two invoices in list.

  Write program to accept a list of student-s name

Write a program that will accepts a list of student's name, individual scores for quiz1, quiz2 and quiz3. Your program should then compute for the average of 3 quizzes.

  Write multiplication program make positive one-digit integer

Write down program which will aid the elementary school learn multiplication. Use Random object to make two positive one-digit integers.

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