Quiz02Solutions - CS411 Operating Systems II Quiz 2 1(2 pts 2(3 pts Spring 2009 Solutions for selected problems Given a record file structure in a

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CS411 Operating Systems II Spring 2009 Quiz # 2 Solutions for selected problems 1. (2 pts) 2. (3 pts) Given a record file structure in a file system that provides only sequential access methods (i.e., create_file, reset , read_next_record , write_record , close , etc.). Write a pseudo-code algorithm to simulate a direct access method rewrite_record ( n ) using the defined sequential access methods . Assume that the file to be changed has been opened for input. When you write a record to a sequential file, and then close the file, the end-of-file is at the end of the new record. Therefore, you can’t just find record #n and overwrite it. Even if that were possible, records might vary in size, so we need a different kind of solution. Here is one way to do it: Assume that file F1 is open for input, and F1 has num_recs records. new_rec will replace record # n . F2 = create_file open F2 for output reset(F1) -- start from beginning of file for (i = 1; i < n; i++)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/28/2009 for the course CS 411 taught by Professor Staff during the Spring '08 term at Oregon State.

Ask a homework question - tutors are online