Question

Exercise 8.4.1: Operations on files. 0 About Current directory File descriptors Open file table Symbolic Descriptor name inde

For each operation, show all changes to the data structures. Open file named test. Seek to position 60 of the open test file.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a) Only OFT is changed. We add the Descriptor Index of the file test (i.e. 19) and the position is 0 since the file is only opened and no bytes have been accessed yet.

It becomes:

Descriptor Index Current Position
.... .....
free
16 55
19 0
free
.... ....

b) Only OFT is changed. The position is updated from 0 to 60.

It becomes:

Descriptor Index Current Position
.... .....
free
16 55
19 60
free
.... ....

c) The Current Directory and File Descriptors are changed. Just to keep things sequential, we give the file new the descriptive index of 21 (after descriptive index 20 of xx) and Disc Block #43 (since 40,41 and 42 is already taken up by file xx). The file length of new is 0 since nothing has been written in it yet.

Current Directory becomes:

Symbolic Name Descriptor Index
.... .....
free
xx 20
abc 16
test 19
new 21
free
.... ....

File Descriptors becomes:

File length Disc Block #
.... .....
15 free
16 100 5
17 free
18 free
19 280 8
20 550 40
21 0 43
.... ....

d) Only OFT is changed. We add the Descriptor Index of the file new (i.e. 21) and the position is 0 since the file is only opened and no bytes have been accessed yet.

It becomes:

Descriptor Index Current Position
.... .....
free
16 55
19 0
21 0
free
.... ....

e) OFT is changed. The position is changed to 30 since we have written 30 bytes.

It becomes:

Descriptor Index Current Position
.... .....
free
16 55
19 0
21 30
free
.... ....

File Descriptors Table is also updated to show file length of 30 for the file new at index 21. It becomes:

File length Disc Block #
.... .....
15 free
16 100 5
17 free
18 free
19 280 8
20 550 40
21 30 43
.... ....

f) OFT is changed. The entry for Descriptor Index 21 is removed and space is now free.

It becomes:

Descriptor Index Current Position
.... .....
free
16 55
19 0
free
free
.... ....

g) The Current Directory and File Descriptors are changed. We remove the entry of the file new from the Current Directory and free up the space. We also remove the entry at the descriptive index of 21 from the File Descriptors Table.

Current Directory becomes:

Symbolic Name Descriptor Index
.... .....
free
xx 20
abc 16
test 19
free
free
.... ....

File Descriptors becomes:

File length Disc Block #
.... .....
15 free
16 100 5
17 free
18 free
19 280 8
20 550 40
21 free
.... ....
Add a comment
Know the answer?
Add Answer to:
Exercise 8.4.1: Operations on files. 0 About Current directory File descriptors Open file table Symbolic Descriptor...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Unix/Linux, input and output are treated as files and referenced by the operating system using file descriptors. When you open a shell session, for example, three file descriptors are in use: 0 st...

    In Unix/Linux, input and output are treated as files and referenced by the operating system using file descriptors. When you open a shell session, for example, three file descriptors are in use: 0 standard input (stdin) 1 standard output (stdout) 2 standard error (stderr) By default, the command interpreter (shell) reads keyboard input from file descriptor 0 (stdin) and writes output to file descriptor 1 (stdout), which appears on the screen. As you explored in Lab 2, input/output can be...

  • IT PYTHON QUESTION1 Consider the following Python code, where infile.txt and outfile.txt both exist in the current directory 'z' ) 。1d = open ( ' infile. txt ' , for line in o...

    IT PYTHON QUESTION1 Consider the following Python code, where infile.txt and outfile.txt both exist in the current directory 'z' ) 。1d = open ( ' infile. txt ' , for line in old: new.write (line) new.write') ne«.close () old.close) Which of the following options best describes the purpose or outcome of this code? O A copy of the file infile.txt is made (except in double line spacing) and saved as outfile.txt in the current directory. O A copy of the...

  • Homework 1- Merge Files: 1. Design a class named MergeFiles 1 Three file names are passed...

    Homework 1- Merge Files: 1. Design a class named MergeFiles 1 Three file names are passed as command-line arguments to MergeFiles as follows: java MergeFiles filel file2 mergedFile II. MergeFiles reads names stored in files file and file2 III. Merges the two list of names into a single list IV. Sorts that single list V. Ignores repetitions VI. Writes the sorted, free-of-repetitions list to a new file named mergedFile.txt VII. The names in all three files are stored as one...

  • Can anyone help me with my C hw? Exercise 3 You will write a new program...

    Can anyone help me with my C hw? Exercise 3 You will write a new program that combines dynamically allocating an array and saving that array to a file. These are the tasks your program must perform Open an output file named "data.txt" and prepare it for writing in text mode o If the file handle is NULL, quit the program o By default, it is created and stored in the same directory as your source code file Prompt the...

  • write a code on .C file Problem Write a C program to implement a banking application...

    write a code on .C file Problem Write a C program to implement a banking application system. The program design must use a main and the below functions only. The program should use the below three text files that contain a set of lines. Sample data of these files are provided with the assessment. Note that you cannot use the library string.h to manipulate string variables. For the file operations and manipulations, you can use only the following functions: fopen(),...

  • 1. Your project will include the following three files: A header file: dynamicArray.h that includes a...

    1. Your project will include the following three files: A header file: dynamicArray.h that includes a list of function prototypes as enumerated in the next section. An implementation file: dynamicArray.cpp that implements the functions declared in the header file. A test driver file: dynamicArray-main.cpp that includes the main() function so that you can test all the functions you've implemented above. 2. The header file dynamicArray.h will include the following list of functions: constructing a dynamic array of the specified size...

  • Python Project

    AssignmentBitmap files map three 8-bit (1-byte) color channels per pixel. A pixel is a light-emitting "dot" on your screen. Whenever you buy a new monitor, you will see the pixel configuration by its width and height, such as 1920 x 1080 (1080p) or 3840x2160 (4K). This tells us that we have 1080 rows (height), and each row has 1920 (width) pixels.The bitmap file format is fairly straight forward where we tell the file what our width and height are. When...

  • C++ Programming

    PROGRAM DESCRIPTIONIn this project, you have to write a C++ program to keep track of grades of students using structures and files.You are provided a data file named student.dat. Open the file to view it. Keep a backup of this file all the time since you will be editing this file in the program and may lose the content.The file has multiple rows—each row represents a student. The data items are in order: last name, first name including any middle...

  • Lab 10: ArrayLists and Files in a GUI Application For this lab, you will work on...

    Lab 10: ArrayLists and Files in a GUI Application For this lab, you will work on a simple GUI application. The starting point for your work consists of four files (TextCollage, DrawTextItem, DrawTextPanel, and SimpleFileChooser) in the code directory. These files are supposed to be in package named "textcollage". Start an Eclipse project, create a package named textcollage in that project, and copy the four files into the package. To run the program, you should run the file TextCollage.java, which...

  • Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that...

    Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that will process monthly sales data for a small company. The data will be used to calculate total sales for each month in a year. The monthly sales totals will be needed for later processing, so it will be stored in an array. Basic Logic for main() Note: all of the functions mentioned in this logic are described below. Declare an array of 12 float/doubles...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT