OperatingSystem代写:CSCI3150MultiThreading


用C/C++代写一个简易的VFS文件系统,并提供对应的命令行工具,实现命令操作。

Introduction

In this assignment, you are going to implement a simple version file system,
namely, vfs, using C/C++. This vfs is specialized designed for matrixes. Each
file stores an n × n matrix. The vfs keeps all versions of all files being
added. It supports four commands.

Add

Usage: vfs add <file path>

Use this command when you want to backup a local file to the vfs. Output Add
success! if this operation is success or output Add error! otherwise. The
first time the file is added to the vfs, that is version 1 of the file. The
second time the file is added to the vfs using that command, that is version 2
of the file. Your vfs shall keep all versions of all files being added.

Retrieve

Usage: vfs retrieve <file path> <version number>

Use this command when you want to retrieve a previous version of your file.
When retrieving, the current working copy of the file will be overwritten by
the version that you retrieve from vfs. If the retrieval is successful, vfs
shall output Retrieve success!, else output Retrieve error!.

Diff

Usage: vfs diff <file path> <version 1> <version 2> <row> <column>

Use this command when you want to know whether a particular element in the
matrix is the same across two versions of the same file. Outputs 0 when the
elements of the two versions are the same, output 1 otherwise. On any error,
outputs Diff error!

Calculate

Usage: vfs calculate <file path> <version 1> <version 2> <type> <row> <column>

Use this command when you want to do some simple matrix calculations across
the same row and column between two versions of a matrix. There are 3 types of
calculation.
Suppose ./testMatrix.txt is a 3 × 3 matrix as follows.

-r

It calculates the sum of differences between the corresponding elements in the
row that contains the element at position [row,column] among the two versions.
For example, ./vfs calculate ./testMatrix.txt 1 2 -r 3 2 calculates the sum of
differences of row 3 in version 1 and version 2 of “testMatrix.txt”. The
result is
(7 − 7) + (8 − 8) + (9 − 1) = 8.
Note: order matters, so the result of
./vfs calculate ./testMatrix.txt 1 2 -r 3
could be different from the result of
./vfs calculate ./testMatrix.txt 2 1 -r 3.
Note: In this command, the column value is ignored.

-c

Same as -r except it calculates the sum of differences between the
corresponding elements in the column that contains the element at position
[row,column] among the two versions.
For example, ./vfs calculate ./testMatrix.txt 1 2 -c 3 2 calculates the sum of
differences of column 2 in version 1 and version 2 of “testMatrix.txt”. The
result is
(2 − 2) + (5 − 5) + (8 − 8) = 0.
Note: In this command, the row value is ignored.

-a

It calculates the sum of differences between the corresponding elements in the
specified sub-matrix among the two versions. The sub-matrix consists of all
elements surrounding the element at position [row,column].

Your assignment

Submission

You are required to submit one source code asg4-func.c to eLearning. If
needed, you can also submit your Makefile to eLearning. You must make sure
your Makefile works, otherwise, you get 0 marks.

Grading

Part A: Correctness

30 test cases. A test case is essentially a script that executes a sequence of
content edits and vfs operations. Each test case will test if your vfs is
functioning properly or not.

Part B: Bonus

A versioned file system shall care about both space and time efficiency. It
shall use less space to store all copies if possible but it shall not
sacrifice the operation performance either.
Bonus will be awarded to the following students.

  • [Test case P1] If the total space under /.vfsdata used by your vfs is smaller than the TA’s demo.
  • [Test case P2] If the total running time of your vfs command in test case P2 is faster than the TA’s demo (Cache will be cleaned before the measurement).

文章作者: SafePoker
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 SafePoker !
  目录