联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> OS作业OS作业

日期:2018-05-31 02:00


Threaded Tape

You are tasked with writing a program that will read different parts of a tape. The tape itself is represented as a 1 dimensional byte array of n size.The user will input commands that will allow the tape to move back and forth by k steps. Each step will output to a file the data being read.

Each head is placed at an offset from the base or starting point of the tape (index 0), this offset is specified by the user. You are tasked with writing the command handler that will invoke functions related to tape head creation. Each head will write to its own respective file. If it is thread 1, it will write out to ./head1, thread 2 will write out to ./head2 and so on.

The main thread needs to wait until all threads have finished reading and writing out to a file. If it attempts to run another command while it is still reading/writing, it could compromise this process, therefore the main thread needs to wait until all other threads have completed and all threads will need to wait until the main thread runs a command.

Your program will use a filename from command line arguments and you will need to read in the binary data. You may treat the data as unsigned bytes.

If no filename is specified in the command line arguments the program should output:

Tape Not Inserted

If a file does not exist

Cannot Read Tape


The output format when a read head is set HEAD:

HEAD <id> at <offset>

When a READ command is ran, the program needs to output when it has finished reading.:

Finished Reading

Important:

The tape file itself a binary file of n bytes. No other information or data is provided with it.

The output of the file should just contain a stream of bytes that was read from the tape and should be rereadable as a tape itself.

You are recommend to use pthreads and mutex locks for synchronisation between threads on this task.

Assumptions/Clarifications:

?Offset from head can be negative, you will need to use the modulus operator (beware of an overflow).

?You may assume that a thread will always start and a file will be created for that thread.

Commands:

HEAD <offset: signed, relative to the base>

READ <offset: signed, relative to the cursor, cursor starts at base>

QUIT

Examples

Example 1 Invalid File:

Tape Not Inserted

Example 2 File Does Not Exist:

Cannot Read Tape

Example 3 Head Example:

HEAD 50

HEAD 1 at +50


HEAD -20

HEAD 2 at -20

Example 4 Read:

READ 4000

Finished Reading


READ -2000

Finished Reading

Academic Declaration

By submitting this assignment you declare the following:

I declare that I have read and understood the University of Sydney Academic Dishonesty and Plagiarism in Coursework Policy, and except where specifically acknowledged, the work contained in this assignment or project is my own work, and has not been copied from other sources or been previously submitted for award or assessment.

I understand that failure to comply with the the Academic Dishonesty and Plagiarism in Coursework Policy, can lead to severe penalties as outlined under Chapter 8 of the University of Sydney By-Law 1999 (as amended). These penalties may be imposed in cases where any significant portion of my submitted work has been copied without proper acknowledgement from other sources, including published works, the internet, existing programs, the work of other students, or work previously submitted for other awards or assessments.

I realise that I may be asked to identify those portions of the work contributed by me and required to demonstrate my knowledge of the relevant material by answering oral questions or by undertaking supplementary work, either written or in the laboratory, in order to arrive at the final assessment mark.

I acknowledge that the School of Information Technologies, in assessing this assignment, may reproduce it entirely, may provide a copy to another member of faculty, and or communicate a copy of this assignment to a plagiarism checking service or in house computer program, and that a copy of the assignment may be maintained by the service or the School of IT for the purpose of future plagiarism checking.


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp