1DV512 - Lab assignment 12022-11-30 1 (5)

1 Introduction

1.1 Assignment Rules

This assignment is meant to be solved individually and not in groups. That means theassignment is evaluated/graded individually.2. When you believe your assignment is ready to be evaluated/graded, upload your solutionusing Moodle’s submission system, and then it will get assessed after some days by us. Pleaserefer to 2.5 for the submission structure.

2 Description

2.1 Task objective

Your objective is to simulate contiguous memoryallocation (see Operating Systems Concepts, mainlychapter 9.2.2.) using all the first-fit, best-fit, and worst-fit strategies.The result shall be a memory layout consisting of allocated blocks and holes (free blocks). Also,external fragmentation shall be computed according to the following formula:𝑓𝑟𝑎𝑔𝑚𝑒𝑛𝑡𝑎𝑡𝑖𝑜𝑛 = 1 −𝐿𝑎𝑟𝑔𝑒𝑠𝑡 𝑏𝑙𝑜𝑐𝑘 𝑜𝑓 𝑓𝑟𝑒𝑒 𝑚𝑒𝑚𝑜𝑟𝑦𝑇𝑜𝑡𝑎𝑙 𝑓𝑟𝑒𝑒 𝑚𝑒𝑚𝑜𝑟𝑦Also, a brief report describing your implementation strategies shall be submitted (i.e., your thoughtswhen constructing the application).

2.2 Task implementation

To control the order in which allocation, deallocation, and compaction of blocks occurs, an input fileshall be used to list actions (see 2.3.1) to be performed. This means that the file is to be read by yourprogram running the actions line by line. Simulation results shall be stored in one or more filesaccording to 2.3.2.If there is not enough memory to allocate a block, theprogram should skip the instruction that lead to an error and continue the execution with the following statement, if any. The sameapplies if a deallocation instruction refers to a non-existing ID. Note that all the occurred errors must
be documented and printed in the output file(s).Also, all file paths shall be relative to your working directory!See 2.4 for an execution example (input to output).

2.3 File formats

There are four commands:Command Parameter 1 Parameter 2 DescriptionA Block id Amount of memory (bytes) Allocate
D Block id Not used Deallocate <block id>C Not used Not used Compact memory, meaning moveall allocated block towards thelowest address.O Not used Not used Output the current status of thememory in an intermediate output
1DV512 - Lab assignment 12022-11-30 2 (5)file. See 2.3.2 for detailedinformation.Rules:An output file contains the results from a simulation or anintermediaterepresentation of thememory during it. Its structure (layout) is described below.A final output file name uses the input file name with the extension <.out>. An intermediate (e.g.,generated after invoking the O command) output file name uses the input file name with theextension <.out#>, where # is the placeholder for an incremental integer. So, if the input file is‘scenario1.in’, then the final output file is ‘scenario1.out’, while all theintermediate outputs will benamed ‘scenario1.out1’, ‘scenario1.out2’, and so on.Content structureNote 1: Anything within a <>-pair below shall be replaced by actual values. ’:’ means additional lines.E.g., <block id>;<start address>; <end address> is replaced with, for instance, 0;200;300.Note 2: Allocated blocks are listed by ascending block id.Note 3: Free blocks are listed by ascending start address.Note 4: In case of an allocation error when executing anA command, the following format shall beused under the Errors section:<type of instruction>;<instructionnumber>;<max available blocks>Where instruction number refers to the number of the command that triggered the error (that isequal to its line number – 1) and the max availableblocks refer to the maximum amount ofallocation space(NOT the total free space!) available when the error occurred.The type ofinstruction must be ‘A’.In case of a deallocation error when executing a Dcommand, the following format shall be usedunder the Errors section:
<type of instruction>;<instruction number>;<reason for Where instruction number refers to the number of thecommand that triggered the error (that is
equal to its line number – 1) and the reason for failureshould be set to 0 if the ID to deallocate was
never attempted to be allocated or to 1 if the ID to deallocate was previously tried to be allocatedbut resulted in an error. The type of instruction must be‘D’.
If the execution did not return any errors (or theintermediate output has no errors until that point),

just output ‘None’ under the Errors section.Note 5: Fragmentation is ALWAYS a 6 decimals number. This means that if your value is for example0.5, it should be printed in the output file as 0.500000. Standard rounding rules apply if your valuehas more than 6 digits for decimals.
Structure:
First fit
Allocated blocks
<block id>;<start address>; <end address>
:
Free blocks
<start address>;<end address>
:
Fragmentation
<fragmentation rounded to 6 decimals>
Errors
<type of instruction>;<instruction number>;<3rd parameter>
:
Best fit
Allocated blocks
<block id>;<start address>; <end address>
:
Free blocks
<start address>;<end address>
:
Fragmentation
<fragmentation rounded to 6 decimals>
Errors
<type of instruction>;<instruction number>;<3rd parameter>
:
Worst fit
Allocated blocks
<block id>;<start address>; <end address>
:
Free blocks
<start address>;<end address>
:
Fragmentation
<fragmentation rounded to 6 decimals>
Errors
<type of instruction>;<instruction number>;<3rd parameter>

2.5 Submission structure

Your submission MUST be composed of a report in .pdf format and a .zip file containing yourexecutable source code along with the instructions for building it. Attaching your output files in thesubmission is unnecessary, as your code will be executed for every desired input file and theproduced output files will be evaluated. Submissions that fail to comply with this format (e.g., reportin .docx format, no building instructions, report placed inside the .zip file, …) will see a slightreduction in their overall score.
WX:codehelp


儒雅的皮蛋
1 声望0 粉丝