plz find attached documements.
csc2404 Assignment 2 Semester 2, 2020 Due Date: 1:00pm 14 September 2020, AEST Instructions This assignment consists of 4 questions, each of equal value. Please answer the questions in your own words. At most, you should only require about a page to answer each question. Clear Layout It is vitally important that your assignment is clearly laid out with questions and parts of questions clearly defined. It must be a straight forward matter for the examiner to determine that you have completed each exercise satisfactorily. We want quality not quantity. Poorly organised submissions will be rejected or receive a poor mark. A PDF/A document typeset using vanilla LATEX is preferred over a document produced by a word-processor. If you must use Microsoft Word or LibreOffice please export your document as PDF/A1 not PDF. Late Submission of Assignments2 Students can apply for an extension of time to submit an assignment at any time up to the deadline. Students are advised to make a request for an extension as soon as their need becomes apparent. Delay in making a request involves the risk of losing marks if the request is refused. The Examiner may grant a short extension of the deadline for submission of an assignment. Extensions are usually granted only in cases of Compassionate and Compelling Circumstances in accordance with the assessment of Compassionate and Compelling Circumstances Procedure. Generally, extensions will be limited to a maximum of five University Business Days. A Student requiring an extension for a period 1 PDF/A is an archival format of PDF that embeds all fonts used in the document within the PDF file. To ensure PDF/A format in Word check “ISO19005-compliant (PDF/A)” under “Options” when saving a file as PDF. 2 The full assessment rules and regulations can be found at http://policy. usq.edu.au/documents.php?id=14749PL http://policy.usq.edu.au/documents.php?id=131150PL http://policy.usq.edu.au/documents.php?id=131150PL http://policy.usq.edu.au/documents.php?id=131150PL http://policy.usq.edu.au/documents.php?id=131150PL http://policy.usq.edu.au/documents.php?id=131150PL http://policy.usq.edu.au/documents.php?id=131150PL http://policy.usq.edu.au/documents.php?id=131150PL http://policy.usq.edu.au/documents.php?id=131150PL http://policy.usq.edu.au/documents.php?id=131150PL http://policy.usq.edu.au/documents.php?id=131150PL 2 of time in excess of this should consider applying for a Deferred Assessment as per Section 4.4 of the assessment procedure. Applications for extensions must be made via email or USQAssist to the Examiner together with accompanying documentation as specified in the Assessment of Compassionate and Compelling Circumstances Procedure. An Assignment submitted after the deadline without an approved extension of time will be penalised. The penalty for late submission without a pre-approved extension is a reduction by 5% of the maximum mark applicable for the assignment, for each University business day or part business day that the assignment is late. An assignment submitted more than ten University business days after the deadline will have a mark of zero recorded for that assignment. The Examiner may refuse to accept assignments for assessment purposes after marked assignments and/or feedback have been released. Non-submission of Assignments and Passing Grades3 To be assured of receiving a passing grade a student must obtain at least 50% of the total weighted marks available for the course and have satisfied any Secondary Hurdles (if applicable). Supplementary assessment may be offered where a student has undertaken all of the required summative assessment items and has passed the Primary Hurdle but failed to satisfy the Secondary Hurdle (Supervised), or has satisfied the Secondary Hurdle (Supervised) but failed to achieve a passing Final Grade by 5% or less of the total weighted Marks. To be awarded a passing grade for a supplementary assessment item (if applicable), a student must achieve at least 50% of the available marks for the supplementary assessment item as per the Assessment Procedure (point 4.4.2). The offer of Supplementary Assessment normally will only be made if the Student has undertaken all possible Summative Assessment Items for the Course (i.e. the assignments). Student Responsibilities The Assessment Procedure Section 4.2.2, also outlines the following student responsibilities: • If requested, Students must be capable of providing a copy of Assignments submitted. Copies should be dispatched to the University within 24 hours of receipt of a request being made. 3 See the University Assessment Procedure policy document http://policy.usq.edu.au/documents.php?id=14749PL http://policy.usq.edu.au/documents.php?id=14749PL https://usqassist.custhelp.com/ https://usqassist.custhelp.com/ http://policy.usq.edu.au/documents/14749PL http://policy.usq.edu.au/documents.php?id=14749PL http://policy.usq.edu.au/documents.php?id=14749PL 3 • Students are responsible for submitting the correct Assignment. • Assignment submissions must contain evidence of student effort to address the requirements of the Assignment. In the absence of evidence of Student effort to address the requirements of the assignment, no Mark will be recorded for that Assessment Item. • A Student may re-submit an Assignment at any time up to the deadline. A request to re-submit after the deadline is dealt with in accordance with section 4.4 ‘Deferred, Supplementary and Varied Assessment and Special Consideration’ of these procedures. Academic Misconduct Academic misconduct is unacceptable and includes plagiarism, collusion and cheating: plagiarism : involves the use of another person’s work without full and clear referencing and acknowledgement; cheating : involves presenting another student’s work as your own; collusion : is a specific type of cheating, that occurs when two or more students fail to abide by directions from the examiner regarding the permitted level of collaboration on an assessment. All are seen by the University as acts of misconduct for which you can be penalised. For further details go to the Library’s site on Plagiarism. http://www.usq.edu.au/library/referencing/plagiarism http://www.usq.edu.au/library/referencing/plagiarism (marks 25) 4 Question 1 Answer the following questions: 6 marks a. Given five memory partitions (in order) of 100 KiB, 500 KiB, 200 KiB, 300 KiB, and 600 KiB, how would each of the firstfit, best- fit, and worst-fit algorithms place processes (in order) of 212 KiB, 417 KiB, 112 KiB, and 426 KiB? Which algorithm makes the most efficient use of memory? b. Assume a 32 bit system, with a 2-level page table, with a page size of 4KiB (p1=10bits, p2=10bits, offset=12bits). 6 marks (i) A program on this system requires 16MiB in total: the program text segment uses 4MiB, the program data requires 2MiB, the program dynamically allocates 8MiB on the heap, and the stack utilises 2MiB. How many page-table pages are required for this process? (Don’t answer with just a number, explain your reasoning. Without your reasoning we cannot award part marks if your answer is incorrect.) 6 marks (ii) Describe the lookup steps within the page tables to find the physical address of the logical address 0x00403004. (iii) If the reference time to access the physical memory frame is 20 nanoseconds. Assume that all required pages are in memory. How long does a paged memory reference take, if— 2 marks i. There is no TLB? 2 marks ii. There is a TLB, with an access speed of 0.05 nanoseconds, but the TLB does not contain information on the required page? 3 marks iii. There is a TLB, with an access speed of 0.05 nanoseconds, and the TLB contains information on this page? (Do not answer with just a number, explain your reasoning. Without your reasoning we cannot award part marks if your answer is incorrect.) (marks 25) 5 Question 2 A file is to be shared among different processes. The file can be accessed simultaneously by more than one process, up to a maximum of 9 processes. In pseudo-code write a monitor to coordinate access to the file. For example: FileMonitor M; int main() { ... M.RequestAccess(); /* Access file: open, read, close, etc. */ M.FinishedAccess(); ... } Monitor FileMonitor { /* monitor variables here */ void RequestAccess() { /* Code here */ } void FinishedAccess() { /* Code here */ } } The monitor pseudo-code needs to define monitor variables and the monitor functions. Notes • This is pseudo-code and not meant to be compiled and run. You will need to check the logic though. • This is a monitor so mutual-exclusion is assured and does not need to be incorporated in the code. • Assume that the monitor uses Mesa condition variables. (marks 25) 6 • As a starting point study Figure 6.14 (Ed. 9 Figure 5.19) from the text book (Operating System Concepts, Silberschatz et el.). Question 3 Consider a program modelling a railway marshalling yard with two sidings: one siding is for Container Wagons and one is for Coal Trucks. The program has one Engine thread, and potentially many Wagon threads (one for each wagon) and potentially many Truck threads (one for each truck). The Engine thread waits until there are sufficient Wagons or Trucks to shunt. The Engine thread calls the method shuntWagons() if Wagons are to be shunted and/or the method shuntTrucks() if Trucks are to be shunted. For efficiency and because of the design of the yard the shunting engine will wait until there are 15 Container Wagons to move and/or there are 10 Coal Trucks to move. In pseudo-code, and using semaphores for synchronisation, write the procedure EngineThread() that will call the pre-written procedures: shuntTrucks() and shuntWagons(). Also write the procedures WagonThread() and TruckThread(), that need to wake-up the Engine thread when there are sufficient trucks or wagons to shunt. As a starting point use the code below. Remember: All Semaphores and variables must be initialised. The pseudo-code below declares variables, but it does not initialise them. 7 void shuntTrucks() { /* Code to shunt 10 Trucks - do not touch */ } void shuntWagons() { /* Code to shunt 15 Wagons - do not touch */ } /* Shared Data between all processes */ Semaphore engineSleep; Semaphore mutex; int numWagons; int numTrucks; EngineThread() { while (True) { /* Your synchronisation pseudo-code here */ } } WagonThread() { /* Your synchronisation pseudo-code here */ } TruckThread() { /* Your synchronisation pseudo-code here */ } Question 4 (marks