Project 2 - Kernel Memory Allocation

Similar documents
Memory Management. To do. q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory

Memory Management. q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory

Memory Management. Today. Next Time. Basic memory management Swapping Kernel memory allocation. Virtual memory

ENGR 3950U / CSCI 3020U (Operating Systems) Simulated UNIX File System Project Instructor: Dr. Kamran Sartipi

Project #1: Tracing, System Calls, and Processes

CSCI 2021, Fall 2018 Malloc Lab: Writing a Dynamic Storage Allocator Assigned: Monday November 5th Due: Monday November 19th, 11:55PM

The print queue was too long. The print queue is always too long shortly before assignments are due. Print your documentation

CS164: Programming Assignment 5 Decaf Semantic Analysis and Code Generation

Project 4: Implementing Malloc Introduction & Problem statement

A4: HTML Validator/Basic DOM Operation

CS Programming Languages Fall Homework #2

CS 361S - Network Security and Privacy Spring Project #2

15-213/18-213/15-513, Fall 2017 C Programming Lab: Assessing Your C Programming Skills

Data Structure and Algorithm Homework #3 Due: 2:20pm, Tuesday, April 9, 2013 TA === Homework submission instructions ===

Programming Assignment #4

1. Mark-and-Sweep Garbage Collection

Machine Problem 1: A Simple Memory Allocator

CS 3214, Fall 2015 Malloc Lab: Writing a Dynamic Storage Allocator Due date: November 16, 2014, 11:59pm

Project 3a: Malloc and Free

CS 213, Fall 2002 Malloc Lab: Writing a Debugging Dynamic Storage Allocator Assigned: Fri Nov. 1, Due: Tuesday Nov. 19, 11:59PM

CSE 351, Spring 2010 Lab 7: Writing a Dynamic Storage Allocator Due: Thursday May 27, 11:59PM

15-213/18-213/15-513, Spring 2018 C Programming Lab: Assessing Your C Programming Skills

CS 2505 Fall 2013 Data Lab: Manipulating Bits Assigned: November 20 Due: Friday December 13, 11:59PM Ends: Friday December 13, 11:59PM

CSE 361S Intro to Systems Software Final Project

ICS(II), Fall 2017 Cache Lab: Understanding Cache Memories Assigned: Thursday, October 26, 2017 Due: Sunday, November 19, 2017, 11:59PM

Programming Project 4: COOL Code Generation

Programming Assignment IV Due Thursday, November 18th, 2010 at 11:59 PM

MCS-284, Fall 2018 Cache Lab: Understanding Cache Memories Assigned: Friday, 11/30 Due: Friday, 12/14, by midnight (via Moodle)

EECS 470 Midterm Exam Winter 2008 answers

Lab 1: Dynamic Memory: Heap Manager

Project 5 Handling Bit Arrays and Pointers in C

Spring 2016, Malloc Lab: Writing Dynamic Memory Allocator

CS 361S - Network Security and Privacy Spring Project #2

CS 241 Data Organization using C

Assignment 5. CS/ECE 354 Spring 2016 DUE: April 22nd (Friday) at 9 am

CS 105 Malloc Lab: Writing a Dynamic Storage Allocator See Web page for due date

The UtePC/Yalnix Memory System

OPERATING SYSTEMS ASSIGNMENT 3 MEMORY MANAGEMENT

COMP 321: Introduction to Computer Systems

Important Project Dates

CSE 361 Fall 2017 Malloc Lab: Writing a Dynamic Storage Allocator Assigned: Monday Nov. 13, Due: Monday Dec. 05, 11:59PM

Project 1. 1 Introduction. October 4, Spec version: 0.1 Due Date: Friday, November 1st, General Instructions

CS 2505 Fall 2018 Data Lab: Data and Bitwise Operations Assigned: November 1 Due: Friday November 30, 23:59 Ends: Friday November 30, 23:59

CSE 361 Fall 2017 Lab Assignment L2: Defusing a Binary Bomb Assigned: Wednesday Sept. 20 Due: Wednesday Oct. 04 at 11:59 pm

CS155: Computer Security Spring Project #1

CS 1550 Project 3: File Systems Directories Due: Sunday, July 22, 2012, 11:59pm Completed Due: Sunday, July 29, 2012, 11:59pm

Shell Project, part 3 (with Buddy System Memory Manager) ( points)

University of Colorado at Colorado Springs CS4500/ Fall 2018 Operating Systems Project 1 - System Calls and Processes

Project #1 Exceptions and Simple System Calls

Homework # 7 DUE: 11:59pm November 15, 2002 NO EXTENSIONS WILL BE GIVEN

CSE 361S Intro to Systems Software Lab #4

Project 2: Shell with History1

Programming Tips for CS758/858

Forest Fire Simulation Using Multiple Processes and Pipes

Writing a Dynamic Storage Allocator

Project Introduction

Overview of Project V Buffer Manager. Steps of Phase II

CS155: Computer Security Spring Project #1. Due: Part 1: Thursday, April pm, Part 2: Monday, April pm.

CMSC 423 Fall 2009: Project Specification

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Compiling Your Code and Running the Tests

Programming Assignment #4 Arrays and Pointers

CS 385 Operating Systems Fall 2011 Homework Assignment 5 Process Synchronization and Communications

CS 344/444 Spring 2008 Project 2 A simple P2P file sharing system April 3, 2008 V0.2

,879 B FAT #1 FAT #2 root directory data. Figure 1: Disk layout for a 1.44 Mb DOS diskette. B is the boot sector.

1 Introduction. 2 Logistics. 3 Hand Out Instructions

CS 105 Malloc Lab: Writing a Dynamic Storage Allocator See Web page for due date

HOT-Compilation: Garbage Collection

15-441: Computer Networks - Project 3 Reliability and Congestion Control protocols for MPEG

Data Networks Project 3: Implementing Intra-Domain Routing Protocols

ECE454, Fall 2014 Homework3: Dynamic Memory Allocation Assigned: Oct 9th, Due: Nov 6th, 11:59PM

It is academic misconduct to share your work with others in any form including posting it on publicly accessible web sites, such as GitHub.

ECEn 424 Data Lab: Manipulating Bits

Hands on Assignment 1

Compilers Project 3: Semantic Analyzer

ANITA S SUPER AWESOME RECITATION SLIDES

Practical 2: Ray Tracing

CSCI544, Fall 2016: Assignment 1

HW 3: Malloc CS 162. Due: Monday, March 28, 2016

CMPE 655 Fall 2016 Assignment 2: Parallel Implementation of a Ray Tracer

BIL220, Spring 2012 Data Lab: Manipulating Bits Assigned: Feb. 23, Due: Wed., Mar. 8, 23:59PM

COMP 3500 Introduction to Operating Systems Project 5 Virtual Memory Manager

This is an open book, open notes exam. But no online or in-class chatting.

CS5401 FS Solving NP-Complete Light Up Puzzle

CS168 Programming Assignment 2: IP over UDP

CS143 Handout 05 Summer 2011 June 22, 2011 Programming Project 1: Lexical Analysis

In Java we have the keyword null, which is the value of an uninitialized reference type

Lectures 13 & 14. memory management

Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time)

15-122: Principles of Imperative Computation, Fall 2015

Due: Tuesday 29 November by 11:00pm Worth: 8%

Lab 09 - Virtual Memory

Lecture 14 Notes. Brent Edmunds

NOTE: Your grade will be based on the correctness, efficiency and clarity.

Introduction. Overview and Getting Started. CS 161 Computer Security Lab 1 Buffer Overflows v.01 Due Date: September 17, 2012 by 11:59pm

SEE2030: Introduction to Computer Systems (Fall 2017) Programming Assignment #2:

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

CS 161 Computer Security

Dictionary Wars CSC 190. March 14, Learning Objectives 2. 2 Swiper no swiping!... and pre-introduction 2

CMU : Advanced Computer Architecture Handout 5: Cache Prefetching Competition ** Due 10/11/2005 **

Transcription:

Project 2 - Kernel Memory Allocation EECS 343 - Fall 2014 Important Dates Out: Monday October 13, 2014 Due: Tuesday October 28, 2014 (11:59:59 PM CST) Project Overview The kernel generates and destroys small tables and buffers frequently during the course of execution, each of which requires dynamic memory allocation. Since most of the needed blocks are smaller than the typical machine page size, the page-level allocator is inappropriate for the task and a separate mechanism is used instead: the kernel memory allocator. In this project you will implement, evaluate and compare a set of common allocation methods for use in a kernel memory allocator. Educational Objectives By the end of the project you should have a better grasp of some of the issues involved in memory management, in particular in the context of the kernel and the kernel memory allocator. Background The operating system must manage all the physical memory and allocate it to both other kernel subsystems and to user-level processes. At boot time the kernel reserves some memory for its own text and static data structures. The rest of memory is managed dynamically the kernel allocates portions of memory to its various clients, which release it when they no longer need it. In a page-based virtual memory system, the memory management subsystem maintains the mapping between virtual and physical pages. In SVR4, for example, the page-level allocator is implemented by the get page() and freepage() routines. The page-level allocator has two principal clients: the paging system which is part of the virtual memory system and allocates pages to user processes, and the kernel memory allocator. The kernel memory allocator (KMA) provides odd-sized buffers of memory to various kernel subsystems. Some example users of the KMA includes the pathname translation routine, which needs to allocate a buffer to copy the pathname from user space, and routines for creating/deleting PCB entries. Since most of these requests are much smaller than a page, the page-level allocator is inappropriate for the task and a separate mechanism is needed. 1

Some of the best KMA implementations allow for dynamic changes in the amount of memory allocated to the KMA. Thus, if the KMA runs out of memory it can just request an additional page from the page-level allocator. For this project, all your implementations will interact with the page-level allocator. Specification For this project you will implement, evaluate and compare the Resource Map and Buddy System algorithms. The correctness of your implementation of these two algorithms is worth a total of 90 points, accounting for all of the basic points. The evaluation report, described later in this section, is worth 10 points. Correct implementations of the extra credit algorithms will give you the specified number of extra credit points added to your score. Resource Map: You can choose between first-fit, best-fit or worst-fit (required: 45 points). Buddy System: For both Buddy systems (basic and lazy), use the same range of sizes (required: 45 points). SVR4 Lazy Buddy: Use the slack values discussed in the handout and only one memory pool (instead of two as employed in the SVR4 implementation) (extra credit: 15 points). Power-of-two Free List: The number and sizes of free lists is your choice (extra credit: 15 points). McKusick-Karels: For your implementation replace those tasks commonly implemented by macros by their C versions (extra credit: 20 points). Each of your KMA implementations will consist of the following two functions (notice that some algorithms will ignore the size argument passed on to free): void* kma_malloc (kma_size_t size) void kma_free (void* ptr, kma_size_t size) Your KMA implementations will use the provided page-level allocator to request new pages, free pages not needed, and report statistics on page usage including number of pages requested/freed/in-use. The provided page-level allocator (kma page.[hc]) implements the following interface: kma_page_t* get_page() void free_page(kma_page_t* page) kma_page_stat_t* page_stats() To get you started, we are providing you with an example algorithm, Dummy. The example algorithm, appropriately named, dummy KMA (kma dummy.[hc]) allocates a full page for any request (smaller than a page in size), independently of the size requested. To see Dummy in action you can simply make kma dummy and run it (./kma dummy testsuite/1.trace). If you run it using (time (1)) with the option for the portable output format ( time -p./kma dummy testsuite/1.trace ) your output will be similar to this (see time (1) s man page for an explanation of the real, user and sys values): [fabianb@localhost kma]\$ time -p./kma_dummy testsuite/1.trace Page Requested/Freed/In Use: 1497/ 1497/ 0 real 0.02 user 0.01 sys 0.00 2

In addition to the different KMA implementations, your submission should include a final report comparing the implemented algorithms based on their utilization factor (ratio of total memory requested to that needed to satisfy the request) and their (worst/average) free/alloc latencies (you will have to instrument your own code to obtain these timing values). Please include a justification for your claimed worst/average performances with respect to each algorithm s design. This report should go in the DOC file included with the skeleton distribution. Testing your code To test your code, we have provided a driver program (kma.[hc]) that accepts as an argument a trace file containing a sequence of allocation and free commands. We will use the included 5 trace files (of increasing difficulty and duration) in the skeleton s testsuite directory to test the correctness of your implementations when you submit your project. You must correctly complete all of the given 5 traces to receive the points for that algorithm. We have also included a script to create additional trace files: testsuite/generate trace. Run it with no arguments to see the options. When you generate a trace, it will plot (with gnuplot, if available 1 ) the number of allocated bytes over the course of the trace. When you are running in non-competition mode, the driver will output a data file that records, at every step in the trace, the current allocated and the number of bytes (pages page size) allocated by your algorithm. Run make analyze to generate the kma output.png (bytes allocated plot) and kma waste.png (inefficiency) plots. The testsuite will also run the testsuite/5.trace file against your selected competition algorithm, so you can know how your algorithm is doing with respect to run time and efficiency. Answers to common questions You don t need to serve requests for buffers larger than about a page size (just return NULL). You are allowed to have one static variable to store a pointer to a kma page t struct to serve as an entry point into your data structures. All other state must be stored in stack variables and in pages returned by get page. You are not allowed to use malloc to obtain any memory. You must request memory for your algorithm s internal data structures using the provided get page and free page interface. You must dynamically manage your control data structures. That is, you cannot preallocate several pages to hold, for example, your buffersize arrays. You will need a method to grow these arrays with the number of requests. We test this by limiting the number of the pages to a smaller size so that you will run out of pages when you preallocated everything in advance. (Or, you can preallocate, but need a method to free them when you run out of space. In any event, you need to dynamically manage the size.) For Extra Points There are two ways to get extra points in this project. 1. You can implement more algorithms from the given list. (Obviously, your implementations must be correct.) (You should clearly indicate those algorithms submitted for extra points in your evaluation report). 1 You can install gnuplot on the VM with sudo apt-get install gnuplot-x11. This is optional. 3

2. You can enter the performance contest with one of your implementations. You propose a contender (specify the executable name in caps e.g. KMA DUMMY in the COMPETITION variable in the Makefile) that will be compared with other teams submissions. Your algorithm will be evaluated on a combined factor of overall runtime and memory efficiency: Performance = Runtime (1 + Inefficiency Penalty) (1) Inefficiency Penalty = n 1 i=0 p i s b i b i n 1 Where n is the number of calls to kma malloc or kma free in the trace file and s is the page size. p i is the number of pages allocated through get page and b i is the number of bytes currently allocated through kma malloc, after the ith event in the trace. This penalty evaluates your algorithm s average ratio between wasted and used memory. To enter the competition, your algorithm must correctly execute all provided traces. The 5th trace file will be used as the competition workload. When you get an algorithm working, submit an intermediate version of the project! We will post a scoreboard of the top scoring submissions on the website. We encourage you to submit versions of your projects as you work so you can see how you are doing against other teams. Each team will only be listed once at a time on the scoreboard, and subsequent project submissions will overwrite the previous performance score. The top scoring team will get 50 extra points, the next two teams (2nd and 3rd place) will receive 25 points each, and the next two teams (4th and 5th place) will get 15 extra points each. (2) Grading To evaluate the correctness of your implementations, we will run the 5 traces that are included with the skeleton for each algorithm. We will also inspect your code and evaluate your final report. Correct implementations of the algorithms are each worth their given number of points (see list above). We will deduct points for the following reasons: 100 points!: It doesn t compile when we type make up to 10 points: no documentation (DOC file) up to 5 points per algorithm: poorly self-documented/commented code 2 points per compiler warning If you hand in your project late, we will deduct 10% from your final score per day or portion thereof. We will not accept submissions that are more than three days late. Deliverables and hand-in instructions Please beware, your hand-in code should run on any of the distributed virtual machine image without any modifications. The deliverables for this project are: 4

1. Source code. 2. Evaluation report (DOC file) including your comparative analysis, as well as a description of any important design decisions you made while implementing the different allocation methods compared. Please make sure that these files are included in the handin. 3. If you attempted to pass the extra credit test cases, please make a note of it in your DOC file. To hand-in your projects: Set your team name in Makefile: replace whoami with yournetid1+yournetid2 for the TEAM variable. Invoke make test-reg, which builds the deliverable tar.gz and runs the test cases. If and only if the test cases terminate, you may submit the handin. Submission will be done through the dedicated webpage (which you can reach from the course site). You can re-submit the project as many times as you want before the deadline; simply follow the same procedure. A few minutes after submitting your handin on the submission site, you will receive an email confirming your submission, with the output of the testsuite running on our submission server. If you haven t received a confirmation within an hour, contact the TA to verify that your submission was received. Good luck! 5