Index: doc/theses/mubeen_zulfiqar_MMath/Makefile
===================================================================
--- doc/theses/mubeen_zulfiqar_MMath/Makefile	(revision ba897d2136bc02c8b8a01751cd212c9a145a8df7)
+++ doc/theses/mubeen_zulfiqar_MMath/Makefile	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
@@ -1,44 +1,49 @@
-# directory for latex clutter files
+# Configuration variables
+
 Build = build
 Figures = figures
 Pictures = pictures
+
+LaTMac = ../../LaTeXmacros
+BibRep = ../../bibliography
+
 TeXSRC = ${wildcard *.tex}
 FigSRC = ${notdir ${wildcard ${Figures}/*.fig}}
 PicSRC = ${notdir ${wildcard ${Pictures}/*.fig}}
-BIBSRC = ${wildcard *.bib}
-TeXLIB = .:../../LaTeXmacros:${Build}: # common latex macros
-BibLIB = .:../../bibliography # common citation repository
+BibSRC = ${wildcard *.bib}
+
+TeXLIB = .:${LaTMac}:${Build}:
+BibLIB = .:${BibRep}:
 
 MAKEFLAGS = --no-print-directory # --silent
 VPATH = ${Build} ${Figures} ${Pictures} # extra search path for file names used in document
 
-### Special Rules:
+DOCUMENT = uw-ethesis.pdf
+BASE = ${basename ${DOCUMENT}}			# remove suffix
 
-.PHONY: all clean
-.PRECIOUS: %.dvi %.ps # do not delete intermediate files
-
-### Commands:
+# Commands
 
 LaTeX = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex -halt-on-error -output-directory=${Build}
-BibTeX = BIBINPUTS=${BibLIB} bibtex
+BibTeX = BIBINPUTS=${BibLIB} && export BIBINPUTS && bibtex
 #Glossary = INDEXSTYLE=${Build} makeglossaries-lite
 
-### Rules and Recipes:
+# Rules and Recipes
 
-DOC = uw-ethesis.pdf
-BASE = ${DOC:%.pdf=%} # remove suffix
+.PHONY : all clean				# not file names
+.PRECIOUS: %.dvi %.ps # do not delete intermediate files
+.ONESHELL :
 
-all: ${DOC}
+all : ${DOCUMENT}
 
-clean:
-	@rm -frv ${DOC} ${Build}
+clean :
+	@rm -frv ${DOCUMENT} ${Build}
 
-# File Dependencies #
+# File Dependencies
 
-${Build}/%.dvi : ${TeXSRC} ${FigSRC:%.fig=%.tex} ${PicSRC:%.fig=%.pstex} ${BIBSRC} Makefile | ${Build}
+%.dvi : ${TeXSRC} ${FigSRC:%.fig=%.tex} ${PicSRC:%.fig=%.pstex} ${BibSRC} ${BibRep}/pl.bib ${LaTMac}/common.tex Makefile | ${Build}
 	${LaTeX} ${BASE}
 	${BibTeX} ${Build}/${BASE}
 	${LaTeX} ${BASE}
-	# if nedded, run latex again to get citations
+	# if needed, run latex again to get citations
 	if fgrep -s "LaTeX Warning: Citation" ${basename $@}.log ; then ${LaTeX} ${BASE} ; fi
 #	${Glossary} ${Build}/${BASE}
@@ -46,5 +51,5 @@
 
 ${Build}:
-	mkdir $@
+	mkdir -p $@
 
 %.pdf : ${Build}/%.ps | ${Build}
Index: doc/theses/mubeen_zulfiqar_MMath/allocator.tex
===================================================================
--- doc/theses/mubeen_zulfiqar_MMath/allocator.tex	(revision ba897d2136bc02c8b8a01751cd212c9a145a8df7)
+++ doc/theses/mubeen_zulfiqar_MMath/allocator.tex	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
@@ -1,150 +1,330 @@
 \chapter{Allocator}
 
-\section{uHeap}
-uHeap is a lightweight memory allocator. The objective behind uHeap is to design a minimal concurrent memory allocator that has new features and also fulfills GNU C Library requirements (FIX ME: cite requirements).
-
-The objective of uHeap's new design was to fulfill following requirements:
-\begin{itemize}
-\item It should be concurrent and thread-safe for multi-threaded programs.
-\item It should avoid global locks, on resources shared across all threads, as much as possible.
-\item It's performance (FIX ME: cite performance benchmarks) should be comparable to the commonly used allocators (FIX ME: cite common allocators).
-\item It should be a lightweight memory allocator.
-\end{itemize}
+This chapter presents a new stand-alone concurrent low-latency memory-allocator ($\approx$1,200 lines of code), called llheap (low-latency heap), for C/\CC programs using kernel threads (1:1 threading), and specialized versions of the allocator for the programming languages \uC and \CFA using user-level threads running over multiple kernel threads (M:N threading).
+The new allocator fulfills the GNU C Library allocator API~\cite{GNUallocAPI}.
+
+
+\section{llheap}
+
+The primary design objective for llheap is low-latency across all allocator calls independent of application access-patterns and/or number of threads, \ie very seldom does the allocator have a delay during an allocator call.
+(Large allocations requiring initialization, \eg zero fill, and/or copying are not covered by the low-latency objective.)
+A direct consequence of this objective is very simple or no storage coalescing;
+hence, llheap's design is willing to use more storage to lower latency.
+This objective is apropos because systems research and industrial applications are striving for low latency and computers have huge amounts of RAM memory.
+Finally, llheap's performance should be comparable with the current best allocators (see performance comparison in \VRef[Chapter]{c:Performance}).
+
+% The objective of llheap's new design was to fulfill following requirements:
+% \begin{itemize}
+% \item It should be concurrent and thread-safe for multi-threaded programs.
+% \item It should avoid global locks, on resources shared across all threads, as much as possible.
+% \item It's performance (FIX ME: cite performance benchmarks) should be comparable to the commonly used allocators (FIX ME: cite common allocators).
+% \item It should be a lightweight memory allocator.
+% \end{itemize}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+<<<<<<< HEAD
 \section{Design choices for uHeap}\label{sec:allocatorSec}
 uHeap's design was reviewed and changed to fulfill new requirements (FIX ME: cite allocator philosophy). For this purpose, following two designs of uHeapLmm were proposed:
-
-\paragraph{Design 1: Centralized}
-One heap, but lower bucket sizes are N-shared across KTs.
-This design leverages the fact that 95\% of allocation requests are less than 512 bytes and there are only 3--5 different request sizes.
-When KTs $\le$ N, the important bucket sizes are uncontented.
-When KTs $>$ N, the free buckets are contented.
-Therefore, threads are only contending for a small number of buckets, which are distributed among them to reduce contention.
-\begin{cquote}
+=======
+\section{Design Choices}
+>>>>>>> bb7c77dc425e289ed60aa638529b3e5c7c3e4961
+
+llheap's design was reviewed and changed multiple times throughout the thesis.
+Some of the rejected designs are discussed because they show the path to the final design (see discussion in \VRef{s:MultipleHeaps}).
+Note, a few simples tests for a design choice were compared with the current best allocators to determine the viability of a design.
+
+
+\subsection{Allocation Fastpath}
+\label{s:AllocationFastpath}
+
+These designs look at the allocation/free \newterm{fastpath}, \ie when an allocation can immediately return free storage or returned storage is not coalesced.
+\paragraph{T:1 model}
+\VRef[Figure]{f:T1SharedBuckets} shows one heap accessed by multiple kernel threads (KTs) using a bucket array, where smaller bucket sizes are N-shared across KTs.
+This design leverages the fact that 95\% of allocation requests are less than 1024 bytes and there are only 3--5 different request sizes.
+When KTs $\le$ N, the common bucket sizes are uncontented;
+when KTs $>$ N, the free buckets are contented and latency increases significantly.
+In all cases, a KT must acquire/release a lock, contented or uncontented, along the fast allocation path because a bucket is shared.
+Therefore, while threads are contending for a small number of buckets sizes, the buckets are distributed among them to reduce contention, which lowers latency;
+however, picking N is workload specific.
+
+\begin{figure}
+\centering
+\input{AllocDS1}
+\caption{T:1 with Shared Buckets}
+\label{f:T1SharedBuckets}
+\end{figure}
+
+Problems:
+\begin{itemize}
+\item
+Need to know when a KT is created/destroyed to assign/unassign a shared bucket-number from the memory allocator.
+\item
+When no thread is assigned a bucket number, its free storage is unavailable.
+\item
+All KTs contend for the global-pool lock for initial allocations, before free-lists get populated.
+\end{itemize}
+Tests showed having locks along the allocation fast-path produced a significant increase in allocation costs and any contention among KTs produces a significant spike in latency.
+
+\paragraph{T:H model}
+\VRef[Figure]{f:THSharedHeaps} shows a fixed number of heaps (N), each a local free pool, where the heaps are sharded across the KTs.
+A KT can point directly to its assigned heap or indirectly through the corresponding heap bucket.
+When KT $\le$ N, the heaps are uncontented;
+when KTs $>$ N, the heaps are contented.
+In all cases, a KT must acquire/release a lock, contented or uncontented along the fast allocation path because a heap is shared.
+By adjusting N upwards, this approach reduces contention but increases storage (time versus space);
+however, picking N is workload specific.
+
+\begin{figure}
 \centering
 \input{AllocDS2}
-\end{cquote}
-Problems: need to know when a kernel thread (KT) is created and destroyed to know when to assign a shared bucket-number.
-When no thread is assigned a bucket number, its free storage is unavailable. All KTs will be contended for one lock on sbrk for their initial allocations (before free-lists gets populated).
-
-\paragraph{Design 2: Decentralized N Heaps}
-Fixed number of heaps: shard the heap into N heaps each with a bump-area allocated from the @sbrk@ area.
-Kernel threads (KT) are assigned to the N heaps.
-When KTs $\le$ N, the heaps are uncontented.
-When KTs $>$ N, the heaps are contented.
-By adjusting N, this approach reduces storage at the cost of speed due to contention.
-In all cases, a thread acquires/releases a lock, contented or uncontented.
-\begin{cquote}
-\centering
-\input{AllocDS1}
-\end{cquote}
-Problems: need to know when a KT is created and destroyed to know when to assign/un-assign a heap to the KT.
-
-\paragraph{Design 3: Decentralized Per-thread Heaps}
-Design 3 is similar to design 2 but instead of having an M:N model, it uses a 1:1 model. So, instead of having N heaos and sharing them among M KTs, Design 3 has one heap for each KT.
-Dynamic number of heaps: create a thread-local heap for each kernel thread (KT) with a bump-area allocated from the @sbrk@ area.
-Each KT will have its own exclusive thread-local heap. Heap will be uncontended between KTs regardless how many KTs have been created.
-Operations on @sbrk@ area will still be protected by locks.
-%\begin{cquote}
-%\centering
-%\input{AllocDS3} FIXME add figs
-%\end{cquote}
-Problems: We cannot destroy the heap when a KT exits because our dynamic objects have ownership and they are returned to the heap that created them when the program frees a dynamic object. All dynamic objects point back to their owner heap. If a thread A creates an object O, passes it to another thread B, and A itself exits. When B will free object O, O should return to A's heap so A's heap should be preserved for the lifetime of the whole program as their might be objects in-use of other threads that were allocated by A. Also, we need to know when a KT is created and destroyed to know when to create/destroy a heap for the KT.
-
-\paragraph{Design 4: Decentralized Per-CPU Heaps}
-Design 4 is similar to Design 3 but instead of having a heap for each thread, it creates a heap for each CPU.
-Fixed number of heaps for a machine: create a heap for each CPU with a bump-area allocated from the @sbrk@ area.
-Each CPU will have its own CPU-local heap. When the program does a dynamic memory operation, it will be entertained by the heap of the CPU where the process is currently running on.
-Each CPU will have its own exclusive heap. Just like Design 3(FIXME cite), heap will be uncontended between KTs regardless how many KTs have been created.
-Operations on @sbrk@ area will still be protected by locks.
-To deal with preemtion during a dynamic memory operation, librseq(FIXME cite) will be used to make sure that the whole dynamic memory operation completes on one CPU. librseq's restartable sequences can make it possible to re-run a critical section and undo the current writes if a preemption happened during the critical section's execution.
-%\begin{cquote}
-%\centering
-%\input{AllocDS4} FIXME add figs
-%\end{cquote}
-
-Problems: This approach was slower than the per-thread model. Also, librseq does not provide such restartable sequences to detect preemtions in user-level threading system which is important to us as CFA(FIXME cite) has its own threading system that we want to support.
-
-Out of the four designs, Design 3 was chosen because of the following reasons.
-\begin{itemize}
-\item
-Decentralized designes are better in general as compared to centralized design because their concurrency is better across all bucket-sizes as design 1 shards a few buckets of selected sizes while other designs shards all the buckets. Decentralized designes shard the whole heap which has all the buckets with the addition of sharding sbrk area. So Design 1 was eliminated.
-\item
-Design 2 was eliminated because it has a possibility of contention in-case of KT > N while Design 3 and 4 have no contention in any scenerio.
-\item
-Design 4 was eliminated because it was slower than Design 3 and it provided no way to achieve user-threading safety using librseq. We had to use CFA interruption handling to achive user-threading safety which has some cost to it. Desing 4 was already slower than Design 3, adding cost of interruption handling on top of that would have made it even slower.
-\end{itemize}
-
-
-\subsection{Advantages of distributed design}
-
-The distributed design of uHeap is concurrent to work in multi-threaded applications.
-
-Some key benefits of the distributed design of uHeap are as follows:
-
-\begin{itemize}
-\item
-The bump allocation is concurrent as memory taken from sbrk is sharded across all heaps as bump allocation reserve. The call to sbrk will be protected using locks but bump allocation (on memory taken from sbrk) will not be contended once the sbrk call has returned.
-\item
-Low or almost no contention on heap resources.
-\item
-It is possible to use sharing and stealing techniques to share/find unused storage, when a free list is unused or empty.
-\item
-Distributed design avoids unnecassry locks on resources shared across all KTs.
-\end{itemize}
+\caption{T:H with Shared Heaps}
+\label{f:THSharedHeaps}
+\end{figure}
+
+Problems:
+\begin{itemize}
+\item
+Need to know when a KT is created/destroyed to assign/unassign a heap from the memory allocator.
+\item
+When no thread is assigned to a heap, its free storage is unavailable.
+\item
+Ownership issues arise (see \VRef{s:Ownership}).
+\item
+All KTs contend for the local/global-pool lock for initial allocations, before free-lists get populated.
+\end{itemize}
+Tests showed having locks along the allocation fast-path produced a significant increase in allocation costs and any contention among KTs produces a significant spike in latency.
+
+\paragraph{T:H model, H = number of CPUs}
+This design is the T:H model but H is set to the number of CPUs on the computer or the number restricted to an application, \eg via @taskset@.
+(See \VRef[Figure]{f:THSharedHeaps} but with a heap bucket per CPU.)
+Hence, each CPU logically has its own private heap and local pool.
+A memory operation is serviced from the heap associated with the CPU executing the operation.
+This approach removes fastpath locking and contention, regardless of the number of KTs mapped across the CPUs, because only one KT is running on each CPU at a time (modulo operations on the global pool and ownership).
+This approach is essentially an M:N approach where M is the number if KTs and N is the number of CPUs.
+
+Problems:
+\begin{itemize}
+\item
+Need to know when a CPU is added/removed from the @taskset@.
+\item
+Need a fast way to determine the CPU a KT is executing on to access the appropriate heap.
+\item
+Need to prevent preemption during a dynamic memory operation because of the \newterm{serially-reusable problem}.
+\begin{quote}
+A sequence of code that is guaranteed to run to completion before being invoked to accept another input is called serially-reusable code.~\cite{SeriallyReusable}
+\end{quote}
+If a KT is preempted during an allocation operation, the operating system can schedule another KT on the same CPU, which can begin an allocation operation before the previous operation associated with this CPU has completed, invalidating heap correctness.
+Note, the serially-reusable problem can occur in sequential programs with preemption, if the signal handler calls the preempted function, unless the function is serially reusable.
+Essentially, the serially-reusable problem is a race condition on an unprotected critical section, where the operating system is providing the second thread via the signal handler.
+
+Library @librseq@~\cite{librseq} was used to perform a fast determination of the CPU and to ensure all memory operations complete on one CPU using @librseq@'s restartable sequences, which restart the critical section after undoing its writes, if the critical section is preempted.
+\end{itemize}
+Tests showed that @librseq@ can determine the particular CPU quickly but setting up the restartable critical-section along the allocation fast-path produced a significant increase in allocation costs.
+Also, the number of undoable writes in @librseq@ is limited and restartable sequences cannot deal with user-level thread (UT) migration across KTs.
+For example, UT$_1$ is executing a memory operation by KT$_1$ on CPU$_1$ and a time-slice preemption occurs.
+The signal handler context switches UT$_1$ onto the user-level ready-queue and starts running UT$_2$ on KT$_1$, which immediately calls a memory operation.
+Since KT$_1$ is still executing on CPU$_1$, @librseq@ takes no action because it assumes KT$_1$ is still executing the same critical section.
+Then UT$_1$ is scheduled onto KT$_2$ by the user-level scheduler, and its memory operation continues in parallel with UT$_2$ using references into the heap associated with CPU$_1$, which corrupts CPU$_1$'s heap.
+If @librseq@ had an @rseq_abort@ which:
+\begin{enumerate}
+\item
+Marked the current restartable critical-section as cancelled so it restarts when attempting to commit.
+\item
+Do nothing if there is no current restartable critical section in progress.
+\end{enumerate}
+Then @rseq_abort@ could be called on the backside of a  user-level context-switching.
+A feature similar to this idea might exist for hardware transactional-memory.
+A significant effort was made to make this approach work but its complexity, lack of robustness, and performance costs resulted in its rejection.
+
+\paragraph{1:1 model}
+This design is the T:H model with T = H, where there is one thread-local heap for each KT.
+(See \VRef[Figure]{f:THSharedHeaps} but with a heap bucket per KT and no bucket or local-pool lock.)
+Hence, immediately after a KT starts, its heap is created and just before a KT terminates, its heap is (logically) deleted.
+Heaps are uncontended for a KTs memory operations to its heap (modulo operations on the global pool and ownership).
+
+Problems:
+\begin{itemize}
+\item
+Need to know when a KT is starts/terminates to create/delete its heap.
+
+\noindent
+It is possible to leverage constructors/destructors for thread-local objects to get a general handle on when a KT starts/terminates.
+\item
+There is a classic \newterm{memory-reclamation} problem for ownership because storage passed to another thread can be returned to a terminated heap.
+
+\noindent
+The classic solution only deletes a heap after all referents are returned, which is complex.
+The cheap alternative is for heaps to persist for program duration to handle outstanding referent frees.
+If old referents return storage to a terminated heap, it is handled in the same way as an active heap.
+To prevent heap blowup, terminated heaps can be reused by new KTs, where a reused heap may be populated with free storage from a prior KT (external fragmentation).
+In most cases, heap blowup is not a problem because programs have a small allocation set-size, so the free storage from a prior KT is apropos for a new KT.
+\item
+There can be significant external fragmentation as the number of KTs increases.
+
+\noindent
+In many concurrent applications, good performance is achieved with the number of KTs proportional to the number of CPUs.
+Since the number of CPUs is relatively small, >~1024, and a heap relatively small, $\approx$10K bytes (not including any associated freed storage), the worst-case external fragmentation is still small compared to the RAM available on large servers with many CPUs.
+\item
+There is the same serially-reusable problem with UTs migrating across KTs.
+\end{itemize}
+Tests showed this design produced the closest performance match with the best current allocators, and code inspection showed most of these allocators use different variations of this approach.
+
+
+\vspace{5pt}
+\noindent
+The conclusion from this design exercise is: any atomic fence, atomic instruction (lock free), or lock along the allocation fastpath produces significant slowdown.
+For the T:1 and T:H models, locking must exist along the allocation fastpath because the buckets or heaps maybe shared by multiple threads, even when KTs $\le$ N.
+For the T:H=CPU and 1:1 models, locking is eliminated along the allocation fastpath.
+However, T:H=CPU has poor operating-system support to determine the CPU id (heap id) and prevent the serially-reusable problem for KTs.
+More operating system support is required to make this model viable, but there is still the serially-reusable problem with user-level threading.
+Leaving the 1:1 model with no atomic actions along the fastpath and no special operating-system support required.
+The 1:1 model still has the serially-reusable problem with user-level threading, which is addressed in \VRef{s:UserlevelThreadingSupport}, and the greatest potential for heap blowup for certain allocation patterns.
+
+
+% \begin{itemize}
+% \item
+% A decentralized design is better to centralized design because their concurrency is better across all bucket-sizes as design 1 shards a few buckets of selected sizes while other designs shards all the buckets. Decentralized designs shard the whole heap which has all the buckets with the addition of sharding @sbrk@ area. So Design 1 was eliminated.
+% \item
+% Design 2 was eliminated because it has a possibility of contention in-case of KT > N while Design 3 and 4 have no contention in any scenario.
+% \item
+% Design 3 was eliminated because it was slower than Design 4 and it provided no way to achieve user-threading safety using librseq. We had to use CFA interruption handling to achieve user-threading safety which has some cost to it.
+% that  because of 4 was already slower than Design 3, adding cost of interruption handling on top of that would have made it even slower.
+% \end{itemize}
+% Of the four designs for a low-latency memory allocator, the 1:1 model was chosen for the following reasons:
+
+% \subsection{Advantages of distributed design}
+% 
+% The distributed design of llheap is concurrent to work in multi-threaded applications.
+% Some key benefits of the distributed design of llheap are as follows:
+% \begin{itemize}
+% \item
+% The bump allocation is concurrent as memory taken from @sbrk@ is sharded across all heaps as bump allocation reserve. The call to @sbrk@ will be protected using locks but bump allocation (on memory taken from @sbrk@) will not be contended once the @sbrk@ call has returned.
+% \item
+% Low or almost no contention on heap resources.
+% \item
+% It is possible to use sharing and stealing techniques to share/find unused storage, when a free list is unused or empty.
+% \item
+% Distributed design avoids unnecessary locks on resources shared across all KTs.
+% \end{itemize}
+
+\subsection{Allocation Latency}
+
+A primary goal of llheap is low latency.
+Two forms of latency are internal and external.
+Internal latency is the time to perform an allocation, while external latency is time to obtain/return storage from/to the operating system.
+Ideally latency is $O(1)$ with a small constant.
+
+To obtain $O(1)$ internal latency means no searching on the allocation fastpath, largely prohibits coalescing, which leads to external fragmentation.
+The mitigating factor is that most programs have well behaved allocation patterns, where the majority of allocation operations can be $O(1)$, and heap blowup does not occur without coalescing (although the allocation footprint may be slightly larger).
+
+To obtain $O(1)$ external latency means obtaining one large storage area from the operating system and subdividing it across all program allocations, which requires a good guess at the program storage high-watermark and potential large external fragmentation.
+Excluding real-time operating-systems, operating-system operations are unbounded, and hence some external latency is unavoidable.
+The mitigating factor is that operating-system calls can often be reduced if a programmer has a sense of the storage high-watermark and the allocator is capable of using this information (see @malloc_expansion@ \VPageref{p:malloc_expansion}).
+Furthermore, while operating-system calls are unbounded, many are now reasonably fast, so their latency is tolerable and infrequent.
+
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-\section{uHeap Structure}
-
-As described in (FIXME cite 2.4) uHeap uses following features of multi-threaded memory allocators.
-\begin{itemize}
-\item
-uHeap has multiple heaps without a global heap and uses 1:1 model. (FIXME cite 2.5 1:1 model)
-\item
-uHeap uses object ownership. (FIXME cite 2.5.2)
-\item
-uHeap does not use object containers (FIXME cite 2.6) or any coalescing technique. Instead each dynamic object allocated by uHeap has a header than contains bookkeeping information.
-\item
-Each thread-local heap in uHeap has its own allocation buffer that is taken from the system using sbrk() call. (FIXME cite 2.7)
-\item
-Unless a heap is freeing an object that is owned by another thread's heap or heap is using sbrk() system call, uHeap is mostly lock-free which eliminates most of the contention on shared resources. (FIXME cite 2.8)
-\end{itemize}
-
-As uHeap uses a heap per-thread model to reduce contention on heap resources, we manage a list of heaps (heap-list) that can be used by threads. The list is empty at the start of the program. When a kernel thread (KT) is created, we check if heap-list is empty. If no then a heap is removed from the heap-list and is given to this new KT to use exclusively. If yes then a new heap object is created in dynamic memory and is given to this new KT to use exclusively. When a KT exits, its heap is not destroyed but instead its heap is put on the heap-list and is ready to be reused by new KTs.
-
-This reduces the memory footprint as the objects on free-lists of a KT that has exited can be reused by a new KT. Also, we preserve all the heaps that were created during the lifetime of the program till the end of the program. uHeap uses object ownership where an object is freed to the free-buckets of the heap that allocated it. Even after a KT A has exited, its heap has to be preserved as there might be objects in-use of other threads that were initially allocated by A and the passed to other threads.
+\section{llheap Structure}
+
+\VRef[Figure]{f:llheapStructure} shows the design of llheap, which uses the following features:
+\begin{itemize}
+\item
+1:1 multiple-heap model to minimize the fastpath,
+\item
+can be built with or without heap ownership,
+\item
+headers per allocation versus containers,
+\item
+no coalescing to minimize latency,
+\item
+global heap memory (pool) obtained from the operating system using @mmap@ to create and reuse heaps needed by threads,
+\item
+local reserved memory (pool) per heap obtained from global pool,
+\item
+global reserved memory (pool) obtained from the operating system using @sbrk@ call,
+\item
+optional fast-lookup table for converting allocation requests into bucket sizes,
+\item
+optional statistic-counters table for accumulating counts of allocation operations.
+\end{itemize}
 
 \begin{figure}
 \centering
+<<<<<<< HEAD
 \includegraphics[width=0.65\textwidth]{figures/NewHeapStructure.eps}
 \caption{uHeap Structure}
 \label{fig:heapStructureFig}
+=======
+% \includegraphics[width=0.65\textwidth]{figures/NewHeapStructure.eps}
+\input{llheap}
+\caption{llheap Structure}
+\label{f:llheapStructure}
+>>>>>>> bb7c77dc425e289ed60aa638529b3e5c7c3e4961
 \end{figure}
 
-Each heap uses seggregated free-buckets that have free objects of a specific size. Each free-bucket of a specific size has following 2 lists in it:
-\begin{itemize}
-\item
-Free list is used when a thread is freeing an object that is owned by its own heap so free list does not use any locks/atomic-operations as it is only used by the owner KT.
-\item
-Away list is used when a thread A is freeing an object that is owned by another KT B's heap. This object should be freed to the owner heap (B's heap) so A will place the object on the away list of B. Away list is lock protected as it is shared by all other threads.
-\end{itemize}
-
-When a dynamic object of a size S is requested. The thread-local heap will check if S is greater than or equal to the mmap threshhold. Any request larger than the mmap threshhold is fulfilled by allocating an mmap area of that size and such requests are not allocated on sbrk area. The value of this threshhold can be changed using mallopt routine but the new value should not be larger than our biggest free-bucket size.
-
-Algorithm~\ref{alg:heapObjectAlloc} briefly shows how an allocation request is fulfilled.
-
-\begin{algorithm}
-\caption{Dynamic object allocation of size S}\label{alg:heapObjectAlloc}
+llheap starts by creating an array of $N$ global heaps from storage obtained using @mmap@, where $N$ is the number of computer cores, that persists for program duration.
+There is a global bump-pointer to the next free heap in the array.
+When this array is exhausted, another array is allocated.
+There is a global top pointer for a heap intrusive link to chain free heaps from terminated threads.
+When statistics are turned on, there is a global top pointer for a heap intrusive link to chain \emph{all} the heaps, which is traversed to accumulate statistics counters across heaps using @malloc_stats@.
+
+When a KT starts, a heap is allocated from the current array for exclusive use by the KT.
+When a KT terminates, its heap is chained onto the heap free-list for reuse by a new KT, which prevents unbounded growth of heaps.
+The free heaps is a stack so hot storage is reused first.
+Preserving all heaps created during the program lifetime, solves the storage lifetime problem, when ownership is used.
+This approach wastes storage if a large number of KTs are created/terminated at program start and then the program continues sequentially.
+llheap can be configured with object ownership, where an object is freed to the heap from which it is allocated, or object no-ownership, where an object is freed to the KT's current heap.
+
+Each heap uses segregated free-buckets that have free objects distributed across 91 different sizes from 16 to 4M.
+The number of buckets used is determined dynamically depending on the crossover point from @sbrk@ to @mmap@ allocation using @mallopt( M_MMAP_THRESHOLD )@, \ie small objects managed by the program and large objects managed by the operating system.
+Each free bucket of a specific size has the following two lists:
+\begin{itemize}
+\item
+A free stack used solely by the KT heap-owner, so push/pop operations do not require locking.
+The free objects are a stack so hot storage is reused first.
+\item
+For ownership, a shared away-stack for KTs to return storage allocated by other KTs, so push/pop operations require locking.
+When the free stack is empty, the entire ownership stack is removed and becomes the head of the corresponding free stack.
+\end{itemize}
+
+Algorithm~\ref{alg:heapObjectAlloc} shows the allocation outline for an object of size $S$.
+First, the allocation is divided into small (@sbrk@) or large (@mmap@).
+For large allocations, the storage is mapped directly from the operating system.
+For small allocations, $S$ is quantized into a bucket size.
+Quantizing is performed using a binary search over the ordered bucket array.
+An optional optimization is fast lookup $O(1)$ for sizes < 64K from a 64K array of type @char@, where each element has an index to the corresponding bucket.
+(Type @char@ restricts the number of bucket sizes to 256.)
+For $S$ > 64K, a binary search is used.
+Then, the allocation storage is obtained from the following locations (in order), with increasing latency.
+\begin{enumerate}[topsep=0pt,itemsep=0pt,parsep=0pt]
+\item
+bucket's free stack,
+\item
+bucket's away stack,
+\item
+heap's local pool
+\item
+global pool
+\item
+operating system (@sbrk@)
+\end{enumerate}
+
+\begin{figure}
+\vspace*{-10pt}
+\begin{algorithm}[H]
+\small
+\caption{Dynamic object allocation of size $S$}\label{alg:heapObjectAlloc}
 \begin{algorithmic}[1]
 \State $\textit{O} \gets \text{NULL}$
-\If {$S < \textit{mmap-threshhold}$}
-	\State $\textit{B} \gets (\text{smallest free-bucket} \geq S)$
+\If {$S >= \textit{mmap-threshhold}$}
+	\State $\textit{O} \gets \text{allocate dynamic memory using system call mmap with size S}$
+\Else
+	\State $\textit{B} \gets \text{smallest free-bucket} \geq S$
 	\If {$\textit{B's free-list is empty}$}
 		\If {$\textit{B's away-list is empty}$}
 			\If {$\textit{heap's allocation buffer} < S$}
-				\State $\text{get allocation buffer using system call sbrk()}$
+				\State $\text{get allocation from global pool (which might call \lstinline{sbrk})}$
 			\EndIf
 			\State $\textit{O} \gets \text{bump allocate an object of size S from allocation buffer}$
@@ -157,6 +337,4 @@
 	\EndIf
 	\State $\textit{O's owner} \gets \text{B}$
-\Else
-	\State $\textit{O} \gets \text{allocate dynamic memory using system call mmap with size S}$
 \EndIf
 \State $\Return \textit{ O}$
@@ -164,4 +342,5 @@
 \end{algorithm}
 
+<<<<<<< HEAD
 Algorithm~\ref{alg:heapObjectFreeOwn} shows how a free request is fulfilled if object ownership is turned on. Algorithm~\ref{alg:heapObjectFreeNoOwn} shows how the same free request is fulfilled without object ownership.
 
@@ -171,4 +350,13 @@
 \If {$\textit{A was mmap-ed}$}
 	\State $\text{return A's dynamic memory to system using system call munmap}$
+=======
+\vspace*{-15pt}
+\begin{algorithm}[H]
+\small
+\caption{Dynamic object free at address $A$ with object ownership}\label{alg:heapObjectFreeOwn}
+\begin{algorithmic}[1]
+\If {$\textit{A mapped allocation}$}
+	\State $\text{return A's dynamic memory to system using system call \lstinline{munmap}}$
+>>>>>>> bb7c77dc425e289ed60aa638529b3e5c7c3e4961
 \Else
 	\State $\text{B} \gets \textit{O's owner}$
@@ -181,4 +369,5 @@
 \end{algorithmic}
 \end{algorithm}
+<<<<<<< HEAD
 
 \begin{algorithm}
@@ -199,12 +388,364 @@
 \end{algorithm}
 
+=======
+>>>>>>> bb7c77dc425e289ed60aa638529b3e5c7c3e4961
+
+\vspace*{-15pt}
+\begin{algorithm}[H]
+\small
+\caption{Dynamic object free at address $A$ without object ownership}\label{alg:heapObjectFreeNoOwn}
+\begin{algorithmic}[1]
+\If {$\textit{A mapped allocation}$}
+	\State $\text{return A's dynamic memory to system using system call \lstinline{munmap}}$
+\Else
+	\State $\text{B} \gets \textit{O's owner}$
+	\If {$\textit{B is thread-local heap's bucket}$}
+		\State $\text{push A to B's free-list}$
+	\Else
+		\State $\text{C} \gets \textit{thread local heap's bucket with same size as B}$
+		\State $\text{push A to C's free-list}$
+	\EndIf
+\EndIf
+\end{algorithmic}
+\end{algorithm}
+\end{figure}
+
+Algorithm~\ref{alg:heapObjectFreeOwn} shows the de-allocation (free) outline for an object at address $A$ with ownership.
+First, the address is divided into small (@sbrk@) or large (@mmap@).
+For large allocations, the storage is unmapped back to the operating system.
+For small allocations, the bucket associated with the request size is retrieved.
+If the bucket is local to the thread, the allocation is pushed onto the thread's associated bucket.
+If the bucket is not local to the thread, the allocation is pushed onto the owning thread's associated away stack.
+
+Algorithm~\ref{alg:heapObjectFreeNoOwn} shows the de-allocation (free) outline for an object at address $A$ without ownership.
+The algorithm is the same as for ownership except if the bucket is not local to the thread.
+Then the corresponding bucket of the owner thread is computed for the deallocating thread, and the allocation is pushed onto the deallocating thread's bucket.
+
+Finally, the llheap design funnels \label{p:FunnelRoutine} all allocation/deallocation operations through routines @malloc@/@free@, which are the only routines to directly access and manage the internal data structures of the heap.
+Other allocation operations, \eg @calloc@, @memalign@, and @realloc@, are composed of calls to @malloc@ and possibly @free@, and may manipulate header information after storage is allocated.
+This design simplifies heap-management code during development and maintenance.
+
+
+\subsection{Alignment}
+
+All dynamic memory allocations must have a minimum storage alignment for the contained object(s).
+Often the minimum memory alignment, M, is the bus width (32 or 64-bit) or the largest register (double, long double) or largest atomic instruction (DCAS) or vector data (MMMX).
+In general, the minimum storage alignment is 8/16-byte boundary on 32/64-bit computers.
+For consistency, the object header is normally aligned at this same boundary.
+Larger alignments must be a power of 2, such page alignment (4/8K).
+Any alignment request, N, $\le$ the minimum alignment is handled as a normal allocation with minimal alignment.
+
+For alignments greater than the minimum, the obvious approach for aligning to address @A@ is: compute the next address that is a multiple of @N@ after the current end of the heap, @E@, plus room for the header before @A@ and the size of the allocation after @A@, moving the end of the heap to @E'@.
+\begin{center}
+\input{Alignment1}
+\end{center}
+The storage between @E@ and @H@ is chained onto the appropriate free list for future allocations.
+This approach is also valid within any sufficiently large free block, where @E@ is the start of the free block, and any unused storage before @H@ or after the allocated object becomes free storage.
+In this approach, the aligned address @A@ is the same as the allocated storage address @P@, \ie @P@ $=$ @A@ for all allocation routines, which simplifies deallocation.
+However, if there are a large number of aligned requests, this approach leads to memory fragmentation from the small free areas around the aligned object.
+As well, it does not work for large allocations, where many memory allocators switch from program @sbrk@ to operating-system @mmap@.
+The reason is that @mmap@ only starts on a page boundary, and it is difficult to reuse the storage before the alignment boundary for other requests.
+Finally, this approach is incompatible with allocator designs that funnel allocation requests through @malloc@ as it directly manipulates management information within the allocator to optimize the space/time of a request.
+
+Instead, llheap alignment is accomplished by making a \emph{pessimistically} allocation request for sufficient storage to ensure that \emph{both} the alignment and size request are satisfied, \eg:
+\begin{center}
+\input{Alignment2}
+\end{center}
+The amount of storage necessary is @alignment - M + size@, which ensures there is an address, @A@, after the storage returned from @malloc@, @P@, that is a multiple of @alignment@ followed by sufficient storage for the data object.
+The approach is pessimistic because if @P@ already has the correct alignment @N@, the initial allocation has already requested sufficient space to move to the next multiple of @N@.
+For this special case, there is @alignment - M@ bytes of unused storage after the data object, which subsequently can be used by @realloc@.
+
+Note, the address returned is @A@, which is subsequently returned to @free@.
+However, to correctly free the allocated object, the value @P@ must be computable, since that is the value generated by @malloc@ and returned within @memalign@.
+Hence, there must be a mechanism to detect when @P@ $\neq$ @A@ and how to compute @P@ from @A@.
+
+The llheap approach uses two headers:
+the \emph{original} header associated with a memory allocation from @malloc@, and a \emph{fake} header within this storage before the alignment boundary @A@, which is returned from @memalign@, e.g.:
+\begin{center}
+\input{Alignment2Impl}
+\end{center}
+Since @malloc@ has a minimum alignment of @M@, @P@ $\neq$ @A@ only holds for alignments of @M@ or greater.
+When @P@ $\neq$ @A@, the minimum distance between @P@ and @A@ is @M@ bytes, due to the pessimistic storage-allocation.
+Therefore, there is always room for an @M@-byte fake header before @A@.
+
+The fake header must supply an indicator to distinguish it from a normal header and the location of address @P@ generated by @malloc@.
+This information is encoded as an offset from A to P and the initialize alignment (discussed in \VRef{s:ReallocStickyProperties}).
+To distinguish a fake header from a normal header, the least-significant bit of the alignment is used because the offset participates in multiple calculations, while the alignment is just remembered data.
+\begin{center}
+\input{FakeHeader}
+\end{center}
+
+
+\subsection{\lstinline{realloc} and Sticky Properties}
+\label{s:ReallocStickyProperties}
+
+Allocation routine @realloc@ provides a memory-management pattern for shrinking/enlarging an existing allocation, while maintaining some or all of the object data, rather than performing the following steps manually.
+\begin{flushleft}
+\begin{tabular}{ll}
+\multicolumn{1}{c}{\textbf{realloc pattern}} & \multicolumn{1}{c}{\textbf{manually}} \\
+\begin{lstlisting}
+T * naddr = realloc( oaddr, newSize );
+
+
+
+\end{lstlisting}
+&
+\begin{lstlisting}
+T * naddr = (T *)malloc( newSize ); $\C[2.4in]{// new storage}$
+memcpy( naddr, addr, oldSize );	 $\C{// copy old bytes}$
+free( addr );				$\C{// free old storage}$
+addr = naddr;				$\C{// change pointer}\CRT$
+\end{lstlisting}
+\end{tabular}
+\end{flushleft}
+The realloc pattern leverages available storage at the end of an allocation due to bucket sizes, possibly eliminating a new allocation and copying.
+This pattern is not used enough to reduce storage management costs.
+In fact, if @oaddr@ is @nullptr@, @realloc@ does a @malloc@, so even the initial @malloc@ can be a @realloc@ for consistency in the pattern.
+
+The hidden problem for this pattern is the effect of zero fill and alignment with respect to reallocation.
+Are these properties transient or persistent (``sticky'')?
+For example, when memory is initially allocated by @calloc@ or @memalign@ with zero fill or alignment properties, respectively, what happens when those allocations are given to @realloc@ to change size.
+That is, if @realloc@ logically extends storage into unused bucket space or allocates new storage to satisfy a size change, are initial allocation properties preserve?
+Currently, allocation properties are not preserved, so subsequent use of @realloc@ storage may cause inefficient execution or errors due to lack of zero fill or alignment.
+This silent problem is unintuitive to programmers and difficult to locate because it is transient.
+To prevent these problems, llheap preserves initial allocation properties for the lifetime of an allocation and the semantics of @realloc@ are augmented to preserve these properties, with additional query routines.
+This change makes the realloc pattern efficient and safe.
+
+
+\subsection{Header}
+
+To preserve allocation properties requires storing additional information with an allocation,
+The only available location is the header, where \VRef[Figure]{f:llheapNormalHeader} shows the llheap storage layout.
+The header has two data field sized appropriately for 32/64-bit alignment requirements.
+The first field is a union of three values:
+\begin{description}
+\item[bucket pointer]
+is for allocated storage and points back to the bucket associated with this storage requests (see \VRef[Figure]{f:llheapStructure} for the fields accessible in a bucket).
+\item[mapped size]
+is for mapped storage and is the storage size for use in unmapping.
+\item[next free block]
+is for free storage and is an intrusive pointer chaining same-size free blocks onto a bucket's free stack.
+\end{description}
+The second field remembers the request size versus the allocation (bucket) size, \eg request 42 bytes which is rounded up to 64 bytes.
+Since programmers think in request sizes rather than allocation sizes, the request size allows better generation of statistics or errors.
+
+\begin{figure}
+\centering
+\input{Header}
+\caption{llheap Normal Header}
+\label{f:llheapNormalHeader}
+\end{figure}
+
+The low-order 3-bits of the first field are \emph{unused} for any stored values, whereas the second field may use all of its bits.
+The 3 unused bits are used to represent mapped allocation, zero filled, and alignment, respectively.
+Note, the alignment bit is not used in the normal header and the zero-filled/mapped bits are not used in the fake header.
+This implementation allows a fast test if any of the lower 3-bits are on (@&@ and compare).
+If no bits are on, it implies a basic allocation, which is handled quickly;
+otherwise, the bits are analysed and appropriate actions are taken for the complex cases.
+Since most allocations are basic, this implementation results in a significant performance gain along the allocation and free fastpath.
+
+
+\section{Statistics and Debugging}
+
+llheap can be built to accumulate fast and largely contention-free allocation statistics to help understand allocation behaviour.
+Incrementing statistic counters must appear on the allocation fastpath.
+As noted, any atomic operation along the fastpath produces a significant increase in allocation costs.
+To make statistics performant enough for use on running systems, each heap has its own set of statistic counters, so heap operations do not require atomic operations.
+
+To locate all statistic counters, heaps are linked together in statistics mode, and this list is locked and traversed to sum all counters across heaps.
+Note, the list is locked to prevent errors traversing an active list;
+the statistics counters are not locked and can flicker during accumulation, which is not an issue with atomic read/write.
+\VRef[Figure]{f:StatiticsOutput} shows an example of statistics output, which covers all allocation operations and information about deallocating storage not owned by a thread.
+No other memory allocator studied provides as comprehensive statistical information.
+Finally, these statistics were invaluable during the development of this thesis for debugging and verifying correctness, and hence, should be equally valuable to application developers.
+
+\begin{figure}
+\begin{lstlisting}
+Heap statistics: (storage request / allocation)
+  malloc >0 calls 2,766; 0 calls 2,064; storage 12,715 / 13,367 bytes
+  aalloc >0 calls 0; 0 calls 0; storage 0 / 0 bytes
+  calloc >0 calls 6; 0 calls 0; storage 1,008 / 1,104 bytes
+  memalign >0 calls 0; 0 calls 0; storage 0 / 0 bytes
+  amemalign >0 calls 0; 0 calls 0; storage 0 / 0 bytes
+  cmemalign >0 calls 0; 0 calls 0; storage 0 / 0 bytes
+  resize >0 calls 0; 0 calls 0; storage 0 / 0 bytes
+  realloc >0 calls 0; 0 calls 0; storage 0 / 0 bytes
+  free !null calls 2,766; null calls 4,064; storage 12,715 / 13,367 bytes
+  away pulls 0; pushes 0; storage 0 / 0 bytes
+  sbrk calls 1; storage 10,485,760 bytes
+  mmap calls 10,000; storage 10,000 / 10,035 bytes
+  munmap calls 10,000; storage 10,000 / 10,035 bytes
+  threads started 4; exited 3
+  heaps new 4; reused 0
+\end{lstlisting}
+\caption{Statistics Output}
+\label{f:StatiticsOutput}
+\end{figure}
+
+llheap can also be built with debug checking, which inserts many asserts along all allocation paths.
+These assertions detect incorrect allocation usage, like double frees, unfreed storage, or memory corruptions because internal values (like header fields) are overwritten.
+These checks are best effort as opposed to complete allocation checking as in @valgrind@.
+Nevertheless, the checks detect many allocation problems.
+There is an unfortunate problem in detecting unfreed storage because some library routines assume their allocations have life-time duration, and hence, do not free their storage.
+For example, @printf@ allocates a 1024 buffer on first call and never deletes this buffer.
+To prevent a false positive for unfreed storage, it is possible to specify an amount of storage that is never freed (see @malloc_unfreed@ \VPageref{p:malloc_unfreed}), and it is subtracted from the total allocate/free difference.
+Determining the amount of never-freed storage is annoying, but once done, any warnings of unfreed storage are application related.
+
+Tests indicate only a 30\% performance increase when statistics \emph{and} debugging are enabled, and the latency cost for accumulating statistic is mitigated by limited calls, often only one at the end of the program.
+
+
+\section{User-level Threading Support}
+\label{s:UserlevelThreadingSupport}
+
+The serially-reusable problem (see \VRef{s:AllocationFastpath}) occurs for kernel threads in the ``T:H model, H = number of CPUs'' model and for user threads in the ``1:1'' model, where llheap uses the ``1:1'' model.
+The solution is to prevent interrupts that can result in CPU or KT change during operations that are logically critical sections.
+Locking these critical sections negates any attempt for a quick fastpath and results in high contention.
+For user-level threading, the serially-reusable problem appears with time slicing for preemptable scheduling, as the signal handler context switches to another user-level thread.
+Without time slicing, a user thread performing a long computation can prevent execution (starve) other threads.
+To prevent starvation for an allocation-active thread, \ie the time slice always triggers in an allocation critical-section for one thread, a thread-local \newterm{rollforward} flag is set in the signal handler when it aborts a time slice.
+The rollforward flag is tested at the end of each allocation funnel routine (see \VPageref{p:FunnelRoutine}), and if set, it is reset and a volunteer yield (context switch) is performed to allow other threads to execute.
+
+llheap uses two techniques to detect when execution is in a allocation operation or routine called from allocation operation, to abort any time slice during this period.
+On the slowpath when executing expensive operations, like @sbrk@ or @mmap@, interrupts are disabled/enabled by setting thread-local flags so the signal handler aborts immediately.
+On the fastpath, disabling/enabling interrupts is too expensive as accessing thread-local storage can be expensive and not thread-safe.
+For example, the ARM processor stores the thread-local pointer in a coprocessor register that cannot perform atomic base-displacement addressing.
+Hence, there is a window between loading the thread-local pointer from the coprocessor register into a normal register and adding the displacement when a time slice can move a thread.
+
+The fast technique defines a special code section and places all non-interruptible routines in this section.
+The linker places all code in this section into a contiguous block of memory, but the order of routines within the block is unspecified.
+Then, the signal handler compares the program counter at the point of interrupt with the the start and end address of the non-interruptible section, and aborts if executing within this section and sets the rollforward flag.
+This technique is fragile because any calls in the non-interruptible code outside of the non-interruptible section (like @sbrk@) must be bracketed with disable/enable interrupts and these calls must be along the slowpath.
+Hence, for correctness, this approach requires inspection of generated assembler code for routines placed in the non-interruptible section.
+This issue is mitigated by the llheap funnel design so only funnel routines and a few statistics routines are placed in the non-interruptible section and their assembler code examined.
+These techniques are used in both the \uC and \CFA versions of llheap, where both of these systems have user-level threading.
+
+
+\section{Bootstrapping}
+
+There are problems bootstrapping a memory allocator.
+\begin{enumerate}
+\item
+Programs can be statically or dynamically linked.
+\item
+The order the linker schedules startup code is poorly supported.
+\item
+Knowing a KT's start and end independently from the KT code is difficult.
+\end{enumerate}
+
+For static linking, the allocator is loaded with the program.
+Hence, allocation calls immediately invoke the allocator operation defined by the loaded allocation library and there is only one memory allocator used in the program.
+This approach allows allocator substitution by placing an allocation library before any other in the linked/load path.
+
+Allocator substitution is similar for dynamic linking, but the problem is that the dynamic loader starts first and needs to perform dynamic allocations \emph{before} the substitution allocator is loaded.
+As a result, the dynamic loader uses a default allocator until the substitution allocator is loaded, after which all allocation operations are handled by the substitution allocator, including from the dynamic loader.
+Hence, some part of the @sbrk@ area may be used by the default allocator and statistics about allocation operations cannot be correct.
+Furthermore, dynamic linking goes through trampolines, so there is an additional cost along the allocator fastpath for all allocation operations.
+Testing showed up to a 5\% performance increase for dynamic linking over static linking, even when using @tls_model("initial-exec")@ so the dynamic loader can obtain tighter binding.
+
+All allocator libraries need to perform startup code to initialize data structures, such as the heap array for llheap.
+The problem is getting initialized done before the first allocator call.
+However, there does not seem to be mechanism to tell either the static or dynamic loader to first perform initialization code before any calls to a loaded library.
+As a result, calls to allocation routines occur without initialization.
+To deal with this problem, it is necessary to put a conditional initialization check along the allocation fastpath to trigger initialization (singleton pattern).
+
+Two other important execution points are program startup and termination, which include prologue or epilogue code to bootstrap a program, which programmers are unaware of.
+For example, dynamic-memory allocations before/after the application starts should not be considered in statistics because the application does not make these calls.
+llheap establishes these two points using routines:
+\begin{lstlisting}
+__attribute__(( constructor( 100 ) )) static void startup( void ) {
+	// clear statistic counters
+	// reset allocUnfreed counter
+}
+__attribute__(( destructor( 100 ) )) static void shutdown( void ) {
+	// sum allocUnfreed for all heaps
+	// subtract global unfreed storage
+	// if allocUnfreed > 0 then print warning message
+}
+\end{lstlisting}
+which use global constructor/destructor priority 100, where the linker calls these routines at program prologue/epilogue in increasing/decreasing order of priority.
+Application programs may only use global constructor/destructor priorities greater than 100.
+Hence, @startup@ is called after the program prologue but before the application starts, and @shutdown@ is called after the program terminates but before the program epilogue.
+By resetting counters in @startup@, prologue allocations are ignored, and checking unfreed storage in @shutdown@ checks only application memory management, ignoring the program epilogue.
+
+While @startup@/@shutdown@ apply to the program KT, a concurrent program creates additional KTs that do not trigger these routines.
+However, it is essential for the allocator to know when each KT is started/terminated.
+One approach is to create a thread-local object with a construct/destructor, which is triggered after a new KT starts and before it terminates, respectively.
+\begin{lstlisting}
+struct ThreadManager {
+	volatile bool pgm_thread;
+	ThreadManager() {} // unusable
+	~ThreadManager() { if ( pgm_thread ) heapManagerDtor(); }
+};
+static thread_local ThreadManager threadManager;
+\end{lstlisting}
+Unfortunately, thread-local variables are created lazily, \ie on the first dereference of @threadManager@, which then triggers its constructor.
+Therefore, the constructor is useless for knowing when a KT starts because the KT must reference it, and the allocator does not control the application KT.
+Fortunately, the singleton pattern needed for initializing the program KT also triggers KT allocator initialization, which can then reference @pgm_thread@ to call @threadManager@'s constructor, otherwise its destructor is not called.
+Now when a KT terminates, @~ThreadManager@ is called to chained it onto the global-heap free-stack, where @pgm_thread@ is set to true only for the program KT.
+The conditional destructor call prevents closing down the program heap, which must remain available because epilogue code may free more storage.
+
+Finally, there is a recursive problem when the singleton pattern dereferences @pgm_thread@ to initialize the thread-local object, because its initialization calls @atExit@, which immediately calls @malloc@ to obtain storage.
+This recursion is handled with another thread-local flag to prevent double initialization.
+A similar problem exists when the KT terminates and calls member @~ThreadManager@, because immediately afterwards, the terminating KT calls @free@ to deallocate the storage obtained from the @atExit@.
+In the meantime, the terminated heap has been put on the global-heap free-stack, and may be active by a new KT, so the @atExit@ free is handled as a free to another heap and put onto the away list using locking.
+
+For user threading systems, the KTs are controlled by the runtime, and hence, start/end pointers are known and interact directly with the llheap allocator for \uC and \CFA, which eliminates or simplifies several of these problems.
+The following API was created to provide interaction between the language runtime and the allocator.
+\begin{lstlisting}
+void startTask();			$\C{// KT starts}$
+void finishTask();			$\C{// KT ends}$
+void startup();				$\C{// when application code starts}$
+void shutdown();			$\C{// when application code ends}$
+bool traceHeap();			$\C{// enable allocation/free printing for debugging}$
+bool traceHeapOn();			$\C{// start printing allocation/free calls}$
+bool traceHeapOff();			$\C{// stop printing allocation/free calls}$
+\end{lstlisting}
+This kind of API is necessary to allow concurrent runtime systems to interact with difference memory allocators in a consistent way.
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 \section{Added Features and Methods}
-To improve the uHeap allocator (FIX ME: cite uHeap) interface and make it more user friendly, we added a few more routines to the C allocator. Also, we built a \CFA (FIX ME: cite cforall) interface on top of C interface to increase the usability of the allocator.
-
-\subsection{C Interface}
-We added a few more features and routines to the allocator's C interface that can make the allocator more usable to the programmers. THese features will programmer more control on the dynamic memory allocation.
+
+The C dynamic-allocation API (see \VRef[Figure]{f:CDynamicAllocationAPI}) is neither orthogonal nor complete.
+For example,
+\begin{itemize}
+\item
+It is possible to zero fill or align an allocation but not both.
+\item
+It is \emph{only} possible to zero fill an array allocation.
+\item
+It is not possible to resize a memory allocation without data copying.
+\item
+@realloc@ does not preserve initial allocation properties.
+\end{itemize}
+As a result, programmers must provide these options, which is error prone, resulting in blaming the entire programming language for a poor dynamic-allocation API.
+Furthermore, newer programming languages have better type systems that can provide safer and more powerful APIs for memory allocation.
+
+\begin{figure}
+\begin{lstlisting}
+void * malloc( size_t size );
+void * calloc( size_t nmemb, size_t size );
+void * realloc( void * ptr, size_t size );
+void * reallocarray( void * ptr, size_t nmemb, size_t size );
+void free( void * ptr );
+void * memalign( size_t alignment, size_t size );
+void * aligned_alloc( size_t alignment, size_t size );
+int posix_memalign( void ** memptr, size_t alignment, size_t size );
+void * valloc( size_t size );
+void * pvalloc( size_t size );
+
+struct mallinfo mallinfo( void );
+int mallopt( int param, int val );
+int malloc_trim( size_t pad );
+size_t malloc_usable_size( void * ptr );
+void malloc_stats( void );
+int malloc_info( int options, FILE * fp );
+\end{lstlisting}
+\caption{C Dynamic-Allocation API}
+\label{f:CDynamicAllocationAPI}
+\end{figure}
+
+The following presents design and API changes for C, \CC (\uC), and \CFA, all of which are implemented in llheap.
+
 
 \subsection{Out of Memory}
@@ -212,354 +753,337 @@
 Most allocators use @nullptr@ to indicate an allocation failure, specifically out of memory;
 hence the need to return an alternate value for a zero-sized allocation.
-The alternative is to abort a program when out of memory.
-In theory, notifying the programmer allows recovery;
-in practice, it is almost impossible to gracefully when out of memory, so the cheaper approach of returning @nullptr@ for a zero-sized allocation is chosen.
-
-
-\subsection{\lstinline{void * aalloc( size_t dim, size_t elemSize )}}
-@aalloc@ is an extension of malloc. It allows programmer to allocate a dynamic array of objects without calculating the total size of array explicitly. The only alternate of this routine in the other allocators is calloc but calloc also fills the dynamic memory with 0 which makes it slower for a programmer who only wants to dynamically allocate an array of objects without filling it with 0.
-\paragraph{Usage}
+A different approach allowed by the C API is to abort a program when out of memory and return @nullptr@ for a zero-sized allocation.
+In theory, notifying the programmer of memory failure allows recovery;
+in practice, it is almost impossible to gracefully recover when out of memory.
+Hence, the cheaper approach of returning @nullptr@ for a zero-sized allocation is chosen because no pseudo allocation is necessary.
+
+
+\subsection{C Interface}
+
+For C, it is possible to increase functionality and orthogonality of the dynamic-memory API to make allocation better for programmers.
+
+For existing C allocation routines:
+\begin{itemize}
+\item
+@calloc@ sets the sticky zero-fill property.
+\item
+@memalign@, @aligned_alloc@, @posix_memalign@, @valloc@ and @pvalloc@ set the sticky alignment property.
+\item
+@realloc@ and @reallocarray@ preserve sticky properties.
+\end{itemize}
+
+The C dynamic-memory API is extended with the following routines:
+
+\paragraph{\lstinline{void * aalloc( size_t dim, size_t elemSize )}}
+extends @calloc@ for allocating a dynamic array of objects without calculating the total size of array explicitly but \emph{without} zero-filling the memory.
+@aalloc@ is significantly faster than @calloc@, which is the only alternative.
+
+\noindent\textbf{Usage}
 @aalloc@ takes two parameters.
-
-\begin{itemize}
-\item
-@dim@: number of objects in the array
-\item
-@elemSize@: size of the object in the array.
-\end{itemize}
-It returns address of dynamic object allocatoed on heap that can contain dim number of objects of the size elemSize. On failure, it returns a @NULL@ pointer.
-
-\subsection{\lstinline{void * resize( void * oaddr, size_t size )}}
-@resize@ is an extension of relloc. It allows programmer to reuse a cuurently allocated dynamic object with a new size requirement. Its alternate in the other allocators is @realloc@ but relloc also copy the data in old object to the new object which makes it slower for the programmer who only wants to reuse an old dynamic object for a new size requirement but does not want to preserve the data in the old object to the new object.
-\paragraph{Usage}
+\begin{itemize}
+\item
+@dim@: number of array objects
+\item
+@elemSize@: size of array object
+\end{itemize}
+It returns the address of the dynamic array or @NULL@ if either @dim@ or @elemSize@ are zero.
+
+\paragraph{\lstinline{void * resize( void * oaddr, size_t size )}}
+extends @realloc@ for resizing an existing allocation \emph{without} copying previous data into the new allocation or preserving sticky properties.
+@resize@ is significantly faster than @realloc@, which is the only alternative.
+
+\noindent\textbf{Usage}
 @resize@ takes two parameters.
-
-\begin{itemize}
-\item
-@oaddr@: the address of the old object that needs to be resized.
-\item
-@size@: the new size requirement of the to which the old object needs to be resized.
-\end{itemize}
-It returns an object that is of the size given but it does not preserve the data in the old object. On failure, it returns a @NULL@ pointer.
-
-\subsection{\lstinline{void * resize( void * oaddr, size_t nalign, size_t size )}}
-This @resize@ is an extension of the above @resize@ (FIX ME: cite above resize). In addition to resizing the size of of an old object, it can also realign the old object to a new alignment requirement.
-\paragraph{Usage}
-This resize takes three parameters. It takes an additional parameter of nalign as compared to the above resize (FIX ME: cite above resize).
-
-\begin{itemize}
-\item
-@oaddr@: the address of the old object that needs to be resized.
-\item
-@nalign@: the new alignment to which the old object needs to be realigned.
-\item
-@size@: the new size requirement of the to which the old object needs to be resized.
-\end{itemize}
-It returns an object with the size and alignment given in the parameters. On failure, it returns a @NULL@ pointer.
-
-\subsection{\lstinline{void * amemalign( size_t alignment, size_t dim, size_t elemSize )}}
-amemalign is a hybrid of memalign and aalloc. It allows programmer to allocate an aligned dynamic array of objects without calculating the total size of the array explicitly. It frees the programmer from calculating the total size of the array.
-\paragraph{Usage}
-amemalign takes three parameters.
-
-\begin{itemize}
-\item
-@alignment@: the alignment to which the dynamic array needs to be aligned.
-\item
-@dim@: number of objects in the array
-\item
-@elemSize@: size of the object in the array.
-\end{itemize}
-It returns a dynamic array of objects that has the capacity to contain dim number of objects of the size of elemSize. The returned dynamic array is aligned to the given alignment. On failure, it returns a @NULL@ pointer.
-
-\subsection{\lstinline{void * cmemalign( size_t alignment, size_t dim, size_t elemSize )}}
-cmemalign is a hybrid of amemalign and calloc. It allows programmer to allocate an aligned dynamic array of objects that is 0 filled. The current way to do this in other allocators is to allocate an aligned object with memalign and then fill it with 0 explicitly. This routine provides both features of aligning and 0 filling, implicitly.
-\paragraph{Usage}
-cmemalign takes three parameters.
-
-\begin{itemize}
-\item
-@alignment@: the alignment to which the dynamic array needs to be aligned.
-\item
-@dim@: number of objects in the array
-\item
-@elemSize@: size of the object in the array.
-\end{itemize}
-It returns a dynamic array of objects that has the capacity to contain dim number of objects of the size of elemSize. The returned dynamic array is aligned to the given alignment and is 0 filled. On failure, it returns a @NULL@ pointer.
-
-\subsection{\lstinline{size_t malloc_alignment( void * addr )}}
-@malloc_alignment@ returns the alignment of a currently allocated dynamic object. It allows the programmer in memory management and personal bookkeeping. It helps the programmer in verofying the alignment of a dynamic object especially in a scenerio similar to prudcer-consumer where a producer allocates a dynamic object and the consumer needs to assure that the dynamic object was allocated with the required alignment.
-\paragraph{Usage}
-@malloc_alignment@ takes one parameters.
-
-\begin{itemize}
-\item
-@addr@: the address of the currently allocated dynamic object.
-\end{itemize}
-@malloc_alignment@ returns the alignment of the given dynamic object. On failure, it return the value of default alignment of the uHeap allocator.
-
-\subsection{\lstinline{bool malloc_zero_fill( void * addr )}}
-@malloc_zero_fill@ returns whether a currently allocated dynamic object was initially zero filled at the time of allocation. It allows the programmer in memory management and personal bookkeeping. It helps the programmer in verifying the zero filled property of a dynamic object especially in a scenerio similar to prudcer-consumer where a producer allocates a dynamic object and the consumer needs to assure that the dynamic object was zero filled at the time of allocation.
-\paragraph{Usage}
+\begin{itemize}
+\item
+@oaddr@: address to be resized
+\item
+@size@: new allocation size (smaller or larger than previous)
+\end{itemize}
+It returns the address of the old or new storage with the specified new size or @NULL@ if @size@ is zero.
+
+\paragraph{\lstinline{void * amemalign( size_t alignment, size_t dim, size_t elemSize )}}
+extends @aalloc@ and @memalign@ for allocating an aligned dynamic array of objects.
+Sets sticky alignment property.
+
+\noindent\textbf{Usage}
+@amemalign@ takes three parameters.
+\begin{itemize}
+\item
+@alignment@: alignment requirement
+\item
+@dim@: number of array objects
+\item
+@elemSize@: size of array object
+\end{itemize}
+It returns the address of the aligned dynamic-array or @NULL@ if either @dim@ or @elemSize@ are zero.
+
+\paragraph{\lstinline{void * cmemalign( size_t alignment, size_t dim, size_t elemSize )}}
+extends @amemalign@ with zero fill and has the same usage as @amemalign@.
+Sets sticky zero-fill and alignment property.
+It returns the address of the aligned, zero-filled dynamic-array or @NULL@ if either @dim@ or @elemSize@ are zero.
+
+\paragraph{\lstinline{size_t malloc_alignment( void * addr )}}
+returns the alignment of the dynamic object for use in aligning similar allocations.
+
+\noindent\textbf{Usage}
+@malloc_alignment@ takes one parameter.
+\begin{itemize}
+\item
+@addr@: address of an allocated object.
+\end{itemize}
+It returns the alignment of the given object, where objects not allocated with alignment return the minimal allocation alignment.
+
+\paragraph{\lstinline{bool malloc_zero_fill( void * addr )}}
+returns true if the object has the zero-fill sticky property for use in zero filling similar allocations.
+
+\noindent\textbf{Usage}
 @malloc_zero_fill@ takes one parameters.
 
 \begin{itemize}
 \item
-@addr@: the address of the currently allocated dynamic object.
-\end{itemize}
-@malloc_zero_fill@ returns true if the dynamic object was initially zero filled and return false otherwise. On failure, it returns false.
-
-\subsection{\lstinline{size_t malloc_size( void * addr )}}
-@malloc_size@ returns the allocation size of a currently allocated dynamic object. It allows the programmer in memory management and personal bookkeeping. It helps the programmer in verofying the alignment of a dynamic object especially in a scenerio similar to prudcer-consumer where a producer allocates a dynamic object and the consumer needs to assure that the dynamic object was allocated with the required size. Its current alternate in the other allocators is @malloc_usable_size@. But, @malloc_size@ is different from @malloc_usable_size@ as @malloc_usabe_size@ returns the total data capacity of dynamic object including the extra space at the end of the dynamic object. On the other hand, @malloc_size@ returns the size that was given to the allocator at the allocation of the dynamic object. This size is updated when an object is realloced, resized, or passed through a similar allocator routine.
-\paragraph{Usage}
+@addr@: address of an allocated object.
+\end{itemize}
+It returns true if the zero-fill sticky property is set and false otherwise.
+
+\paragraph{\lstinline{size_t malloc_size( void * addr )}}
+returns the request size of the dynamic object (updated when an object is resized) for use in similar allocations.
+See also @malloc_usable_size@.
+
+\noindent\textbf{Usage}
 @malloc_size@ takes one parameters.
-
-\begin{itemize}
-\item
-@addr@: the address of the currently allocated dynamic object.
-\end{itemize}
-@malloc_size@ returns the allocation size of the given dynamic object. On failure, it return zero.
-
-\subsection{\lstinline{void * realloc( void * oaddr, size_t nalign, size_t size )}}
-This @realloc@ is an extension of the default @realloc@ (FIX ME: cite default @realloc@). In addition to reallocating an old object and preserving the data in old object, it can also realign the old object to a new alignment requirement.
-\paragraph{Usage}
-This @realloc@ takes three parameters. It takes an additional parameter of nalign as compared to the default @realloc@.
-
-\begin{itemize}
-\item
-@oaddr@: the address of the old object that needs to be reallocated.
-\item
-@nalign@: the new alignment to which the old object needs to be realigned.
-\item
-@size@: the new size requirement of the to which the old object needs to be resized.
-\end{itemize}
-It returns an object with the size and alignment given in the parameters that preserves the data in the old object. On failure, it returns a @NULL@ pointer.
-
-\subsection{\CFA Malloc Interface}
-We added some routines to the malloc interface of \CFA. These routines can only be used in \CFA and not in our standalone uHeap allocator as these routines use some features that are only provided by \CFA and not by C. It makes the allocator even more usable to the programmers.
-\CFA provides the liberty to know the returned type of a call to the allocator. So, mainly in these added routines, we removed the object size parameter from the routine as allocator can calculate the size of the object from the returned type.
-
-\subsection{\lstinline{T * malloc( void )}}
-This malloc is a simplified polymorphic form of defualt malloc (FIX ME: cite malloc). It does not take any parameter as compared to default malloc that takes one parameter.
-\paragraph{Usage}
-This malloc takes no parameters.
-It returns a dynamic object of the size of type @T@. On failure, it returns a @NULL@ pointer.
-
-\subsection{\lstinline{T * aalloc( size_t dim )}}
-This aalloc is a simplified polymorphic form of above aalloc (FIX ME: cite aalloc). It takes one parameter as compared to the above aalloc that takes two parameters.
-\paragraph{Usage}
-aalloc takes one parameters.
-
-\begin{itemize}
-\item
-@dim@: required number of objects in the array.
-\end{itemize}
-It returns a dynamic object that has the capacity to contain dim number of objects, each of the size of type @T@. On failure, it returns a @NULL@ pointer.
-
-\subsection{\lstinline{T * calloc( size_t dim )}}
-This calloc is a simplified polymorphic form of defualt calloc (FIX ME: cite calloc). It takes one parameter as compared to the default calloc that takes two parameters.
-\paragraph{Usage}
-This calloc takes one parameter.
-
-\begin{itemize}
-\item
-@dim@: required number of objects in the array.
-\end{itemize}
-It returns a dynamic object that has the capacity to contain dim number of objects, each of the size of type @T@. On failure, it returns a @NULL@ pointer.
-
-\subsection{\lstinline{T * resize( T * ptr, size_t size )}}
-This resize is a simplified polymorphic form of above resize (FIX ME: cite resize with alignment). It takes two parameters as compared to the above resize that takes three parameters. It frees the programmer from explicitly mentioning the alignment of the allocation as \CFA provides gives allocator the liberty to get the alignment of the returned type.
-\paragraph{Usage}
-This resize takes two parameters.
-
-\begin{itemize}
-\item
-@ptr@: address of the old object.
-\item
-@size@: the required size of the new object.
-\end{itemize}
-It returns a dynamic object of the size given in paramters. The returned object is aligned to the alignemtn of type @T@. On failure, it returns a @NULL@ pointer.
-
-\subsection{\lstinline{T * realloc( T * ptr, size_t size )}}
-This @realloc@ is a simplified polymorphic form of defualt @realloc@ (FIX ME: cite @realloc@ with align). It takes two parameters as compared to the above @realloc@ that takes three parameters. It frees the programmer from explicitly mentioning the alignment of the allocation as \CFA provides gives allocator the liberty to get the alignment of the returned type.
-\paragraph{Usage}
-This @realloc@ takes two parameters.
-
-\begin{itemize}
-\item
-@ptr@: address of the old object.
-\item
-@size@: the required size of the new object.
-\end{itemize}
-It returns a dynamic object of the size given in paramters that preserves the data in the given object. The returned object is aligned to the alignemtn of type @T@. On failure, it returns a @NULL@ pointer.
-
-\subsection{\lstinline{T * memalign( size_t align )}}
-This memalign is a simplified polymorphic form of defualt memalign (FIX ME: cite memalign). It takes one parameters as compared to the default memalign that takes two parameters.
-\paragraph{Usage}
-memalign takes one parameters.
-
-\begin{itemize}
-\item
-@align@: the required alignment of the dynamic object.
-\end{itemize}
-It returns a dynamic object of the size of type @T@ that is aligned to given parameter align. On failure, it returns a @NULL@ pointer.
-
-\subsection{\lstinline{T * amemalign( size_t align, size_t dim )}}
-This amemalign is a simplified polymorphic form of above amemalign (FIX ME: cite amemalign). It takes two parameter as compared to the above amemalign that takes three parameters.
-\paragraph{Usage}
-amemalign takes two parameters.
-
-\begin{itemize}
-\item
-@align@: required alignment of the dynamic array.
-\item
-@dim@: required number of objects in the array.
-\end{itemize}
-It returns a dynamic object that has the capacity to contain dim number of objects, each of the size of type @T@. The returned object is aligned to the given parameter align. On failure, it returns a @NULL@ pointer.
-
-\subsection{\lstinline{T * cmemalign( size_t align, size_t dim  )}}
-This cmemalign is a simplified polymorphic form of above cmemalign (FIX ME: cite cmemalign). It takes two parameter as compared to the above cmemalign that takes three parameters.
-\paragraph{Usage}
-cmemalign takes two parameters.
-
-\begin{itemize}
-\item
-@align@: required alignment of the dynamic array.
-\item
-@dim@: required number of objects in the array.
-\end{itemize}
-It returns a dynamic object that has the capacity to contain dim number of objects, each of the size of type @T@. The returned object is aligned to the given parameter align and is zero filled. On failure, it returns a @NULL@ pointer.
-
-\subsection{\lstinline{T * aligned_alloc( size_t align )}}
-This @aligned_alloc@ is a simplified polymorphic form of defualt @aligned_alloc@ (FIX ME: cite @aligned_alloc@). It takes one parameter as compared to the default @aligned_alloc@ that takes two parameters.
-\paragraph{Usage}
-This @aligned_alloc@ takes one parameter.
-
-\begin{itemize}
-\item
-@align@: required alignment of the dynamic object.
-\end{itemize}
-It returns a dynamic object of the size of type @T@ that is aligned to the given parameter. On failure, it returns a @NULL@ pointer.
-
-\subsection{\lstinline{int posix_memalign( T ** ptr, size_t align )}}
-This @posix_memalign@ is a simplified polymorphic form of defualt @posix_memalign@ (FIX ME: cite @posix_memalign@). It takes two parameters as compared to the default @posix_memalign@ that takes three parameters.
-\paragraph{Usage}
-This @posix_memalign@ takes two parameter.
-
-\begin{itemize}
-\item
-@ptr@: variable address to store the address of the allocated object.
-\item
-@align@: required alignment of the dynamic object.
-\end{itemize}
-
-It stores address of the dynamic object of the size of type @T@ in given parameter ptr. This object is aligned to the given parameter. On failure, it returns a @NULL@ pointer.
-
-\subsection{\lstinline{T * valloc( void )}}
-This @valloc@ is a simplified polymorphic form of defualt @valloc@ (FIX ME: cite @valloc@). It takes no parameters as compared to the default @valloc@ that takes one parameter.
-\paragraph{Usage}
-@valloc@ takes no parameters.
-It returns a dynamic object of the size of type @T@ that is aligned to the page size. On failure, it returns a @NULL@ pointer.
-
-\subsection{\lstinline{T * pvalloc( void )}}
-\paragraph{Usage}
-@pvalloc@ takes no parameters.
-It returns a dynamic object of the size that is calcutaed by rouding the size of type @T@. The returned object is also aligned to the page size. On failure, it returns a @NULL@ pointer.
-
-\subsection{Alloc Interface}
-In addition to improve allocator interface both for \CFA and our standalone allocator uHeap in C. We also added a new alloc interface in \CFA that increases usability of dynamic memory allocation.
-This interface helps programmers in three major ways.
-
-\begin{itemize}
-\item
-Routine Name: alloc interfce frees programmers from remmebring different routine names for different kind of dynamic allocations.
-\item
-Parametre Positions: alloc interface frees programmers from remembering parameter postions in call to routines.
-\item
-Object Size: alloc interface does not require programmer to mention the object size as \CFA allows allocator to determince the object size from returned type of alloc call.
-\end{itemize}
-
-Alloc interface uses polymorphism, backtick routines (FIX ME: cite backtick) and ttype parameters of \CFA (FIX ME: cite ttype) to provide a very simple dynamic memory allocation interface to the programmers. The new interfece has just one routine name alloc that can be used to perform a wide range of dynamic allocations. The parameters use backtick functions to provide a similar-to named parameters feature for our alloc interface so that programmers do not have to remember parameter positions in alloc call except the position of dimension (dim) parameter.
-
-\subsection{Routine: \lstinline{T * alloc( ... )}}
-Call to alloc wihout any parameter returns one object of size of type @T@ allocated dynamically.
-Only the dimension (dim) parameter for array allocation has the fixed position in the alloc routine. If programmer wants to allocate an array of objects that the required number of members in the array has to be given as the first parameter to the alloc routine.
-alocc routine accepts six kinds of arguments. Using different combinations of tha parameters, different kind of allocations can be performed. Any combincation of parameters can be used together except @`realloc@ and @`resize@ that should not be used simultanously in one call to routine as it creates ambiguity about whether to reallocate or resize a currently allocated dynamic object. If both @`resize@ and @`realloc@ are used in a call to alloc then the latter one will take effect or unexpected resulted might be produced.
-
-\paragraph{Dim}
-This is the only parameter in the alloc routine that has a fixed-position and it is also the only parameter that does not use a backtick function. It has to be passed at the first position to alloc call in-case of an array allocation of objects of type @T@.
-It represents the required number of members in the array allocation as in \CFA's aalloc (FIX ME: cite aalloc).
-This parameter should be of type @size_t@.
-
-Example: @int a = alloc( 5 )@
-This call will return a dynamic array of five integers.
-
-\paragraph{Align}
-This parameter is position-free and uses a backtick routine align (@`align@). The parameter passed with @`align@ should be of type @size_t@. If the alignment parameter is not a power of two or is less than the default alignment of the allocator (that can be found out using routine libAlign in \CFA) then the passed alignment parameter will be rejected and the default alignment will be used.
-
-Example: @int b = alloc( 5 , 64`align )@
-This call will return a dynamic array of five integers. It will align the allocated object to 64.
-
-\paragraph{Fill}
-This parameter is position-free and uses a backtick routine fill (@`fill@). In case of @realloc@, only the extra space after copying the data in the old object will be filled with given parameter.
-Three types of parameters can be passed using `fill.
-
-\begin{itemize}
-\item
-@char@: A char can be passed with @`fill@ to fill the whole dynamic allocation with the given char recursively till the end of required allocation.
-\item
-Object of returned type: An object of type of returned type can be passed with @`fill@ to fill the whole dynamic allocation with the given object recursively till the end of required allocation.
-\item
-Dynamic object of returned type: A dynamic object of type of returned type can be passed with @`fill@ to fill the dynamic allocation with the given dynamic object. In this case, the allocated memory is not filled recursively till the end of allocation. The filling happen untill the end object passed to @`fill@ or the end of requested allocation reaches.
-\end{itemize}
-
-Example: @int b = alloc( 5 , 'a'`fill )@
-This call will return a dynamic array of five integers. It will fill the allocated object with character 'a' recursively till the end of requested allocation size.
-
-Example: @int b = alloc( 5 , 4`fill )@
-This call will return a dynamic array of five integers. It will fill the allocated object with integer 4 recursively till the end of requested allocation size.
-
-Example: @int b = alloc( 5 , a`fill )@ where @a@ is a pointer of int type
-This call will return a dynamic array of five integers. It will copy data in a to the returned object non-recursively untill end of a or the newly allocated object is reached.
-
-\paragraph{Resize}
-This parameter is position-free and uses a backtick routine resize (@`resize@). It represents the old dynamic object (oaddr) that the programmer wants to
-\begin{itemize}
-\item
-resize to a new size.
-\item
-realign to a new alignment
-\item
-fill with something.
-\end{itemize}
-The data in old dynamic object will not be preserved in the new object. The type of object passed to @`resize@ and the returned type of alloc call can be different.
-
-Example: @int b = alloc( 5 , a`resize )@
-This call will resize object a to a dynamic array that can contain 5 integers.
-
-Example: @int b = alloc( 5 , a`resize , 32`align )@
-This call will resize object a to a dynamic array that can contain 5 integers. The returned object will also be aligned to 32.
-
-Example: @int b = alloc( 5 , a`resize , 32`align , 2`fill )@
-This call will resize object a to a dynamic array that can contain 5 integers. The returned object will also be aligned to 32 and will be filled with 2.
-
-\paragraph{Realloc}
-This parameter is position-free and uses a backtick routine @realloc@ (@`realloc@). It represents the old dynamic object (oaddr) that the programmer wants to
-\begin{itemize}
-\item
-realloc to a new size.
-\item
-realign to a new alignment
-\item
-fill with something.
-\end{itemize}
-The data in old dynamic object will be preserved in the new object. The type of object passed to @`realloc@ and the returned type of alloc call cannot be different.
-
-Example: @int b = alloc( 5 , a`realloc )@
-This call will realloc object a to a dynamic array that can contain 5 integers.
-
-Example: @int b = alloc( 5 , a`realloc , 32`align )@
-This call will realloc object a to a dynamic array that can contain 5 integers. The returned object will also be aligned to 32.
-
-Example: @int b = alloc( 5 , a`realloc , 32`align , 2`fill )@
-This call will resize object a to a dynamic array that can contain 5 integers. The returned object will also be aligned to 32. The extra space after copying data of a to the returned object will be filled with 2.
+\begin{itemize}
+\item
+@addr@: address of an allocated object.
+\end{itemize}
+It returns the request size or zero if @addr@ is @NULL@.
+
+\paragraph{\lstinline{int malloc_stats_fd( int fd )}}
+changes the file descriptor where @malloc_stats@ writes statistics (default @stdout@).
+
+\noindent\textbf{Usage}
+@malloc_stats_fd@ takes one parameters.
+\begin{itemize}
+\item
+@fd@: files description.
+\end{itemize}
+It returns the previous file descriptor.
+
+\paragraph{\lstinline{size_t malloc_expansion()}}
+\label{p:malloc_expansion}
+set the amount (bytes) to extend the heap when there is insufficient free storage to service an allocation request.
+It returns the heap extension size used throughout a program, \ie called once at heap initialization.
+
+\paragraph{\lstinline{size_t malloc_mmap_start()}}
+set the crossover between allocations occurring in the @sbrk@ area or separately mapped.
+It returns the crossover point used throughout a program, \ie called once at heap initialization.
+
+\paragraph{\lstinline{size_t malloc_unfreed()}}
+\label{p:malloc_unfreed}
+amount subtracted to adjust for unfreed program storage (debug only).
+It returns the new subtraction amount and called by @malloc_stats@.
+
+
+\subsection{\CC Interface}
+
+The following extensions take advantage of overload polymorphism in the \CC type-system.
+
+\paragraph{\lstinline{void * resize( void * oaddr, size_t nalign, size_t size )}}
+extends @resize@ with an alignment re\-quirement.
+
+\noindent\textbf{Usage}
+takes three parameters.
+\begin{itemize}
+\item
+@oaddr@: address to be resized
+\item
+@nalign@: alignment requirement
+\item
+@size@: new allocation size (smaller or larger than previous)
+\end{itemize}
+It returns the address of the old or new storage with the specified new size and alignment, or @NULL@ if @size@ is zero.
+
+\paragraph{\lstinline{void * realloc( void * oaddr, size_t nalign, size_t size )}}
+extends @realloc@ with an alignment re\-quirement and has the same usage as aligned @resize@.
+
+
+\subsection{\CFA Interface}
+
+The following extensions take advantage of overload polymorphism in the \CFA type-system.
+The key safety advantage of the \CFA type system is using the return type to select overloads;
+hence, a polymorphic routine knows the returned type and its size.
+This capability is used to remove the object size parameter and correctly cast the return storage to match the result type.
+For example, the following is the \CFA wrapper for C @malloc@:
+\begin{cfa}
+forall( T & | sized(T) ) {
+	T * malloc( void ) {
+		if ( _Alignof(T) <= libAlign() ) return @(T *)@malloc( @sizeof(T)@ ); // C allocation
+		else return @(T *)@memalign( @_Alignof(T)@, @sizeof(T)@ ); // C allocation
+	} // malloc
+\end{cfa}
+and is used as follows:
+\begin{lstlisting}
+int * i = malloc();
+double * d = malloc();
+struct Spinlock { ... } __attribute__(( aligned(128) ));
+Spinlock * sl = malloc();
+\end{lstlisting}
+where each @malloc@ call provides the return type as @T@, which is used with @sizeof@, @_Alignof@, and casting the storage to the correct type.
+This interface removes many of the common allocation errors in C programs.
+\VRef[Figure]{f:CFADynamicAllocationAPI} show the \CFA wrappers for the equivalent C/\CC allocation routines with same semantic behaviour.
+
+\begin{figure}
+\begin{lstlisting}
+T * malloc( void );
+T * aalloc( size_t dim );
+T * calloc( size_t dim );
+T * resize( T * ptr, size_t size );
+T * realloc( T * ptr, size_t size );
+T * memalign( size_t align );
+T * amemalign( size_t align, size_t dim );
+T * cmemalign( size_t align, size_t dim  );
+T * aligned_alloc( size_t align );
+int posix_memalign( T ** ptr, size_t align );
+T * valloc( void );
+T * pvalloc( void );
+\end{lstlisting}
+\caption{\CFA C-Style Dynamic-Allocation API}
+\label{f:CFADynamicAllocationAPI}
+\end{figure}
+
+In addition to the \CFA C-style allocator interface, a new allocator interface is provided to further increase orthogonality and usability of dynamic-memory allocation.
+This interface helps programmers in three ways.
+\begin{itemize}
+\item
+naming: \CFA regular and @ttype@ polymorphism is used to encapsulate a wide range of allocation functionality into a single routine name, so programmers do not have to remember multiple routine names for different kinds of dynamic allocations.
+\item
+named arguments: individual allocation properties are specified using postfix function call, so programmers do have to remember parameter positions in allocation calls.
+\item
+object size: like the \CFA C-style interface, programmers do not have to specify object size or cast allocation results.
+\end{itemize}
+Note, postfix function call is an alternative call syntax, using backtick @`@, where the argument appears before the function name, \eg
+\begin{cfa}
+duration ?@`@h( int h );		// ? denote the position of the function operand
+duration ?@`@m( int m );
+duration ?@`@s( int s );
+duration dur = 3@`@h + 42@`@m + 17@`@s;
+\end{cfa}
+@ttype@ polymorphism is similar to \CC variadic templates.
+
+\paragraph{\lstinline{T * alloc( ... )} or \lstinline{T * alloc( size_t dim, ... )}}
+is overloaded with a variable number of specific allocation routines, or an integer dimension parameter followed by a variable number specific allocation routines.
+A call without parameters returns a dynamically allocated object of type @T@ (@malloc@).
+A call with only the dimension (dim) parameter returns a dynamically allocated array of objects of type @T@ (@aalloc@).
+The variable number of arguments consist of allocation properties, which can be combined to produce different kinds of allocations.
+The only restriction is for properties @realloc@ and @resize@, which cannot be combined.
+
+The allocation property functions are:
+\subparagraph{\lstinline{T_align ?`align( size_t alignment )}}
+to align the allocation.
+The alignment parameter must be $\ge$ the default alignment (@libAlign()@ in \CFA) and a power of two, \eg:
+\begin{cfa}
+int * i0 = alloc( @4096`align@ );  sout | i0 | nl;
+int * i1 = alloc( 3, @4096`align@ );  sout | i1; for (i; 3 ) sout | &i1[i]; sout | nl;
+
+0x555555572000
+0x555555574000 0x555555574000 0x555555574004 0x555555574008
+\end{cfa}
+returns a dynamic object and object array aligned on a 4096-byte boundary.
+
+\subparagraph{\lstinline{S_fill(T) ?`fill ( /* various types */ )}}
+to initialize storage.
+There are three ways to fill storage:
+\begin{enumerate}
+\item
+A char fills each byte of each object.
+\item
+An object of the returned type fills each object.
+\item
+An object array pointer fills some or all of the corresponding object array.
+\end{enumerate}
+For example:
+\begin{cfa}[numbers=left]
+int * i0 = alloc( @0n`fill@ );  sout | *i0 | nl;  // disambiguate 0
+int * i1 = alloc( @5`fill@ );  sout | *i1 | nl;
+int * i2 = alloc( @'\xfe'`fill@ ); sout | hex( *i2 ) | nl;
+int * i3 = alloc( 5, @5`fill@ );  for ( i; 5 ) sout | i3[i]; sout | nl;
+int * i4 = alloc( 5, @0xdeadbeefN`fill@ );  for ( i; 5 ) sout | hex( i4[i] ); sout | nl;
+int * i5 = alloc( 5, @i3`fill@ );  for ( i; 5 ) sout | i5[i]; sout | nl;
+int * i6 = alloc( 5, @[i3, 3]`fill@ );  for ( i; 5 ) sout | i6[i]; sout | nl;
+\end{cfa}
+\begin{lstlisting}[numbers=left]
+0
+5
+0xfefefefe
+5 5 5 5 5
+0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
+5 5 5 5 5
+5 5 5 -555819298 -555819298  // two undefined values
+\end{lstlisting}
+Examples 1 to 3, fill an object with a value or characters.
+Examples 4 to 7, fill an array of objects with values, another array, or part of an array.
+
+\subparagraph{\lstinline{S_resize(T) ?`resize( void * oaddr )}}
+used to resize, realign, and fill, where the old object data is not copied to the new object.
+The old object type may be different from the new object type, since the values are not used.
+For example:
+\begin{cfa}[numbers=left]
+int * i = alloc( @5`fill@ );  sout | i | *i;
+i = alloc( @i`resize@, @256`align@, @7`fill@ );  sout | i | *i;
+double * d = alloc( @i`resize@, @4096`align@, @13.5`fill@ );  sout | d | *d;
+\end{cfa}
+\begin{lstlisting}[numbers=left]
+0x55555556d5c0 5
+0x555555570000 7
+0x555555571000 13.5
+\end{lstlisting}
+Examples 2 to 3 change the alignment, fill, and size for the initial storage of @i@.
+
+\begin{cfa}[numbers=left]
+int * ia = alloc( 5, @5`fill@ );  for ( i; 5 ) sout | ia[i]; sout | nl;
+ia = alloc( 10, @ia`resize@, @7`fill@ ); for ( i; 10 ) sout | ia[i]; sout | nl;
+sout | ia; ia = alloc( 5, @ia`resize@, @512`align@, @13`fill@ ); sout | ia; for ( i; 5 ) sout | ia[i]; sout | nl;;
+ia = alloc( 3, @ia`resize@, @4096`align@, @2`fill@ );  sout | ia; for ( i; 3 ) sout | &ia[i] | ia[i]; sout | nl;
+\end{cfa}
+\begin{lstlisting}[numbers=left]
+5 5 5 5 5
+7 7 7 7 7 7 7 7 7 7
+0x55555556d560 0x555555571a00 13 13 13 13 13
+0x555555572000 0x555555572000 2 0x555555572004 2 0x555555572008 2
+\end{lstlisting}
+Examples 2 to 4 change the array size, alignment and fill for the initial storage of @ia@.
+
+\subparagraph{\lstinline{S_realloc(T) ?`realloc( T * a ))}}
+used to resize, realign, and fill, where the old object data is copied to the new object.
+The old object type must be the same as the new object type, since the values used.
+Note, for @fill@, only the extra space after copying the data from the old object is filled with the given parameter.
+For example:
+\begin{cfa}[numbers=left]
+int * i = alloc( @5`fill@ );  sout | i | *i;
+i = alloc( @i`realloc@, @256`align@ );  sout | i | *i;
+i = alloc( @i`realloc@, @4096`align@, @13`fill@ );  sout | i | *i;
+\end{cfa}
+\begin{lstlisting}[numbers=left]
+0x55555556d5c0 5
+0x555555570000 5
+0x555555571000 5
+\end{lstlisting}
+Examples 2 to 3 change the alignment for the initial storage of @i@.
+The @13`fill@ for example 3 does nothing because no extra space is added.
+
+\begin{cfa}[numbers=left]
+int * ia = alloc( 5, @5`fill@ );  for ( i; 5 ) sout | ia[i]; sout | nl;
+ia = alloc( 10, @ia`realloc@, @7`fill@ ); for ( i; 10 ) sout | ia[i]; sout | nl;
+sout | ia; ia = alloc( 1, @ia`realloc@, @512`align@, @13`fill@ ); sout | ia; for ( i; 1 ) sout | ia[i]; sout | nl;;
+ia = alloc( 3, @ia`realloc@, @4096`align@, @2`fill@ );  sout | ia; for ( i; 3 ) sout | &ia[i] | ia[i]; sout | nl;
+\end{cfa}
+\begin{lstlisting}[numbers=left]
+5 5 5 5 5
+5 5 5 5 5 7 7 7 7 7
+0x55555556c560 0x555555570a00 5
+0x555555571000 0x555555571000 5 0x555555571004 2 0x555555571008 2
+\end{lstlisting}
+Examples 2 to 4 change the array size, alignment and fill for the initial storage of @ia@.
+The @13`fill@ for example 3 does nothing because no extra space is added.
+
+These \CFA allocation features are used extensively in the development of the \CFA runtime.
Index: doc/theses/mubeen_zulfiqar_MMath/background.tex
===================================================================
--- doc/theses/mubeen_zulfiqar_MMath/background.tex	(revision ba897d2136bc02c8b8a01751cd212c9a145a8df7)
+++ doc/theses/mubeen_zulfiqar_MMath/background.tex	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
@@ -34,7 +34,7 @@
 \VRef[Figure]{f:AllocatorComponents} shows the two important data components for a memory allocator, management and storage, collectively called the \newterm{heap}.
 The \newterm{management data} is a data structure located at a known memory address and contains all information necessary to manage the storage data.
-The management data starts with fixed-sized information in the static-data memory that flows into the dynamic-allocation memory.
+The management data starts with fixed-sized information in the static-data memory that references components in the dynamic-allocation memory.
 The \newterm{storage data} is composed of allocated and freed objects, and \newterm{reserved memory}.
-Allocated objects (white) are variable sized, and allocated and maintained by the program;
+Allocated objects (light grey) are variable sized, and allocated and maintained by the program;
 \ie only the program knows the location of allocated storage, not the memory allocator.
 \begin{figure}[h]
@@ -44,5 +44,5 @@
 \label{f:AllocatorComponents}
 \end{figure}
-Freed objects (light grey) are memory deallocated by the program, which are linked into one or more lists facilitating easy location for new allocations.
+Freed objects (white) represent memory deallocated by the program, which are linked into one or more lists facilitating easy location of new allocations.
 Often the free list is chained internally so it does not consume additional storage, \ie the link fields are placed at known locations in the unused memory blocks.
 Reserved memory (dark grey) is one or more blocks of memory obtained from the operating system but not yet allocated to the program;
@@ -54,5 +54,6 @@
 The trailer may be used to simplify an allocation implementation, \eg coalescing, and/or for security purposes to mark the end of an object.
 An object may be preceded by padding to ensure proper alignment.
-Some algorithms quantize allocation requests into distinct sizes resulting in additional spacing after objects less than the quantized value.
+Some algorithms quantize allocation requests into distinct sizes, called \newterm{buckets}, resulting in additional spacing after objects less than the quantized value.
+(Note, the buckets are often organized as an array of ascending bucket sizes for fast searching, \eg binary search, and the array is stored in the heap management-area, where each bucket is a top point to the freed objects of that size.)
 When padding and spacing are necessary, neither can be used to satisfy a future allocation request while the current allocation exists.
 A free object also contains management data, \eg size, chaining, etc.
@@ -81,5 +82,5 @@
 Fragmentation is memory requested from the operating system but not used by the program;
 hence, allocated objects are not fragmentation.
-\VRef[Figure]{f:InternalExternalFragmentation}) shows fragmentation is divided into two forms: internal or external.
+\VRef[Figure]{f:InternalExternalFragmentation} shows fragmentation is divided into two forms: internal or external.
 
 \begin{figure}
@@ -96,5 +97,5 @@
 An allocator should strive to keep internal management information to a minimum.
 
-\newterm{External fragmentation} is all memory space reserved from the operating system but not allocated to the program~\cite{Wilson95,Lim98,Siebert00}, which includes freed objects, all external management data, and reserved memory.
+\newterm{External fragmentation} is all memory space reserved from the operating system but not allocated to the program~\cite{Wilson95,Lim98,Siebert00}, which includes all external management data, freed objects, and reserved memory.
 This memory is problematic in two ways: heap blowup and highly fragmented memory.
 \newterm{Heap blowup} occurs when memory freed by the program is not reused for future allocations leading to potentially unbounded external fragmentation growth~\cite{Berger00}.
@@ -125,5 +126,5 @@
 \end{figure}
 
-For a single-threaded memory allocator, three basic approaches for controlling fragmentation have been identified~\cite{Johnstone99}.
+For a single-threaded memory allocator, three basic approaches for controlling fragmentation are identified~\cite{Johnstone99}.
 The first approach is a \newterm{sequential-fit algorithm} with one list of free objects that is searched for a block large enough to fit a requested object size.
 Different search policies determine the free object selected, \eg the first free object large enough or closest to the requested size.
@@ -132,5 +133,5 @@
 
 The second approach is a \newterm{segregated} or \newterm{binning algorithm} with a set of lists for different sized freed objects.
-When an object is allocated, the requested size is rounded up to the nearest bin-size, possibly with spacing after the object.
+When an object is allocated, the requested size is rounded up to the nearest bin-size, often leading to spacing after the object.
 A binning algorithm is fast at finding free memory of the appropriate size and allocating it, since the first free object on the free list is used.
 The fewer bin-sizes, the fewer lists need to be searched and maintained;
@@ -158,5 +159,5 @@
 Temporal locality commonly occurs during an iterative computation with a fix set of disjoint variables, while spatial locality commonly occurs when traversing an array.
 
-Hardware takes advantage of temporal and spatial locality through multiple levels of caching (\ie memory hierarchy).
+Hardware takes advantage of temporal and spatial locality through multiple levels of caching, \ie memory hierarchy.
 When an object is accessed, the memory physically located around the object is also cached with the expectation that the current and nearby objects will be referenced within a short period of time.
 For example, entire cache lines are transferred between memory and cache and entire virtual-memory pages are transferred between disk and memory.
@@ -171,5 +172,5 @@
 
 There are a number of ways a memory allocator can degrade locality by increasing the working set.
-For example, a memory allocator may access multiple free objects before finding one to satisfy an allocation request (\eg sequential-fit algorithm).
+For example, a memory allocator may access multiple free objects before finding one to satisfy an allocation request, \eg sequential-fit algorithm.
 If there are a (large) number of objects accessed in very different areas of memory, the allocator may perturb the program's memory hierarchy causing multiple cache or page misses~\cite{Grunwald93}.
 Another way locality can be degraded is by spatially separating related data.
@@ -181,5 +182,5 @@
 
 A multi-threaded memory-allocator does not run any threads itself, but is used by a multi-threaded program.
-In addition to single-threaded design issues of locality and fragmentation, a multi-threaded allocator may be simultaneously accessed by multiple threads, and hence, must deal with concurrency issues such as mutual exclusion, false sharing, and additional forms of heap blowup.
+In addition to single-threaded design issues of fragmentation and locality, a multi-threaded allocator is simultaneously accessed by multiple threads, and hence, must deal with concurrency issues such as mutual exclusion, false sharing, and additional forms of heap blowup.
 
 
@@ -192,8 +193,13 @@
 Second is when multiple threads contend for a shared resource simultaneously, and hence, some threads must wait until the resource is released.
 Contention can be reduced in a number of ways:
+\begin{itemize}[itemsep=0pt]
+\item
 using multiple fine-grained locks versus a single lock, spreading the contention across a number of locks;
+\item
 using trylock and generating new storage if the lock is busy, yielding a classic space versus time tradeoff;
+\item
 using one of the many lock-free approaches for reducing contention on basic data-structure operations~\cite{Oyama99}.
-However, all of these approaches have degenerate cases where contention occurs.
+\end{itemize}
+However, all of these approaches have degenerate cases where program contention is high, which occurs outside of the allocator.
 
 
@@ -275,5 +281,5 @@
 \label{s:MultipleHeaps}
 
-A single-threaded allocator has at most one thread and heap, while a multi-threaded allocator has potentially multiple threads and heaps.
+A multi-threaded allocator has potentially multiple threads and heaps.
 The multiple threads cause complexity, and multiple heaps are a mechanism for dealing with the complexity.
 The spectrum ranges from multiple threads using a single heap, denoted as T:1 (see \VRef[Figure]{f:SingleHeap}), to multiple threads sharing multiple heaps, denoted as T:H (see \VRef[Figure]{f:SharedHeaps}), to one thread per heap, denoted as 1:1 (see \VRef[Figure]{f:PerThreadHeap}), which is almost back to a single-threaded allocator.
@@ -339,5 +345,5 @@
 An alternative implementation is for all heaps to share one reserved memory, which requires a separate lock for the reserved storage to ensure mutual exclusion when acquiring new memory.
 Because multiple threads can allocate/free/reallocate adjacent storage, all forms of false sharing may occur.
-Other storage-management options are to use @mmap@ to set aside (large) areas of virtual memory for each heap and suballocate each heap's storage within that area.
+Other storage-management options are to use @mmap@ to set aside (large) areas of virtual memory for each heap and suballocate each heap's storage within that area, pushing part of the storage management complexity back to the operating system.
 
 \begin{figure}
@@ -368,5 +374,5 @@
 
 
-\paragraph{1:1 model (thread heaps)} where each thread has its own heap, which eliminates most contention and locking because threads seldom accesses another thread's heap (see ownership in \VRef{s:Ownership}).
+\paragraph{1:1 model (thread heaps)} where each thread has its own heap eliminating most contention and locking because threads seldom access another thread's heap (see ownership in \VRef{s:Ownership}).
 An additional benefit of thread heaps is improved locality due to better memory layout.
 As each thread only allocates from its heap, all objects for a thread are consolidated in the storage area for that heap, better utilizing each CPUs cache and accessing fewer pages.
@@ -380,5 +386,5 @@
 Second is to place the thread heap on a list of available heaps and reuse it for a new thread in the future.
 Destroying the thread heap immediately may reduce external fragmentation sooner, since all free objects are freed to the global heap and may be reused by other threads.
-Alternatively, reusing thread heaps may improve performance if the inheriting thread makes similar allocation requests as the thread that previously held the thread heap.
+Alternatively, reusing thread heaps may improve performance if the inheriting thread makes similar allocation requests as the thread that previously held the thread heap because any unfreed storage is immediately accessible..
 
 
@@ -388,5 +394,5 @@
 However, an important goal of user-level threading is for fast operations (creation/termination/context-switching) by not interacting with the operating system, which allows the ability to create large numbers of high-performance interacting threads ($>$ 10,000).
 It is difficult to retain this goal, if the user-threading model is directly involved with the heap model.
-\VRef[Figure]{f:UserLevelKernelHeaps} shows that virtually all user-level threading systems use whatever kernel-level heap-model provided by the language runtime.
+\VRef[Figure]{f:UserLevelKernelHeaps} shows that virtually all user-level threading systems use whatever kernel-level heap-model is provided by the language runtime.
 Hence, a user thread allocates/deallocates from/to the heap of the kernel thread on which it is currently executing.
 
@@ -400,6 +406,5 @@
 Adopting this model results in a subtle problem with shared heaps.
 With kernel threading, an operation that is started by a kernel thread is always completed by that thread.
-For example, if a kernel thread starts an allocation/deallocation on a shared heap, it always completes that operation with that heap even if preempted.
-Any correctness locking associated with the shared heap is preserved across preemption.
+For example, if a kernel thread starts an allocation/deallocation on a shared heap, it always completes that operation with that heap even if preempted, \ie any locking correctness associated with the shared heap is preserved across preemption.
 
 However, this correctness property is not preserved for user-level threading.
@@ -409,5 +414,5 @@
 However, eagerly disabling/enabling time-slicing on the allocation/deallocation fast path is expensive, because preemption is rare (10--100 milliseconds).
 Instead, techniques exist to lazily detect this case in the interrupt handler, abort the preemption, and return to the operation so it can complete atomically.
-Occasionally ignoring a preemption should be benign.
+Occasionally ignoring a preemption should be benign, but a persistent lack of preemption can result in both short and long term starvation.
 
 
@@ -430,6 +435,6 @@
 
 \newterm{Ownership} defines which heap an object is returned-to on deallocation.
-If a thread returns an object to the heap it was originally allocated from, the heap has ownership of its objects.
-Alternatively, a thread can return an object to the heap it is currently allocating from, which can be any heap accessible during a thread's lifetime.
+If a thread returns an object to the heap it was originally allocated from, a heap has ownership of its objects.
+Alternatively, a thread can return an object to the heap it is currently associated with, which can be any heap accessible during a thread's lifetime.
 \VRef[Figure]{f:HeapsOwnership} shows an example of multiple heaps (minus the global heap) with and without ownership.
 Again, the arrows indicate the direction memory conceptually moves for each kind of operation.
@@ -539,4 +544,5 @@
 Only with the 1:1 model and ownership is active and passive false-sharing avoided (see \VRef{s:Ownership}).
 Passive false-sharing may still occur, if delayed ownership is used.
+Finally, a completely free container can become reserved storage and be reset to allocate objects of a new size or freed to the global heap.
 
 \begin{figure}
@@ -553,10 +559,4 @@
 \caption{Free-list Structure with Container Ownership}
 \end{figure}
-
-A fragmented heap has multiple containers that may be partially or completely free.
-A completely free container can become reserved storage and be reset to allocate objects of a new size.
-When a heap reaches a threshold of free objects, it moves some free storage to the global heap for reuse to prevent heap blowup.
-Without ownership, when a heap frees objects to the global heap, individual objects must be passed, and placed on the global-heap's free-list.
-Containers cannot be freed to the global heap unless completely free because
 
 When a container changes ownership, the ownership of all objects within it change as well.
@@ -569,5 +569,5 @@
 Note, once the object is freed by Task$_1$, no more false sharing can occur until the container changes ownership again.
 To prevent this form of false sharing, container movement may be restricted to when all objects in the container are free.
-One implementation approach that increases the freedom to return a free container to the operating system involves allocating containers using a call like @mmap@, which allows memory at an arbitrary address to be returned versus only storage at the end of the contiguous @sbrk@ area.
+One implementation approach that increases the freedom to return a free container to the operating system involves allocating containers using a call like @mmap@, which allows memory at an arbitrary address to be returned versus only storage at the end of the contiguous @sbrk@ area, again pushing storage management complexity back to the operating system.
 
 \begin{figure}
@@ -700,5 +700,5 @@
 \end{figure}
 
-As mentioned, an implementation may have only one heap deal with the global heap, so the other heap can be simplified.
+As mentioned, an implementation may have only one heap interact with the global heap, so the other heap can be simplified.
 For example, if only the private heap interacts with the global heap, the public heap can be reduced to a lock-protected free-list of objects deallocated by other threads due to ownership, called a \newterm{remote free-list}.
 To avoid heap blowup, the private heap allocates from the remote free-list when it reaches some threshold or it has no free storage.
@@ -721,11 +721,11 @@
 An allocation buffer is reserved memory (see~\VRef{s:AllocatorComponents}) not yet allocated to the program, and is used for allocating objects when the free list is empty.
 That is, rather than requesting new storage for a single object, an entire buffer is requested from which multiple objects are allocated later.
-Both any heap may use an allocation buffer, resulting in allocation from the buffer before requesting objects (containers) from the global heap or operating system, respectively.
+Any heap may use an allocation buffer, resulting in allocation from the buffer before requesting objects (containers) from the global heap or operating system, respectively.
 The allocation buffer reduces contention and the number of global/operating-system calls.
 For coalescing, a buffer is split into smaller objects by allocations, and recomposed into larger buffer areas during deallocations.
 
-Allocation buffers are useful initially when there are no freed objects in a heap because many allocations usually occur when a thread starts.
+Allocation buffers are useful initially when there are no freed objects in a heap because many allocations usually occur when a thread starts (simple bump allocation).
 Furthermore, to prevent heap blowup, objects should be reused before allocating a new allocation buffer.
-Thus, allocation buffers are often allocated more frequently at program/thread start, and then their use often diminishes.
+Thus, allocation buffers are often allocated more frequently at program/thread start, and then allocations often diminish.
 
 Using an allocation buffer with a thread heap avoids active false-sharing, since all objects in the allocation buffer are allocated to the same thread.
@@ -746,14 +746,14 @@
 \label{s:LockFreeOperations}
 
-A lock-free algorithm guarantees safe concurrent-access to a data structure, so that at least one thread can make progress in the system, but an individual task has no bound to execution, and hence, may starve~\cite[pp.~745--746]{Herlihy93}.
-% A wait-free algorithm puts a finite bound on the number of steps any thread takes to complete an operation, so an individual task cannot starve
+A \newterm{lock-free algorithm} guarantees safe concurrent-access to a data structure, so that at least one thread makes progress, but an individual task has no execution bound and may starve~\cite[pp.~745--746]{Herlihy93}.
+(A \newterm{wait-free algorithm} puts a bound on the number of steps any thread takes to complete an operation to prevent starvation.)
 Lock-free operations can be used in an allocator to reduce or eliminate the use of locks.
-Locks are a problem for high contention or if the thread holding the lock is preempted and other threads attempt to use that lock.
-With respect to the heap, these situations are unlikely unless all threads makes extremely high use of dynamic-memory allocation, which can be an indication of poor design.
+While locks and lock-free data-structures often have equal performance, lock-free has the advantage of not holding a lock across preemption so other threads can continue to make progress.
+With respect to the heap, these situations are unlikely unless all threads make extremely high use of dynamic-memory allocation, which can be an indication of poor design.
 Nevertheless, lock-free algorithms can reduce the number of context switches, since a thread does not yield/block while waiting for a lock;
-on the other hand, a thread may busy-wait for an unbounded period.
+on the other hand, a thread may busy-wait for an unbounded period holding a processor.
 Finally, lock-free implementations have greater complexity and hardware dependency.
 Lock-free algorithms can be applied most easily to simple free-lists, \eg remote free-list, to allow lock-free insertion and removal from the head of a stack.
-Implementing lock-free operations for more complex data-structures (queue~\cite{Valois94}/deque~\cite{Sundell08}) is more complex.
+Implementing lock-free operations for more complex data-structures (queue~\cite{Valois94}/deque~\cite{Sundell08}) is correspondingly more complex.
 Michael~\cite{Michael04} and Gidenstam \etal \cite{Gidenstam05} have created lock-free variations of the Hoard allocator.
 
Index: doc/theses/mubeen_zulfiqar_MMath/figures/Alignment1.fig
===================================================================
--- doc/theses/mubeen_zulfiqar_MMath/figures/Alignment1.fig	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
+++ doc/theses/mubeen_zulfiqar_MMath/figures/Alignment1.fig	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
@@ -0,0 +1,35 @@
+#FIG 3.2  Produced by xfig version 3.2.7b
+Landscape
+Center
+Inches
+Letter
+100.00
+Single
+-2
+1200 2
+5 1 0 1 0 7 50 -1 -1 0.000 0 1 1 0 4350.000 -13893.750 2175 1725 4200 1875 6525 1725
+	1 1 1.00 45.00 90.00
+6 6525 1575 7650 1800
+4 0 0 50 -1 4 12 0.0000 2 195 1095 6525 1725 E$^{\\prime}$\001
+-6
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 4
+	 1200 1200 2100 1200 2100 1500 1200 1500
+2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2
+	 5700 1200 5700 1500
+2 2 0 0 0 7 60 -1 18 0.000 0 0 -1 0 0 5
+	 5700 1200 6600 1200 6600 1500 5700 1500 5700 1200
+2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2
+	 4200 1200 4200 1500
+2 2 0 1 0 7 50 -1 18 0.000 0 0 -1 0 0 5
+	 2100 1200 3300 1200 3300 1500 2100 1500 2100 1200
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 3300 1200 6600 1200 6600 1500 3300 1500 3300 1200
+4 1 0 50 -1 4 12 0.0000 2 150 135 2100 1725 E\001
+4 1 0 50 -1 0 12 0.0000 2 180 510 4800 1425 object\001
+4 1 0 50 -1 0 12 0.0000 2 135 585 6150 1425 unused\001
+4 1 0 50 -1 0 12 0.0000 2 180 1185 1650 1425 $\\cdots$  heap\001
+4 0 0 50 -1 4 12 0.0000 2 180 390 4200 1725 A(P)\001
+4 1 0 50 -1 0 12 0.0000 2 135 540 3750 1425 header\001
+4 1 0 50 -1 0 12 0.0000 2 135 300 2700 1425 free\001
+4 1 0 50 -1 4 12 0.0000 2 150 135 3300 1725 H\001
+4 0 0 50 -1 0 12 0.0000 2 180 1200 4650 1725 (multiple of N)\001
Index: doc/theses/mubeen_zulfiqar_MMath/figures/Alignment2.fig
===================================================================
--- doc/theses/mubeen_zulfiqar_MMath/figures/Alignment2.fig	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
+++ doc/theses/mubeen_zulfiqar_MMath/figures/Alignment2.fig	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
@@ -0,0 +1,31 @@
+#FIG 3.2  Produced by xfig version 3.2.7b
+Landscape
+Center
+Inches
+Letter
+100.00
+Single
+-2
+1200 2
+2 1 1 1 0 7 25 -1 -1 4.000 0 0 -1 0 0 2
+	 2100 1500 2100 1800
+2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2
+	 5700 1500 5700 1800
+2 2 0 0 0 7 60 -1 18 0.000 0 0 -1 0 0 5
+	 2100 1500 4200 1500 4200 1800 2100 1800 2100 1500
+2 2 0 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 5
+	 1200 1500 6600 1500 6600 1800 1200 1800 1200 1500
+2 1 1 1 0 7 25 -1 -1 4.000 0 0 -1 0 0 2
+	 4200 1500 4200 1800
+2 2 0 0 0 7 60 -1 18 0.000 0 0 -1 0 0 5
+	 5700 1500 6600 1500 6600 1800 5700 1800 5700 1500
+4 1 0 50 -1 0 12 0.0000 2 135 540 1650 1725 header\001
+4 1 0 50 -1 4 12 0.0000 2 150 135 1200 2025 H\001
+4 1 0 50 -1 4 12 0.0000 2 150 135 2100 2025 P\001
+4 0 0 50 -1 0 12 0.0000 2 180 1575 2175 2025 (min. alignment M)\001
+4 1 0 50 -1 0 12 0.0000 2 180 510 4950 1725 object\001
+4 1 0 50 -1 0 12 0.0000 2 135 315 4950 1425 size\001
+4 1 0 50 -1 0 12 0.0000 2 180 1815 3150 1425 internal fragmentation\001
+4 1 0 50 -1 0 12 0.0000 2 135 585 6150 1725 unused\001
+4 1 0 50 -1 4 12 0.0000 2 150 135 4200 2025 A\001
+4 0 0 50 -1 0 12 0.0000 2 180 1200 4275 2025 (multiple of N)\001
Index: doc/theses/mubeen_zulfiqar_MMath/figures/Alignment2Impl.fig
===================================================================
--- doc/theses/mubeen_zulfiqar_MMath/figures/Alignment2Impl.fig	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
+++ doc/theses/mubeen_zulfiqar_MMath/figures/Alignment2Impl.fig	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
@@ -0,0 +1,35 @@
+#FIG 3.2  Produced by xfig version 3.2.7b
+Landscape
+Center
+Inches
+Letter
+100.00
+Single
+-2
+1200 2
+2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2
+	 2100 1500 2100 1875
+2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2
+	 4200 1500 4200 1875
+2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2
+	 3300 1500 3300 1875
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 3300 1725 2100 1725
+2 2 0 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 5
+	 1200 1500 5700 1500 5700 1875 1200 1875 1200 1500
+2 2 0 0 0 7 60 -1 18 0.000 0 0 -1 0 0 5
+	 2100 1500 3300 1500 3300 1875 2100 1875 2100 1500
+4 1 0 50 -1 0 12 0.0000 2 180 1815 2550 1425 internal fragmentation\001
+4 1 0 50 -1 0 12 0.0000 2 180 510 4950 1725 object\001
+4 1 0 50 -1 0 12 0.0000 2 135 315 4950 1425 size\001
+4 1 0 50 -1 4 12 0.0000 2 150 135 1200 2100 H\001
+4 1 0 50 -1 4 12 0.0000 2 150 135 2100 2100 P\001
+4 0 0 50 -1 0 12 0.0000 2 180 1575 2175 2100 (min. alignment M)\001
+4 1 0 50 -1 4 12 0.0000 2 150 135 4200 2100 A\001
+4 0 0 50 -1 0 12 0.0000 2 180 1200 4275 2100 (multiple of N)\001
+4 1 0 50 -1 0 12 0.0000 2 135 540 3750 1850 header\001
+4 1 0 50 -1 0 12 0.0000 2 135 345 3750 1700 fake\001
+4 1 0 50 -1 0 12 0.0000 2 135 450 2700 1700 offset\001
+4 1 0 50 -1 0 12 0.0000 2 135 540 1650 1850 header\001
+4 1 0 50 -1 0 12 0.0000 2 135 570 1650 1675 normal\001
Index: doc/theses/mubeen_zulfiqar_MMath/figures/AllocDS1.fig
===================================================================
--- doc/theses/mubeen_zulfiqar_MMath/figures/AllocDS1.fig	(revision ba897d2136bc02c8b8a01751cd212c9a145a8df7)
+++ doc/theses/mubeen_zulfiqar_MMath/figures/AllocDS1.fig	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
@@ -8,155 +8,119 @@
 -2
 1200 2
-6 4200 1575 4500 1725
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4275 1650 20 20 4275 1650 4295 1650
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4350 1650 20 20 4350 1650 4370 1650
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4425 1650 20 20 4425 1650 4445 1650
+6 2850 2100 3150 2250
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 2925 2175 20 20 2925 2175 2945 2175
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 3000 2175 20 20 3000 2175 3020 2175
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 3075 2175 20 20 3075 2175 3095 2175
 -6
-6 2850 2475 3150 2850
+6 4050 2100 4350 2250
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4125 2175 20 20 4125 2175 4145 2175
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4200 2175 20 20 4200 2175 4220 2175
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4275 2175 20 20 4275 2175 4295 2175
+-6
+6 4650 2100 4950 2250
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4725 2175 20 20 4725 2175 4745 2175
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4800 2175 20 20 4800 2175 4820 2175
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4875 2175 20 20 4875 2175 4895 2175
+-6
+6 3450 2100 3750 2250
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 3525 2175 20 20 3525 2175 3545 2175
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 3600 2175 20 20 3600 2175 3620 2175
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 3675 2175 20 20 3675 2175 3695 2175
+-6
+6 3300 2175 3600 2550
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
 	1 1 1.00 45.00 90.00
-	 2925 2475 2925 2700
+	 3375 2175 3375 2400
 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 2850 2700 3150 2700 3150 2850 2850 2850 2850 2700
+	 3300 2400 3600 2400 3600 2550 3300 2550 3300 2400
 -6
-6 4350 2475 4650 2850
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3150 1800 3150 2250
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 2850 1800 2850 2250
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 4650 1800 4650 2250
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 4950 1800 4950 2250
+2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 4500 1725 4500 2250
+2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 5100 1725 5100 2250
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3450 1800 3450 2250
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3750 1800 3750 2250
+2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3300 1725 3300 2250
+2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3900 1725 3900 2250
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 5250 1800 5250 2250
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 5400 1800 5400 2250
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 5550 1800 5550 2250
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 5700 1800 5700 2250
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 5850 1800 5850 2250
+2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 2700 1725 2700 2250
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
 	1 1 1.00 45.00 90.00
-	 4425 2475 4425 2700
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 4350 2700 4650 2700 4650 2850 4350 2850 4350 2700
--6
-6 3600 2475 3825 3150
+	 3375 1275 3375 1575
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
 	1 1 1.00 45.00 90.00
-	 3675 2475 3675 2700
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 3600 2700 3825 2700 3825 2850 3600 2850 3600 2700
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 3600 3000 3825 3000 3825 3150 3600 3150 3600 3000
+	 2700 1275 2700 1575
+2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 2775 1275 2775 1575
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
 	1 1 1.00 45.00 90.00
-	 3675 2775 3675 3000
--6
-6 4875 3600 5175 3750
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4950 3675 20 20 4950 3675 4970 3675
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 5025 3675 20 20 5025 3675 5045 3675
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 5100 3675 20 20 5100 3675 5120 3675
--6
-6 4875 2325 5175 2475
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4950 2400 20 20 4950 2400 4970 2400
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 5025 2400 20 20 5025 2400 5045 2400
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 5100 2400 20 20 5100 2400 5120 2400
--6
-6 5625 2325 5925 2475
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 5700 2400 20 20 5700 2400 5720 2400
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 5775 2400 20 20 5775 2400 5795 2400
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 5850 2400 20 20 5850 2400 5870 2400
--6
-6 5625 3600 5925 3750
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 5700 3675 20 20 5700 3675 5720 3675
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 5775 3675 20 20 5775 3675 5795 3675
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 5850 3675 20 20 5850 3675 5870 3675
--6
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 2400 2100 2400 2550
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 2550 2100 2550 2550
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 2700 2100 2700 2550
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 2850 2100 2850 2550
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 3000 2100 3000 2550
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 3600 2100 3600 2550
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 3900 2100 3900 2550
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 4050 2100 4050 2550
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 4200 2100 4200 2550
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 4350 2100 4350 2550
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 4500 2100 4500 2550
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 3300 1500 3300 1800
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 3600 1500 3600 1800
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 3900 1500 3900 1800
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 3000 1500 4800 1500 4800 1800 3000 1800 3000 1500
+	 5175 1275 5175 1575
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 5625 1275 5625 1575
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 3750 1275 3750 1575
 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 1 0 2
 	1 1 1.00 45.00 90.00
-	 3225 1650 2625 2100
+	 3825 1275 3825 1575
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 2700 1950 6000 1950
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 2700 2100 6000 2100
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 2700 1800 6000 1800 6000 2250 2700 2250 2700 1800
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
 	1 1 1.00 45.00 90.00
-	 3150 1650 2550 2100
+	 2775 2175 2775 2400
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
 	1 1 1.00 45.00 90.00
-	 3450 1650 4050 2100
-2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 1 0 2
-	1 1 1.00 45.00 90.00
-	 3375 1650 3975 2100
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 2100 2100 2100 2550
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 1950 2250 3150 2250
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 3450 2250 4650 2250
+	 2775 2475 2775 2700
 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 1950 2100 3150 2100 3150 2550 1950 2550 1950 2100
+	 2700 2700 2850 2700 2850 2850 2700 2850 2700 2700
 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 3450 2100 4650 2100 4650 2550 3450 2550 3450 2100
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 2250 2100 2250 2550
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 3750 2100 3750 2550
+	 2700 2400 2850 2400 2850 2550 2700 2550 2700 2400
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
 	1 1 1.00 45.00 90.00
-	 2025 2475 2025 2700
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
-	1 1 1.00 45.00 90.00
-	 2025 2775 2025 3000
+	 4575 2175 4575 2400
 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 1950 3000 2100 3000 2100 3150 1950 3150 1950 3000
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 1950 2700 2100 2700 2100 2850 1950 2850 1950 2700
+	 4500 2400 5025 2400 5025 2550 4500 2550 4500 2400
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 3
 	1 1 1.00 45.00 90.00
-	 1950 3750 2700 3750 2700 3525
+	 3600 3375 4350 3375 4350 3150
 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 1950 3525 3150 3525 3150 3900 1950 3900 1950 3525
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 3
-	1 1 1.00 45.00 90.00
-	 3450 3750 4200 3750 4200 3525
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 3450 3525 4650 3525 4650 3900 3450 3900 3450 3525
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 3
-	1 1 1.00 45.00 90.00
-	 3150 4650 4200 4650 4200 4275
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 3150 4275 4650 4275 4650 4875 3150 4875 3150 4275
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 1950 2400 3150 2400
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 3450 2400 4650 2400
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 5400 2100 5400 3900
-4 2 0 50 -1 0 11 0.0000 2 120 300 1875 2250 lock\001
-4 1 0 50 -1 0 12 0.0000 2 135 1935 3900 1425 N kernel-thread buckets\001
-4 1 0 50 -1 0 12 0.0000 2 195 810 4425 2025 heap$_2$\001
-4 1 0 50 -1 0 12 0.0000 2 195 810 2175 2025 heap$_1$\001
-4 2 0 50 -1 0 11 0.0000 2 120 270 1875 2400 size\001
-4 2 0 50 -1 0 11 0.0000 2 120 270 1875 2550 free\001
-4 1 0 50 -1 0 12 0.0000 2 180 825 2550 3450 local pool\001
-4 0 0 50 -1 0 12 0.0000 2 135 360 3525 3700 lock\001
-4 0 0 50 -1 0 12 0.0000 2 135 360 3225 4450 lock\001
-4 2 0 50 -1 0 12 0.0000 2 135 600 1875 3000 free list\001
-4 1 0 50 -1 0 12 0.0000 2 180 825 4050 3450 local pool\001
-4 1 0 50 -1 0 12 0.0000 2 180 1455 3900 4200 global pool (sbrk)\001
-4 0 0 50 -1 0 12 0.0000 2 135 360 2025 3700 lock\001
-4 1 0 50 -1 0 12 0.0000 2 180 720 6450 3150 free pool\001
-4 1 0 50 -1 0 12 0.0000 2 180 390 6450 2925 heap\001
+	 3600 3150 5100 3150 5100 3525 3600 3525 3600 3150
+4 2 0 50 -1 0 11 0.0000 2 135 300 2625 1950 lock\001
+4 1 0 50 -1 0 11 0.0000 2 150 1155 3000 1725 N$\\times$S$_1$\001
+4 1 0 50 -1 0 11 0.0000 2 150 1155 3600 1725 N$\\times$S$_2$\001
+4 1 0 50 -1 0 12 0.0000 2 180 390 4425 1500 heap\001
+4 2 0 50 -1 0 12 0.0000 2 135 1140 2550 1425 kernel threads\001
+4 2 0 50 -1 0 11 0.0000 2 120 270 2625 2100 size\001
+4 2 0 50 -1 0 11 0.0000 2 120 270 2625 2250 free\001
+4 2 0 50 -1 0 12 0.0000 2 135 600 2625 2700 free list\001
+4 0 0 50 -1 0 12 0.0000 2 135 360 3675 3325 lock\001
+4 1 0 50 -1 0 12 0.0000 2 180 1455 4350 3075 global pool (sbrk)\001
+4 1 0 50 -1 0 11 0.0000 2 150 1110 4800 1725 N$\\times$S$_t$\001
Index: doc/theses/mubeen_zulfiqar_MMath/figures/AllocDS2.fig
===================================================================
--- doc/theses/mubeen_zulfiqar_MMath/figures/AllocDS2.fig	(revision ba897d2136bc02c8b8a01751cd212c9a145a8df7)
+++ doc/theses/mubeen_zulfiqar_MMath/figures/AllocDS2.fig	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
@@ -8,119 +8,141 @@
 -2
 1200 2
-6 2850 2100 3150 2250
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 2925 2175 20 20 2925 2175 2945 2175
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 3000 2175 20 20 3000 2175 3020 2175
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 3075 2175 20 20 3075 2175 3095 2175
--6
-6 4050 2100 4350 2250
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4125 2175 20 20 4125 2175 4145 2175
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4200 2175 20 20 4200 2175 4220 2175
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4275 2175 20 20 4275 2175 4295 2175
--6
-6 4650 2100 4950 2250
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4725 2175 20 20 4725 2175 4745 2175
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4800 2175 20 20 4800 2175 4820 2175
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4875 2175 20 20 4875 2175 4895 2175
--6
-6 3450 2100 3750 2250
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 3525 2175 20 20 3525 2175 3545 2175
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 3600 2175 20 20 3600 2175 3620 2175
-1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 3675 2175 20 20 3675 2175 3695 2175
--6
-6 3300 2175 3600 2550
+6 2850 2475 3150 2850
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
 	1 1 1.00 45.00 90.00
-	 3375 2175 3375 2400
+	 2925 2475 2925 2700
 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 3300 2400 3600 2400 3600 2550 3300 2550 3300 2400
+	 2850 2700 3150 2700 3150 2850 2850 2850 2850 2700
+-6
+6 4350 2475 4650 2850
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 4425 2475 4425 2700
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 4350 2700 4650 2700 4650 2850 4350 2850 4350 2700
+-6
+6 3600 2475 3825 3150
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 3675 2475 3675 2700
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 3600 2700 3825 2700 3825 2850 3600 2850 3600 2700
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 3600 3000 3825 3000 3825 3150 3600 3150 3600 3000
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 3675 2775 3675 3000
+-6
+6 1950 3525 3150 3900
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 3
+	1 1 1.00 45.00 90.00
+	 1950 3750 2700 3750 2700 3525
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 1950 3525 3150 3525 3150 3900 1950 3900 1950 3525
+4 0 0 50 -1 0 12 0.0000 2 135 360 2025 3700 lock\001
+-6
+6 4050 1575 4350 1725
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4125 1650 20 20 4125 1650 4145 1650
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4200 1650 20 20 4200 1650 4220 1650
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4275 1650 20 20 4275 1650 4295 1650
+-6
+6 4875 2325 6150 3750
+6 4875 2325 5175 2475
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4950 2400 20 20 4950 2400 4970 2400
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 5025 2400 20 20 5025 2400 5045 2400
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 5100 2400 20 20 5100 2400 5120 2400
+-6
+6 4875 3600 5175 3750
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4950 3675 20 20 4950 3675 4970 3675
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 5025 3675 20 20 5025 3675 5045 3675
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 5100 3675 20 20 5100 3675 5120 3675
+-6
+4 1 0 50 -1 0 12 0.0000 2 180 900 5700 3150 local pools\001
+4 1 0 50 -1 0 12 0.0000 2 180 465 5700 2925 heaps\001
+-6
+6 3600 4050 5100 4650
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 3
+	1 1 1.00 45.00 90.00
+	 3600 4500 4350 4500 4350 4275
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 3600 4275 5100 4275 5100 4650 3600 4650 3600 4275
+4 1 0 50 -1 0 12 0.0000 2 180 1455 4350 4200 global pool (sbrk)\001
+4 0 0 50 -1 0 12 0.0000 2 135 360 3675 4450 lock\001
 -6
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 3150 1800 3150 2250
+	 2400 2100 2400 2550
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 2850 1800 2850 2250
+	 2550 2100 2550 2550
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 4650 1800 4650 2250
+	 2700 2100 2700 2550
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 4950 1800 4950 2250
-2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 4500 1725 4500 2250
-2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 5100 1725 5100 2250
+	 2850 2100 2850 2550
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 3450 1800 3450 2250
+	 3000 2100 3000 2550
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 3750 1800 3750 2250
-2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 3300 1725 3300 2250
-2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 3900 1725 3900 2250
+	 3600 2100 3600 2550
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 5250 1800 5250 2250
+	 3900 2100 3900 2550
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 5400 1800 5400 2250
+	 4050 2100 4050 2550
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 5550 1800 5550 2250
+	 4200 2100 4200 2550
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 5700 1800 5700 2250
+	 4350 2100 4350 2550
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 5850 1800 5850 2250
-2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 2700 1725 2700 2250
+	 4500 2100 4500 2550
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3300 1500 3300 1800
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3600 1500 3600 1800
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 3000 1500 4800 1500 4800 1800 3000 1800 3000 1500
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
 	1 1 1.00 45.00 90.00
-	 3375 1275 3375 1575
+	 3150 1650 2550 2100
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
 	1 1 1.00 45.00 90.00
-	 2700 1275 2700 1575
-2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 1 0 2
-	1 1 1.00 45.00 90.00
-	 2775 1275 2775 1575
+	 3450 1650 4050 2100
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 2100 2100 2100 2550
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 1950 2250 3150 2250
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3450 2250 4650 2250
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 1950 2100 3150 2100 3150 2550 1950 2550 1950 2100
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 3450 2100 4650 2100 4650 2550 3450 2550 3450 2100
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 2250 2100 2250 2550
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3750 2100 3750 2550
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
 	1 1 1.00 45.00 90.00
-	 5175 1275 5175 1575
+	 2025 2475 2025 2700
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
 	1 1 1.00 45.00 90.00
-	 5625 1275 5625 1575
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
-	1 1 1.00 45.00 90.00
-	 3750 1275 3750 1575
-2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 1 0 2
-	1 1 1.00 45.00 90.00
-	 3825 1275 3825 1575
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 2700 1950 6000 1950
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 2700 2100 6000 2100
+	 2025 2775 2025 3000
 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 2700 1800 6000 1800 6000 2250 2700 2250 2700 1800
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
-	1 1 1.00 45.00 90.00
-	 2775 2175 2775 2400
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
-	1 1 1.00 45.00 90.00
-	 2775 2475 2775 2700
+	 1950 3000 2100 3000 2100 3150 1950 3150 1950 3000
 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 2700 2700 2850 2700 2850 2850 2700 2850 2700 2700
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 2700 2400 2850 2400 2850 2550 2700 2550 2700 2400
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
-	1 1 1.00 45.00 90.00
-	 4575 2175 4575 2400
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 4500 2400 5025 2400 5025 2550 4500 2550 4500 2400
+	 1950 2700 2100 2700 2100 2850 1950 2850 1950 2700
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 3
 	1 1 1.00 45.00 90.00
-	 3600 3525 4650 3525 4650 3150
+	 3450 3750 4200 3750 4200 3525
 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 3600 3150 5100 3150 5100 3750 3600 3750 3600 3150
-4 2 0 50 -1 0 11 0.0000 2 120 300 2625 1950 lock\001
-4 1 0 50 -1 0 10 0.0000 2 150 1155 3000 1725 N$\\times$S$_1$\001
-4 1 0 50 -1 0 10 0.0000 2 150 1155 3600 1725 N$\\times$S$_2$\001
-4 1 0 50 -1 0 12 0.0000 2 180 390 4425 1500 heap\001
-4 2 0 50 -1 0 12 0.0000 2 135 1140 2550 1425 kernel threads\001
-4 2 0 50 -1 0 11 0.0000 2 120 270 2625 2100 size\001
-4 2 0 50 -1 0 11 0.0000 2 120 270 2625 2250 free\001
-4 2 0 50 -1 0 12 0.0000 2 135 600 2625 2700 free list\001
-4 0 0 50 -1 0 12 0.0000 2 135 360 3675 3325 lock\001
-4 1 0 50 -1 0 12 0.0000 2 180 1455 4350 3075 global pool (sbrk)\001
-4 1 0 50 -1 0 10 0.0000 2 150 1110 4800 1725 N$\\times$S$_t$\001
+	 3450 3525 4650 3525 4650 3900 3450 3900 3450 3525
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 1950 2400 3150 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3450 2400 4650 2400
+4 2 0 50 -1 0 11 0.0000 2 135 300 1875 2250 lock\001
+4 1 0 50 -1 0 12 0.0000 2 180 1245 3900 1425 H heap buckets\001
+4 1 0 50 -1 0 12 0.0000 2 180 810 4425 2025 heap$_2$\001
+4 1 0 50 -1 0 12 0.0000 2 180 810 2175 2025 heap$_1$\001
+4 2 0 50 -1 0 11 0.0000 2 120 270 1875 2400 size\001
+4 2 0 50 -1 0 11 0.0000 2 120 270 1875 2550 free\001
+4 1 0 50 -1 0 12 0.0000 2 180 825 2550 3450 local pool\001
+4 0 0 50 -1 0 12 0.0000 2 135 360 3525 3700 lock\001
+4 2 0 50 -1 0 12 0.0000 2 135 600 1875 3000 free list\001
+4 1 0 50 -1 0 12 0.0000 2 180 825 4050 3450 local pool\001
Index: doc/theses/mubeen_zulfiqar_MMath/figures/FakeHeader.fig
===================================================================
--- doc/theses/mubeen_zulfiqar_MMath/figures/FakeHeader.fig	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
+++ doc/theses/mubeen_zulfiqar_MMath/figures/FakeHeader.fig	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
@@ -0,0 +1,24 @@
+#FIG 3.2  Produced by xfig version 3.2.7b
+Landscape
+Center
+Inches
+Letter
+100.00
+Single
+-2
+1200 2
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 2700 1500 2700 1800
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 1200 1500 4200 1500 4200 1800 1200 1800 1200 1500
+2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2
+	 2550 1500 2550 1800
+2 1 0 1 0 7 50 -1 -1 4.000 0 0 -1 1 0 3
+	1 1 1.00 45.00 90.00
+	 2925 1950 2625 1950 2625 1800
+4 1 0 50 -1 0 12 0.0000 2 135 450 3450 1725 offset\001
+4 1 0 50 -1 0 12 0.0000 2 180 825 1950 1725 alignment\001
+4 1 0 50 -1 0 12 0.0000 2 135 105 2625 1725 1\001
+4 0 0 50 -1 0 12 0.0000 2 180 1920 3000 2025 alignment (fake header)\001
+4 1 0 50 -1 0 12 0.0000 2 180 765 1950 1425 4/8-bytes\001
+4 1 0 50 -1 0 12 0.0000 2 180 765 3450 1425 4/8-bytes\001
Index: doc/theses/mubeen_zulfiqar_MMath/figures/Header.fig
===================================================================
--- doc/theses/mubeen_zulfiqar_MMath/figures/Header.fig	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
+++ doc/theses/mubeen_zulfiqar_MMath/figures/Header.fig	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
@@ -0,0 +1,40 @@
+#FIG 3.2  Produced by xfig version 3.2.7b
+Landscape
+Center
+Inches
+Letter
+100.00
+Single
+-2
+1200 2
+2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2
+	 1800 1800 4200 1800
+2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2
+	 1800 2100 4200 2100
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 1800 1500 4200 1500 4200 2400 1800 2400 1800 1500
+2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2
+	 3900 1500 3900 2400
+2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2
+	 3600 1500 3600 2400
+2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2
+	 3300 1500 3300 2400
+2 1 0 1 0 7 50 -1 -1 4.000 0 0 -1 1 0 3
+	1 1 1.00 45.00 90.00
+	 4050 2625 3750 2625 3750 2400
+2 1 0 1 0 7 50 -1 -1 4.000 0 0 -1 1 0 3
+	1 1 1.00 45.00 90.00
+	 4050 2850 3450 2850 3450 2400
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 4200 1800 6600 1800 6600 2100 4200 2100 4200 1800
+4 0 0 50 -1 0 12 0.0000 2 180 1185 1875 1725 bucket pointer\001
+4 0 0 50 -1 0 12 0.0000 2 180 1005 1875 2025 mapped size\001
+4 0 0 50 -1 0 12 0.0000 2 135 1215 1875 2325 next free block\001
+4 2 0 50 -1 0 12 0.0000 2 135 480 1725 2025 union\001
+4 1 0 50 -1 0 12 0.0000 2 135 270 3775 2325 0/1\001
+4 1 0 50 -1 0 12 0.0000 2 135 270 3475 2325 0/1\001
+4 1 0 50 -1 0 12 0.0000 2 180 945 5400 2025 request size\001
+4 1 0 50 -1 0 12 0.0000 2 180 765 5400 1425 4/8-bytes\001
+4 1 0 50 -1 0 12 0.0000 2 180 765 3000 1425 4/8-bytes\001
+4 0 0 50 -1 0 12 0.0000 2 135 825 4125 2700 zero filled\001
+4 0 0 50 -1 0 12 0.0000 2 180 1515 4125 2925 mapped allocation\001
Index: doc/theses/mubeen_zulfiqar_MMath/figures/UserKernelHeaps.fig
===================================================================
--- doc/theses/mubeen_zulfiqar_MMath/figures/UserKernelHeaps.fig	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
+++ doc/theses/mubeen_zulfiqar_MMath/figures/UserKernelHeaps.fig	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
@@ -0,0 +1,59 @@
+#FIG 3.2  Produced by xfig version 3.2.7b
+Landscape
+Center
+Inches
+Letter
+100.00
+Single
+-2
+1200 2
+6 1500 1200 2100 1500
+1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 1800 1350 150 150 1800 1350 1950 1350
+4 1 0 50 -1 0 11 0.0000 2 165 495 1800 1425 U$_2$\001
+-6
+6 1050 1200 1650 1500
+1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 1350 1350 150 150 1350 1350 1500 1350
+4 1 0 50 -1 0 11 0.0000 2 165 495 1350 1425 U$_1$\001
+-6
+6 1950 1200 2550 1500
+1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 2250 1350 150 150 2250 1350 2400 1350
+4 1 0 50 -1 0 11 0.0000 2 165 495 2250 1425 U$_3$\001
+-6
+6 2850 1200 3450 1500
+1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 3150 1350 150 150 3150 1350 3300 1350
+4 1 0 50 -1 0 11 0.0000 2 165 495 3150 1425 U$_4$\001
+-6
+6 2400 1200 3000 1500
+1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 2700 1350 150 150 2700 1350 2850 1350
+4 1 0 50 -1 0 11 0.0000 2 165 495 2700 1425 U$_5$\001
+-6
+6 3300 1200 3900 1500
+1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 3600 1350 150 150 3600 1350 3750 1350
+4 1 0 50 -1 0 11 0.0000 2 165 495 3600 1425 U$_6$\001
+-6
+6 2175 1800 2775 2100
+1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 2475 1950 150 150 2475 1950 2625 1950
+4 1 0 50 -1 0 11 0.0000 2 165 495 2475 2025 K$_2$\001
+-6
+6 1725 1800 2325 2100
+1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 2025 1950 150 150 2025 1950 2175 1950
+4 1 0 50 -1 0 11 0.0000 2 165 495 2025 2025 K$_1$\001
+-6
+6 2625 1800 3225 2100
+1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 2925 1950 150 150 2925 1950 3075 1950
+4 1 0 50 -1 0 11 0.0000 2 165 495 2925 2025 K$_3$\001
+-6
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2
+	0 0 1.00 45.00 90.00
+	0 0 1.00 45.00 90.00
+	 2025 2100 2025 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2
+	0 0 1.00 45.00 90.00
+	0 0 1.00 45.00 90.00
+	 2475 2100 2475 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2
+	0 0 1.00 45.00 90.00
+	0 0 1.00 45.00 90.00
+	 2925 2100 2925 2400
+4 1 0 50 -1 0 11 0.0000 2 135 2235 2475 1725 scheduled across kernel threads\001
+4 1 0 50 -1 0 11 0.0000 2 180 2145 2475 2625 K:1 or K:H or 1:1 heap model\001
Index: doc/theses/mubeen_zulfiqar_MMath/figures/llheap.fig
===================================================================
--- doc/theses/mubeen_zulfiqar_MMath/figures/llheap.fig	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
+++ doc/theses/mubeen_zulfiqar_MMath/figures/llheap.fig	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
@@ -0,0 +1,177 @@
+#FIG 3.2  Produced by xfig version 3.2.7b
+Landscape
+Center
+Inches
+Letter
+100.00
+Single
+-2
+1200 2
+6 1275 1950 1725 2250
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 1275 1950 1725 1950 1725 2250 1275 2250 1275 1950
+4 1 0 50 -1 0 12 0.0000 2 135 360 1500 2175 lock\001
+-6
+6 4125 4050 4275 4350
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4200 4125 20 20 4200 4125 4220 4125
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4200 4200 20 20 4200 4200 4220 4200
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4200 4275 20 20 4200 4275 4220 4275
+-6
+6 5025 3825 5325 3975
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 5100 3900 20 20 5100 3900 5120 3900
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 5175 3900 20 20 5175 3900 5195 3900
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 5250 3900 20 20 5250 3900 5270 3900
+-6
+6 6150 2025 6450 2175
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6225 2100 20 20 6225 2100 6245 2100
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6300 2100 20 20 6300 2100 6320 2100
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6375 2100 20 20 6375 2100 6395 2100
+-6
+6 3225 4650 3675 4950
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 3225 4650 3675 4650 3675 4950 3225 4950 3225 4650
+4 1 0 50 -1 0 12 0.0000 2 135 360 3450 4875 lock\001
+-6
+6 3750 2325 3900 2700
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 3825 2325 3825 2550
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 3750 2550 3900 2550 3900 2700 3750 2700 3750 2550
+-6
+6 6750 2025 7050 2175
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6825 2100 20 20 6825 2100 6845 2100
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6900 2100 20 20 6900 2100 6920 2100
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6975 2100 20 20 6975 2100 6995 2100
+-6
+6 2550 3150 3450 4350
+6 2925 4050 3075 4350
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 3000 4125 20 20 3000 4125 3020 4125
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 3000 4200 20 20 3000 4200 3020 4200
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 3000 4275 20 20 3000 4275 3020 4275
+-6
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 2550 3375 3450 3375 3450 3600 2550 3600 2550 3375
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 2550 3750 3450 3750 3450 3975 2550 3975 2550 3750
+4 1 0 50 -1 0 12 0.0000 2 180 900 3000 3300 local pools\001
+-6
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 2850 1800 2850 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3000 1800 3000 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3150 1800 3150 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3300 1800 3300 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3450 1800 3450 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 2550 1800 2550 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 2400 1950 3600 1950
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 2700 1800 2700 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 2400 2100 3600 2100
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 2400 1800 3600 1800 3600 2400 2400 2400 2400 1800
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 2400 2250 3600 2250
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 2475 2325 2475 2550
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 2475 2625 2475 2850
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 2400 2850 2550 2850 2550 3000 2400 3000 2400 2850
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 2400 2550 2550 2550 2550 2700 2400 2700 2400 2550
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 2925 2175 2925 2550
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 2925 2625 2925 2850
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 2850 2850 3000 2850 3000 3000 2850 3000 2850 2850
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 2850 2550 3000 2550 3000 2700 2850 2700 2850 2550
+2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3600 1650 3600 2550
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 3375 2325 3375 2550
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 3225 2550 3525 2550 3525 2700 3225 2700 3225 2550
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 4050 1800 4050 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 4200 1800 4200 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 4350 1800 4350 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 4500 1800 4500 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 4650 1800 4650 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3750 1800 3750 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3600 1950 4800 1950
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3900 1800 3900 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3600 2100 4800 2100
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 3600 1800 4800 1800 4800 2400 3600 2400 3600 1800
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 3600 2250 4800 2250
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 4125 2175 4125 2550
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 4050 2550 4200 2550 4200 2700 4050 2700 4050 2550
+2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 4800 1650 4800 2550
+2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 5400 1650 5400 2550
+2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 6000 1650 6000 2550
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 4800 1800 6600 1800 6600 2400 4800 2400 4800 1800
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 4575 2625 4575 2850
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 4575 2325 4575 2550
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 4425 2550 4725 2550 4725 2700 4425 2700 4425 2550
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 4425 2850 4725 2850 4725 3000 4425 3000 4425 2850
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 3750 3375 4650 3375 4650 3600 3750 3600 3750 3375
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 3750 3750 4650 3750 4650 3975 3750 3975 3750 3750
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 3825 4650 5325 4650 5325 4950 3825 4950 3825 4650
+2 2 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 5
+	 1200 3900 1950 3900 1950 4425 1200 4425 1200 3900
+2 2 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 5
+	 1200 3000 1800 3000 1800 3525 1200 3525 1200 3000
+4 2 0 50 -1 0 11 0.0000 2 135 300 2325 1950 lock\001
+4 2 0 50 -1 0 11 0.0000 2 120 270 2325 2100 size\001
+4 2 0 50 -1 0 11 0.0000 2 120 270 2325 2400 free\001
+4 2 0 50 -1 0 11 0.0000 2 165 495 2325 2250 (away)\001
+4 1 0 50 -1 0 12 0.0000 2 180 1455 4575 4575 global pool (sbrk)\001
+4 1 0 50 -1 0 12 0.0000 2 180 900 4200 3300 local pools\001
+4 1 0 50 -1 0 12 0.0000 2 180 1695 4350 1425 global heaps (mmap)\001
+4 1 0 50 -1 0 12 0.0000 2 180 810 3000 1725 heap$_1$\001
+4 1 0 50 -1 0 12 0.0000 2 180 810 4200 1725 heap$_2$\001
+4 1 0 50 -1 0 11 0.0000 2 120 255 1500 3150 fast\001
+4 1 0 50 -1 0 11 0.0000 2 180 495 1500 3300 lookup\001
+4 1 0 50 -1 0 11 0.0000 2 135 330 1500 3450 table\001
+4 1 0 50 -1 0 11 0.0000 2 120 315 1575 4050 stats\001
+4 1 0 50 -1 0 11 0.0000 2 120 600 1575 4200 counters\001
+4 1 0 50 -1 0 11 0.0000 2 135 330 1575 4350 table\001
Index: doc/theses/mubeen_zulfiqar_MMath/intro.tex
===================================================================
--- doc/theses/mubeen_zulfiqar_MMath/intro.tex	(revision ba897d2136bc02c8b8a01751cd212c9a145a8df7)
+++ doc/theses/mubeen_zulfiqar_MMath/intro.tex	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
@@ -48,5 +48,5 @@
 Attempts have been made to perform quasi garbage collection in C/\CC~\cite{Boehm88}, but it is a compromise.
 This thesis only examines dynamic memory-management with \emph{explicit} deallocation.
-While garbage collection and compaction are not part this work, many of the results are applicable to the allocation phase in any memory-management approach.
+While garbage collection and compaction are not part this work, many of the work's results are applicable to the allocation phase in any memory-management approach.
 
 Most programs use a general-purpose allocator, often the one provided implicitly by the programming-language's runtime.
@@ -65,14 +65,22 @@
 \begin{enumerate}[leftmargin=*]
 \item
-Implementation of a new stand-lone concurrent low-latency memory-allocator ($\approx$1,200 lines of code) for C/\CC programs using kernel threads (1:1 threading), and specialized versions of the allocator for programming languages \uC and \CFA using user-level threads running over multiple kernel threads (M:N threading).
-
-\item
-Adopt returning of @nullptr@ for a zero-sized allocation, rather than an actual memory address, both of which can be passed to @free@.
-
-\item
-Extended the standard C heap functionality by preserving with each allocation its original request size versus the amount allocated, if an allocation is zero fill, and the allocation alignment.
-
-\item
-Use the zero fill and alignment as \emph{sticky} properties for @realloc@, to realign existing storage, or preserve existing zero-fill and alignment when storage is copied.
+Implementation of a new stand-lone concurrent low-latency memory-allocator ($\approx$1,200 lines of code) for C/\CC programs using kernel threads (1:1 threading), and specialized versions of the allocator for the programming languages \uC and \CFA using user-level threads running over multiple kernel threads (M:N threading).
+
+\item
+Adopt @nullptr@ return for a zero-sized allocation, rather than an actual memory address, which can be passed to @free@.
+
+\item
+Extend the standard C heap functionality by preserving with each allocation:
+\begin{itemize}[itemsep=0pt]
+\item
+its request size plus the amount allocated,
+\item
+whether an allocation is zero fill,
+\item
+and allocation alignment.
+\end{itemize}
+
+\item
+Use the preserved zero fill and alignment as \emph{sticky} properties for @realloc@ to zero-fill and align when storage is extended or copied.
 Without this extension, it is unsafe to @realloc@ storage initially allocated with zero-fill/alignment as these properties are not preserved when copying.
 This silent generation of a problem is unintuitive to programmers and difficult to locate because it is transient.
@@ -86,5 +94,5 @@
 @resize( oaddr, alignment, size )@ re-purpose an old allocation with new alignment but \emph{without} preserving fill.
 \item
-@realloc( oaddr, alignment, size )@ same as previous @realloc@ but adding or changing alignment.
+@realloc( oaddr, alignment, size )@ same as @realloc@ but adding or changing alignment.
 \item
 @aalloc( dim, elemSize )@ same as @calloc@ except memory is \emph{not} zero filled.
@@ -96,5 +104,5 @@
 
 \item
-Provide additional heap wrapper functions in \CFA to provide a complete orthogonal set of allocation operations and properties.
+Provide additional heap wrapper functions in \CFA creating an orthogonal set of allocation operations and properties.
 
 \item
@@ -109,5 +117,5 @@
 @malloc_size( addr )@ returns the size of the memory allocation pointed-to by @addr@.
 \item
-@malloc_usable_size( addr )@ returns the usable size of the memory pointed-to by @addr@, i.e., the bin size containing the allocation, where @malloc_size( addr )@ $\le$ @malloc_usable_size( addr )@.
+@malloc_usable_size( addr )@ returns the usable (total) size of the memory pointed-to by @addr@, i.e., the bin size containing the allocation, where @malloc_size( addr )@ $\le$ @malloc_usable_size( addr )@.
 \end{itemize}
 
@@ -116,5 +124,5 @@
 
 \item
-Provide complete, fast, and contention-free allocation statistics to help understand program behaviour:
+Provide complete, fast, and contention-free allocation statistics to help understand allocation behaviour:
 \begin{itemize}
 \item
Index: doc/theses/mubeen_zulfiqar_MMath/performance.tex
===================================================================
--- doc/theses/mubeen_zulfiqar_MMath/performance.tex	(revision ba897d2136bc02c8b8a01751cd212c9a145a8df7)
+++ doc/theses/mubeen_zulfiqar_MMath/performance.tex	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
@@ -1,3 +1,4 @@
 \chapter{Performance}
+\label{c:Performance}
 
 \section{Machine Specification}
Index: doc/theses/mubeen_zulfiqar_MMath/uw-ethesis.bib
===================================================================
--- doc/theses/mubeen_zulfiqar_MMath/uw-ethesis.bib	(revision ba897d2136bc02c8b8a01751cd212c9a145a8df7)
+++ doc/theses/mubeen_zulfiqar_MMath/uw-ethesis.bib	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
@@ -124,10 +124,33 @@
 }
 
-@misc{nedmalloc,
-    author	= {Niall Douglas},
-    title	= {nedmalloc version 1.06 Beta},
-    month	= jan,
-    year	= 2010,
-    note	= {\textsf{http://\-prdownloads.\-sourceforge.\-net/\-nedmalloc/\-nedmalloc\_v1.06beta1\_svn1151.zip}},
+@misc{ptmalloc2,
+    author	= {Wolfram Gloger},
+    title	= {ptmalloc version 2},
+    month	= jun,
+    year	= 2006,
+    note	= {\href{http://www.malloc.de/malloc/ptmalloc2-current.tar.gz}{http://www.malloc.de/\-malloc/\-ptmalloc2-current.tar.gz}},
+}
+
+@misc{GNUallocAPI,
+    author	= {GNU},
+    title	= {Summary of malloc-Related Functions},
+    year	= 2020,
+    note	= {\href{https://www.gnu.org/software/libc/manual/html\_node/Summary-of-Malloc.html}{https://www.gnu.org/\-software/\-libc/\-manual/\-html\_node/\-Summary-of-Malloc.html}},
+}
+
+@misc{SeriallyReusable,
+    author	= {IBM},
+    title	= {Serially reusable programs},
+    month	= mar,
+    year	= 2021,
+    note	= {\href{https://www.ibm.com/docs/en/ztpf/1.1.0.15?topic=structures-serially-reusable-programs}{https://www.ibm.com/\-docs/\-en/\-ztpf/\-1.1.0.15?\-topic=structures-serially-reusable-programs}},
+}
+
+@misc{librseq,
+    author	= {Mathieu Desnoyers},
+    title	= {Library for Restartable Sequences},
+    month	= mar,
+    year	= 2022,
+    note	= {\href{https://github.com/compudj/librseq}{https://github.com/compudj/librseq}},
 }
 
Index: doc/theses/mubeen_zulfiqar_MMath/uw-ethesis.tex
===================================================================
--- doc/theses/mubeen_zulfiqar_MMath/uw-ethesis.tex	(revision ba897d2136bc02c8b8a01751cd212c9a145a8df7)
+++ doc/theses/mubeen_zulfiqar_MMath/uw-ethesis.tex	(revision 2e9b59be1a4f6206dcfcb10cb3b400d3a5948c6c)
@@ -60,4 +60,5 @@
 % For hyperlinked PDF, suitable for viewing on a computer, use this:
 \documentclass[letterpaper,12pt,titlepage,oneside,final]{book}
+\usepackage[T1]{fontenc}	% Latin-1 => 256-bit characters, => | not dash, <> not Spanish question marks
 
 % For PDF, suitable for double-sided printing, change the PrintVersion variable below to "true" and use this \documentclass line instead of the one above:
@@ -94,5 +95,6 @@
 % Use the "hyperref" package
 % N.B. HYPERREF MUST BE THE LAST PACKAGE LOADED; ADD ADDITIONAL PKGS ABOVE
-\usepackage[pagebackref=true]{hyperref} % with basic options
+\usepackage{url}
+\usepackage[dvips,pagebackref=true]{hyperref} % with basic options
 %\usepackage[pdftex,pagebackref=true]{hyperref}
 % N.B. pagebackref=true provides links back from the References to the body text. This can cause trouble for printing.
@@ -113,5 +115,6 @@
     citecolor=blue,        % color of links to bibliography
     filecolor=magenta,      % color of file links
-    urlcolor=blue           % color of external links
+    urlcolor=blue,           % color of external links
+    breaklinks=true
 }
 \ifthenelse{\boolean{PrintVersion}}{   % for improved print quality, change some hyperref options
@@ -122,4 +125,7 @@
     urlcolor=black
 }}{} % end of ifthenelse (no else)
+%\usepackage[dvips,plainpages=false,pdfpagelabels,pdfpagemode=UseNone,pagebackref=true,breaklinks=true,colorlinks=true,linkcolor=blue,citecolor=blue,urlcolor=blue]{hyperref}
+\usepackage{breakurl}
+\urlstyle{sf}
 
 %\usepackage[automake,toc,abbreviations]{glossaries-extra} % Exception to the rule of hyperref being the last add-on package
@@ -171,5 +177,6 @@
 \input{common}
 %\usepackageinput{common}
-\CFAStyle						% CFA code-style for all languages
+\CFAStyle						% CFA code-style
+\lstset{language=CFA}					% default language
 \lstset{basicstyle=\linespread{0.9}\sf}			% CFA typewriter font
 \newcommand{\uC}{$\mu$\CC}
