User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin...
-
Upload
audra-blair -
Category
Documents
-
view
214 -
download
1
Transcript of User-level Memory Management Supervisor: Joe Cordina Co-Supervisor: Kurt Debattista Observer: Kevin...
User-level Memory Management
Supervisor: Joe CordinaCo-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
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.
User-level Memory Management 4Joe Cordina
Literature Operating Systems Book
(Dinosaur) Operating Systems Slides C Programming Book Internet Resources
User-level Memory Management 5Joe Cordina
Assessment
50% Design/Implementation 30% Documentation/Inception
Report 20% Presentation/Interview
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
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
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.
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
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
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.
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;
}
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;
}
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.
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.
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
User-level Memory Management 17Joe Cordina
Presentation 15 minute presentation
Choice of material Knowledge of subject Clarity
Interview Answer questions related to APT
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
User-level Memory Management 19Joe Cordina
The end
All the best! Good luck! Work hard!