user-level memory management supervisor: joe cordina co-supervisor: kurt debattista observer: kevin...

19
User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

Upload: audra-blair

Post on 11-Jan-2016

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management

Supervisor: Joe CordinaCo-Supervisor: Kurt Debattista

Observer: Kevin Vella

Page 2: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 2Joe Cordina

APT Advanced practical task serve the

purpose of allowing students to design, implement and document a medium to large project Student initiative Understand task + design Research into possible solutions Work alone under supervisor’s guidance

Page 3: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 3Joe Cordina

Overview

Improving memory access and allocation/de-allocation through the design and implementation of a user-level memory management library.

Page 4: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 4Joe Cordina

Literature Operating Systems Book

(Dinosaur) Operating Systems Slides C Programming Book Internet Resources

Page 5: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 5Joe Cordina

Assessment

50% Design/Implementation 30% Documentation/Inception

Report 20% Presentation/Interview

Page 6: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 6Joe Cordina

Main issues of APT Implementation

Library providing user level memory access

Provides an efficient internal memory management

Reduce System calls Eliminate Page Faults Basic SMP support

Example programs with benchmark results

Page 7: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 7Joe Cordina

User Level Management Library Has to provide the following

system calls: void *umalloc(int bytes); int ufree(void *ptr);

Provisions have to be made for reporting error messages

Has to cater for page faults

Page 8: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 8Joe Cordina

System Calls All system calls into the kernel are

expensive. Thus we try to use all memory

allocation and de-allocation at the user level.

Page 9: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 9Joe Cordina

Page Faults When user calls malloc(), an area of memory if

assigned to the process but this assignment is logical until the first byte is written.

When the first byte is written, a page fault occurs which assigns the page into physical memory.

This page fault has overheads which should be eliminated

A page fault also occurs when a process tries to access a page which has been swapped out of memory

Page 10: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 10Joe Cordina

Page Faults (cont.) To eliminate page faults one can use

one of the following: Write to the memory page on initializing of

the memory management library Use mlock() which does not guarantee

consecutive memory allocation and needs root access.

int mlock(const void *addr, size_t len); Use the bigphysarea patch or something

similar

Page 11: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 11Joe Cordina

SMP Support When using clone(), a new process is created which

resides and shares the same user space as the parent. int clone(int (*fn)(void *arg), void *child_stack,

int flags, void *arg); Each new process can be allocated to a free processor. You should guarantee that your user level management

library can cater for simultaneous allocation. To avoid system calls we cannot use semaphores and

thus we make use of a spin lock. A spin lock busy waits on a shared variable until a

resource is marked as free.

Page 12: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 12Joe Cordina

SMP Support (cont.) Shared variables:

int allow;initially allow = 1

allow = 1 P can enter its critical section Process P

do {loop while (allow != 1) repeat while;allow=0;critical section;allow = 1;reminder section;

}

Page 13: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 13Joe Cordina

SMP Support (cont.) You will realize that a busy wait loop

could not set variables atomically and thus we need to make use of a Test-And-Set instruction (btsl).

Test and modify the content of a word atomically

boolean TestAndSet(boolean &target) {boolean rv = target;target = true;return rv;

}

Page 14: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 14Joe Cordina

Bonus Material Provide the following user level call

in your library void *getSM(int index)

that allocates a shared memory area of fixed size. Any call to this function with the same index will return a pointer to the same memory area.

Page 15: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 15Joe Cordina

Bonus Material Provide calls to allow Concurrent Read

and Exclusive Write access to the shared memory area.

Thus access to the area goes through the library calls (e.g. uswrite and usread) but allows many processes to read from the memory area but this access is denied once a process tries to write to this area.

This guarantees shared memory integrity.

Page 16: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 16Joe Cordina

Documentation Inception report (Thursday 28th

February) Analysis/Design Work plan

Report Detailed analysis of problem Discussion of solution (+ others considered) Detailed description of data structures and

algorithms used

Page 17: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 17Joe Cordina

Presentation 15 minute presentation

Choice of material Knowledge of subject Clarity

Interview Answer questions related to APT

Page 18: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 18Joe Cordina

Interaction Expect to report to supervisor

every other week: Thursday Who cannot attend must mail in

progress report + work in progress demo

First meeting Thursday 28th February

Page 19: User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin Vella

User-level Memory Management 19Joe Cordina

The end

All the best! Good luck! Work hard!