1. Homepage
  2. Programming
  3. [2021] PSU - CMPSC 473 Operating Systems - Project3 Event-driven Simulator

[2021] PSU - CMPSC 473 Operating Systems - Project3 Event-driven Simulator

Engage in a Conversation
PSUCMPSC 473Operating SystemsThe Pennsylvania State UniversityProgramming Help

Goals

The goals for this project are to help you: CourseNana.COM

  1. Get experience working with a trace-based event-driven simulator
  2. Get experience with a basic virtual memory management system (including MMU, TLB, DRAM, DRAM-resident multi-level page tables, page replacement algorithms, and swap device)
  3. Get experience with simulation-based performance evaluation

Project Overview

You will implement and experiment with a simple virtual memory manager (VMM) consisting of the following elements: (i) MMU, (ii) TLB, (iii) DRAM, (iv) DRAM-based multi-level page tables, and (iv) disk-based swap device. To do this, you will be given a simulator base code. If you have never worked with a simulator, do not worry. Much of the simulator functionality will be already implemented in  the base code allowing you to focus on ideas related to VMM. Additionally, be sure to check out a short video that has been uploaded in canvas announcements - wherein we describe all you need to know to quickly become familiar with the base code. CourseNana.COM

  CourseNana.COM

Our base code simulates multiple processes time-sharing a single CPU with the help of the operating system which implements a round-robin CPU scheduler. The code base has been written to work for processes that only execute non-memory instructions. For each simulated process, the simulator reads the instructions from an “input trace file” for that process. You will extend this to simulate the time-sharing of processes that also execute memory instructions (such as loads and stores) that access virtual addresses that need to be translated into their physical counterparts by the MMU. CourseNana.COM

As input, you will receive two types of files: input files and traces. These files are present in the ‘traces’ folder. CourseNana.COM

Where to find the simulator base code

  CourseNana.COM

The simulator base code is in the simulator.c file. You can compile it using the make command. Then, to run the simulator, you need to write the following command: CourseNana.COM

$ ./simulator input1.txt output1.txt CourseNana.COM

Where input1.txt is the input file and output1.txt will contain the output from running the simulator. CourseNana.COM

Simulator Inputs

Our simulator takes two types of inputs for each simulation (henceforth also called “experiment”): (i) system parameters and (ii) a scheduling trace for each process involved in the experiment. These inputs are specified within a file that is passed as a command line argument to the simulator. So for an input file called input1.txt, the simulator would be invoked as follows, where the output will be written to output1.txt. More details on compiling and running the simulator appear under “Using the Simulator”

$ ./simulator input1.txt output1.txt CourseNana.COM

 

The format of an input file is as follows: CourseNana.COM

  CourseNana.COM

# list of system parameters specified as parameter-descriptive-string parameter-value; (all latencies are in  units of a “cycle”) CourseNana.COM

# list of parameters that will remain the same across all experiments CourseNana.COM

Non-mem-inst-length 1 CourseNana.COM

Virtual-addr-size-in-bits 32 CourseNana.COM

DRAM-size-in-MB 4 CourseNana.COM

TLB-size-in-entries 16 CourseNana.COM

TLB-latency 1 CourseNana.COM

DRAM-latency 100 CourseNana.COM

Swap-latency 10000000 CourseNana.COM

Page-fault-trap-handling-time 10000 CourseNana.COM

Swap-interrupt-handling-time 10000 CourseNana.COM

TLB-type FullyAssociative CourseNana.COM

TLB-replacement-policy LRU CourseNana.COM

# list of parameters that may vary across experiments CourseNana.COM

P-in-bits 12 CourseNana.COM

Num-pagetable-levels 3 CourseNana.COM

N1-in-bits 8 CourseNana.COM

N2-in-bits 8 CourseNana.COM

N3-in-bits 4 CourseNana.COM

Page-replacement-policy LRU CourseNana.COM

Num-procs 3 CourseNana.COM

# trace-file-name arrival-time-of-process CourseNana.COM

process1 0 CourseNana.COM

process2 3 CourseNana.COM

process3 4 CourseNana.COM

  CourseNana.COM

The processes are in order, meaning that each process has a start time later than or equal to the previous start time. CourseNana.COM

Code for parsing this file will be provided with the functions openTrace(), closeTrace(), readNextTrace() and readSysParam() in fileIO.h/c files. CourseNana.COM

The traces are: “input1.txt”, “input2.txt”, …., “input10.txt”. CourseNana.COM

Process trace files contain a list of addresses accessed by a program. The process trace file names will correspond to trace-file-name.txt from input trace files. So in the above example the “input1.txt” points to the 3 process file - “process1.txt”, “process2.txt” and “process3.txt”. ‘Mem’ or ‘NonMem’ is used to define the type of instructions. CourseNana.COM

Here is an example of the first few lines within a process trace file: CourseNana.COM

  CourseNana.COM

Total-num-instr 1000000 CourseNana.COM

Mem 0x12f00C00 CourseNana.COM

Mem 0x77f46B77 CourseNana.COM

NonMem CourseNana.COM

Mem 0x7ffde001 CourseNana.COM

Mem 0x12f0015C CourseNana.COM

NonMem CourseNana.COM

Mem 0x77f3c000 CourseNana.COM

Mem 0x12f00C28 CourseNana.COM

NonMem CourseNana.COM

NonMem CourseNana.COM

NonMem CourseNana.COM

NonMem CourseNana.COM

Mem 0x12f00010 CourseNana.COM

Mem 0x12f0CC11 CourseNana.COM

Mem 0x12f00100C CourseNana.COM

Mem 0x77f3CDE1 CourseNana.COM

... CourseNana.COM

  CourseNana.COM

Code for parsing this file will be provided with the functions openTrace(), closeTrace(), readNumIns() and readNextMem() in fileIO.h/c files. CourseNana.COM

The process traces are available for each process in the traces: “process1.txt”, “process2..txt”, …., “process44.txt”. CourseNana.COM

 

 

Using the Base Simulator

  CourseNana.COM

We have simulated the Round Robin process scheduler in the schedulingRR() function. This is the only scheduler you need to work with. CourseNana.COM

  CourseNana.COM

The base code simulates NonMem instructions ONLY and generates the following upon the completion of an experiment: CourseNana.COM

  1. per-process completion time
  2. total number of context switches
  3. total amount of time spent in OS vs. total amount of time spent in user mode.

  CourseNana.COM

The current implementation works with “input1.txt” and “input10.txt” only which has all NONMEM instructions. CourseNana.COM

  CourseNana.COM

“input1.txt” has 3 processes: process1, process2  and process3. Each of these processes have 2, 2 and 3 NonMem instructions respectively. CourseNana.COM

  CourseNana.COM

Use the following commands to execute the simulator: CourseNana.COM

Make CourseNana.COM

./simulator input1.txt output1.txt
[here input1.txt is the trace parameter you wish to experiment with, output1.txt is the file name where the output will be written]
CourseNana.COM

  CourseNana.COM

Make clean will delete all object files. CourseNana.COM

  CourseNana.COM

The execution order of the processes in “input1” are: process1 → process2 → process3 → process2 → process3; where quanta = 5, nonMemReadTime = 2 and contextSwitchTime = 1. CourseNana.COM

  CourseNana.COM

The below diagram shows the execution order of the 3 processes in “input1”: CourseNana.COM

  CourseNana.COM

CourseNana.COM

What you need to do CourseNana.COM

  CourseNana.COM

You are required to append to this simulator to take care of all types of instructions and generate the following: [You can use traces 2-9 as reference to test your code] CourseNana.COM

  1. per-process completion time
  2. total number of context switches
  3. total number of disk interrupts
  4. per-process and total number of TLB misses (absolute and ratios)
  5. per-process and total number of page faults (absolute and ratios)
  6. per-process and total fraction of time in blocked state
  7. total amount of time spent in OS vs. total amount of time spent in user mode.

To that end, you would have to implement data structures for TLB and page table and include necessary functions and helper data structures. CourseNana.COM

You must assume that the swap device has sufficient capacity to accommodate the active address spaces in their entirety in any experiment. You will assume that the capacity needs of the page tables themselves are accommodated by main memory other than the DRAM that the simulator considers (but that it has similar latency characteristics). You will ignore the main memory needs of the page tables themselves in your simulation of DRAM usage. You will assume that all the memory instructions in the trace files reference valid virtual addresses and, therefore, do not raise traps. All page table entries must be aligned to 4 Bytes. Besides the PPN, you only need to consider the valid bit within a PTE. All of these other PTE entries in a real page table are to be ignored: permissions, user/kernel, dirty, reference. CourseNana.COM

  CourseNana.COM

Provided Code Structure

      dataStructures.h file contains the structs used in this project. You can add other structures here. CourseNana.COM

      fieIO.h/c file contains the helper functions for reading the traces. CourseNana.COM

      gll.h/c contains a linked list implementation for ease. It has been used in the existing code and you are welcome to use it for your linked list implementation. CourseNana.COM

      simulator.h/c contains the code for the simulator. You are expected to include your implementation in this file. There are //TODO instructions that give you some guidance about adding your implementation specific values in existing functions. You are expected to determine how to include your implementation yourself. CourseNana.COM

      init() initializes all the data structures and list of processes. processList is the list of all processes. Any process that becomes ready to run is moved to readyProcess list. The process that should run right now is moved to runningProcess list. You should initialize your necessary variables/data structures here. CourseNana.COM

      simulate() function is the simulator which loops through all the processes until all of them are done. It calls the processSimulator() function in a loop. processSimulator() simulates the running process until one of these things  happen- timer interrupt, disk interrupt, page fault, process finishes. processSimulator() calls readIns() function that reads the next instruction for the running process. You have to handle “MEM” instructions in readIns() function. CourseNana.COM

      diskToMemory() function moves one page from disk to memory. You have to implement it. CourseNana.COM

To implement these functions, you will need to implement TLB and page table along with MMU and swapping logic. You would also need to implement multiple page replacement algorithms(described in next section). CourseNana.COM

      Recommended order of implementation: CourseNana.COM

      MMU, DRAM, swap device, Page table only with no TLB CourseNana.COM

      Add TLB CourseNana.COM

      Performance evaluation CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
PSU代写,CMPSC 473代写,Operating Systems代写,The Pennsylvania State University代写,Programming Help代写,PSU代编,CMPSC 473代编,Operating Systems代编,The Pennsylvania State University代编,Programming Help代编,PSU代考,CMPSC 473代考,Operating Systems代考,The Pennsylvania State University代考,Programming Help代考,PSUhelp,CMPSC 473help,Operating Systemshelp,The Pennsylvania State Universityhelp,Programming Helphelp,PSU作业代写,CMPSC 473作业代写,Operating Systems作业代写,The Pennsylvania State University作业代写,Programming Help作业代写,PSU编程代写,CMPSC 473编程代写,Operating Systems编程代写,The Pennsylvania State University编程代写,Programming Help编程代写,PSUprogramming help,CMPSC 473programming help,Operating Systemsprogramming help,The Pennsylvania State Universityprogramming help,Programming Helpprogramming help,PSUassignment help,CMPSC 473assignment help,Operating Systemsassignment help,The Pennsylvania State Universityassignment help,Programming Helpassignment help,PSUsolution,CMPSC 473solution,Operating Systemssolution,The Pennsylvania State Universitysolution,Programming Helpsolution,