Interactive 3D Visualisation of Meteorological Data

Download Report

Transcript Interactive 3D Visualisation of Meteorological Data

User-level Memory
Management
Supervisor: Joe Cordina
Co-Supervisor: Kurt Debattista
Observer: Kevin Vella
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
User-level Memory Management
Joe Cordina
2
Overview

Improving memory access and
allocation/de-allocation through the
design and implementation of a userlevel memory management library.
User-level Memory Management
Joe Cordina
3
Literature




Operating Systems Book (Dinosaur)
Operating Systems Slides
C Programming Book
Internet Resources
User-level Memory Management
Joe Cordina
4
Assessment



50% Design/Implementation
30% Documentation/Inception Report
20% Presentation/Interview
User-level Memory Management
Joe Cordina
5
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
User-level Memory Management
Joe Cordina
6
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
User-level Memory Management
Joe Cordina
7
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.
User-level Memory Management
Joe Cordina
8
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
User-level Memory Management
Joe Cordina
9
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
User-level Memory Management
Joe Cordina
10
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.
User-level Memory Management
Joe Cordina
11
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;
}
User-level Memory Management
Joe Cordina
12
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;
}
User-level Memory Management
Joe Cordina
13
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.
User-level Memory Management
Joe Cordina
14
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.
User-level Memory Management
Joe Cordina
15
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
User-level Memory Management
Joe Cordina
16
Presentation

15 minute presentation




Choice of material
Knowledge of subject
Clarity
Interview

Answer questions related to APT
User-level Memory Management
Joe Cordina
17
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
User-level Memory Management
Joe Cordina
18
The end



All the best!
Good luck!
Work hard!
User-level Memory Management
Joe Cordina
19