COM1032 Operating Systems

Coursework

60% of the Total Mark


Contents

Deadlines............................................................................................................................................................................1

Submission Requirements ....................................................................................................................................................1

Overall Task........................................................................................................................................................................2

Component A [70 pts]..........................................................................................................................................................2

    Tasks..............................................................................................................................................................................2

    Additional Info ................................................................................................................................................................4

Component B [30 pts]..........................................................................................................................................................5


Deadlines

Date Handed out: Friday 23 April 2021, Week 8

Deadline: Wednesday 19 May 2021, 16:00, week 12

Submission: All Java files and One PDF Via SurreyLearn

Late submission penalties will apply as usual according to the regulations

Academic Misconduct: Coursework will be routinely checked for academic misconduct. The work must be individual.


Submission Requirements

You need to submit all Java files and the PDF report in the surreylearn assignment folder.

Each Java file must have the line “package URN;” where the URN is your own student number. In the case of the report, the first part of the report name must be “URN-“ where URN is your own student number. This is to ensure we have the correct files for each student.

Additionally, all the files submitted will have a turnitin report – that means no archives. If you have 4 Java files and 3 input txt files and 1 PDF report, you have to submit all 7 files. A high turnitin score for some files should not be of concern as we’ll investigate and make the appropriate decision.


Overall Task

Build a Non-Contiguous Segmented Memory Allocation Management that simulates the allocation of processes in memory, and provide a report that explains your implementation. See Lab 8 for an example in the context of contiguous memory allocation. The full 100 marks for this task are split into:

• Component A [70 pts] a java program that implements the Segmented Memory Allocation.

• Component B [30 pts] a report describing the implementation.


Component A [70 pts]

Write a java program that implements the Segmented Memory Allocation Management. We expect you to provide us with all your Java files and make it clear how each sub-component was solved. More precisely, provide us with Filename and code line for the implementation of the code, and an example that demonstrate the function/algorithm working. All your examples have to be in same place – ideally one after another; maybe in the main function.

Caution: Your Java program has to run without major help from us – it must be self-contained; we’re not going to search for your fancy library and add it, or change environment paths, etc. We’ll be using Eclipse in Windows 10. If we cannot make run then you’ll receive 0 pts for this component.


Tasks

A.1. [30 pts] A working Java program. Submit all your Java files needed to run the implementation of Segmented Memory Allocation Management. This implementation needs to consider core aspects of memory allocation: processes, segment table, segments of variable memory size, allocation/dealocation of processes in memory using segments, allocation/deallocation of memory to segments, etc. In the Main function have an example that shows everything working.

A.1.1. All working Java files submitted to the assignment folder as files and not part of some archive.

A.1.2. An example that shows the allocation and deallocation of processes from memory. Print Start Example A.1.2” and “End Example A.1.2” to highlight the beginning and end of this example.

A.2. [15 pts] Implement the 2 functionalities read-write protection and sharing of segments. A.2 is built on A.1 by adding the 2 functionalities mentioned here. See the Paging Lecture slides for how they are intended to work.

A.2.1. Read-write protection. Provide the Filename with line number for the code, and an example that shows this functionality working. Print the exact location of code (Filename and line number) between the lines “Start Code Location A.2.1 read-write protection” and “End Code Location A.2.1 read-write protection”. Print “Start Example A.2.1 read-write protection” and “End Example A.2.1 read-write protection” to highlight the beginning and end of the example for this component.

Example:

Start Example A.1.2

… The Example….

End Example A.1.2

Start Code Location A.2.1 read-write protection

…. Filename and line number …..

End Code Location A.2.1 read-write protection

Start Example A.2.1 read-write protection

…. The example ….

End Example A.2.1 read-write protection

A.2.2. Sharing of segments. Provide the Filename with line number for the code, and an example that shows this functionality working. Print the exact location of code (Filename and line number) between the lines “Start Code Location A.2.2 sharing of segments” and “End Code Location A.2.2 sharing of segments”. Print “Start Example A.2.2 sharing of segments” and “End Example A.2.2 sharing of segments” to highlight the beginning and end of the example for this component.

A.2.3. Combining read-write protection and sharing. Provide an example that shows these 2 functionalities working together. Print “Start Example A.2.3” and “End Example A.2.3” to highlight the beginning and end of the example for this component. See Example 3.

A.3. [10 pts] Implement the Translation Look-Aside Buffer (TLB) and compaction. A.3 is built on A.1 by adding TLB and compaction. Component A.3 can be done independent from A.2. See the Paging Lecture slides for how it is intended to work.

A.3.1. Translation Look-Aside Buffer (TLB). Provide the Filename with line number for the code, and an example that shows this functionality working. Print the exact location of code (Filename and line number) between the lines “Start Code Location A.3.1 TLB” and “End Code Location A.3.1 TLB”. Print “Start Example A.3.1 TLB working” and “End Example A.3.1 TLB working” to highlight the beginning and end of the example for TLB working. Print “Start Example A.3.1 TLB miss” and “End Example A.3.1 TLB miss” to highlight the beginning and end of the example for TLB miss.

A.3.2. Compaction- is an algorithm used to shuffle the memory content and free memory space. Make sure it’s integrated with the memory management such that it works automatically when enough memory is in the system that can be allocated to a process, when the process would have otherwise not been allocated due to small size of the holes. Print the exact location of code (Filename and line number) between the lines “Start Code Location A.3.2 Compaction” and “End Code Location A.3.1 Compaction”. Print “Start Example A.3.1 Compaction” and “End Example A.3.1 Compaction” to highlight the beginning and end of the example to allocated a process, when the process would have otherwise not been allocated due to small size of the holes.

A.4. [15 pts] Testing Exceptions. There will be 3 tests created by the marker to focus on a number of exceptions your program should have already accounted for. Each successful test is worth 5pts. 2 tests depend only on A.1, while the 3rd test depends on A.1, A.2, and A.3.

A.5. [10pts] Useful Comments. All variables, major functions and classes should have comments explaining their functionality. A.5 looks at comments to all Java procedures and classes. This component requires you to have done at least A.1. If additional components have been done, e.g. A.2, A.3, A.4, then those procedures and classes also have to have comments. You don’t need to add comments to all functions, e.g. if you have get_something and set_something then the code is self-explanatory. See Lab 7 Solution for an example.


Additional Info

How to prepare your Examples: All your examples have to be non-trivial. For example, do not just allocate a single process to main memory. There has to be at least 5 processes and a variable length and memory size for their segments. Highlight each example with “Start Example number” and “End Example number” both in the main function and in the console.

Remark: Your code has to handle changes to the example provided, e.g., increasing the number of segments or the size of memory needed.

Standard Inputs: To allocate/deallocate a process to memory use a standard format Process, Segment 1, Segment 2 ... For example, 1, 100, 200, 10 refers to Process P1 requiring you to allocate 100 bytes for Segment S1, 200 bytes for Segment 2, and 10 bytes for Segment 3. The first allocation creates a baseline, and all other calls to process 1 will add or remove memory from the segments.

• Example: 1, 100, 200, 10 followed by 1, 100, 200, 10 tells us Process P1 has allocated 200 bytes to Segment 1, 400 to Segment 2, and 30 to Segment 3.

• Example: 1, 100, 200, 10 followed by 1, -40, 200, -10 tells us Process P1 has allocated 60 bytes to Segment 1, 400 to Segment 2, and 0 to Segment 3.

• Example: 1, 100, 200, 10 with 1, -40, -200, 10 and 1, -40, 200, tells us Process P1 has allocated 60 bytes to Segment 1, Segment 2 disappears (200-200), and Segment 3 became Segment 2 with 220 bytes in memory. The number of segments can vary, notice that 1, -40, 200 allocates 200 bytes to old Segment 3 (now on Second position).

Read-Write and Sharing: To enable read-only (0 or false) or read-write (1 or true) permission we attach a Boolean flag read-write-flag to each Segment. Similarly, we attach a shared-with-list for the list of processes that have shared access to this segment. Notice that the shared-with-list can be empty. Also, notice that the processes in shared-with-list must have a segment with size and that is not allocated new memory.

• Example: 1, [100, 0], [200, 0, 2, 3, 4], 10 tells us that Process P1 has 3 segments. Segment 1 has 100 bytes allocated with read-only permission and this segment is not shared. Segment 2 has 200 bytes under read-only permission and this segment is shared with processes P2, P3, and P4. Segment 3 has 10 bytes under read-write permission and not shared; so, the value 10 is viewed as [10, 1]. Notice that Sharing always works with read-only permission.

• Example: 1, [100, 0], [200, 0, 2, 3, 4], 10 and 1, [-10, 1], [100, 0, 2, 5], 10 tells us that Process 1 has 3 Segments. Segment 1 has 90 bytes of memory under the read-write permission. Segment 2 has 300 bytes under read-only permission and is shared with process P2 and P5.

• Example: 1, [100, 0], [200, 0, 2, 3] and 2, [200, 0, 1, 3], tells us that Process 1 has 2 Segments. Segment 1 has 100 bytes of memory under the read-write permission. Segment 2 has 200 bytes under read-only permission and is shared with process P2 and P3. However, process P2 has a segment of the size 200 bytes associated to him and must have P1 and P3 in shared-with-listThe total allocation of memory is 300 bytes, as when Segment 1 of P2 is already in memory.

Examples with Compaction: No sharing and read-write protection considered in this example.

Total Memory: 1024 bytes. OS memory: 124 bytes.

Step 1: 1, 100, 100, 10

Step 2: 2, 400

Step 3: 1, -40, 0, 0

Step 4: 2, -10, 300

Step 5: 3, 180, 60

Imagine that we allocate memory in order: 900 bytes in user space.

We use A to say allocated memory and H the hole of available memory

After Step 1: [A100] [A100] [A10] [H690]

After Step 2: [A100] [A100] [A10] [A200] [H490]

After Step 3: [A60] [H40] [A100] [A10] [A200] [H490]

After Step 4: [A60] [H40] [A100] [A10] [A190] [H10] [A300] [H190]

Compaction before Step 5: [A60] [A100] [A10] [A190] [A300] [H240]

Compaction and Step 5: [A60] [A100] [A10] [A190] [A300] [A 180] [A60]

No compaction means Process 3 cannot be allocated in memory.


Component B [30 pts]

Write a PDF document that explains your implementation. You are to provide an up-to 5-page (withour the title page) document in a reasonable font (e.g., Times New Roman/Calibri 11pt). The report must be submitted as a PDF on surreylearn such that turnitin provides a score. That means do not put this PDF in an archive. The goal of this report is to explain how the code works, some of your choices, what each file does. We’re going to look at the following aspects:

B.1. [15 pts] Provide an overall description/intuition of the implementation. Describe minimally what we should expect from your implementation, e.g., what is the main file, what each file does (you can use some of the comments in the code), how they link in the system. The main aim is on how the system looks and how each class plays a role in the system. All classes need a description, even if the class is trivial. You can minimally describe some functions by saying we provide a getter and setter to this variable, e.g., “Process.java in Lab 8 can be described as the class that defines a process. We consider a number of private variables: reference_number – used to identify a process, operation to either allocate (1) or deallocate (2) this process in/from memory, and argument for the size of memory this process used/or will use. We’ve defined getter and setter procedures for these variables.”

B.2. [10 pts] Use an UML Class diagram to enforce the above point. Be sure you’ve used the same class names, procedure names, and variable names you mentioned in B.1. Here is a link that explains how to build class diagrams. https://www.youtube.com/watch?v=UI6lqHOVHic

B.3. [5 pts] Style. Make your document presentable, e.g., using title, sections or paragraphs.