Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields  

High-level memory management commands
[Toy Command Interpreter]


Defines

#define ERR_PREFIX   "******* ERROR: "
 Error message template.

#define LINE_RULE   "+--------------------------------------------------\n"
 Line rule.

#define LINE_PREFIX   "| "
 Normal line prefix.

#define LINE_NUMBER_FORMAT   "%4d"
 Format for printing line #s.

#define PRINT_ERROR(error)   if(error!=ERR_UNKNOWN) printf(ERR_PREFIX"%s\n",ErrMessages[error])
 Simple macro to print an error message to stdout.


Functions

ErrMessage_t TMM_StoreInteger (ToyMM *tm, int process, int addr, int val)
 Stores an integer in a process' memory.

ErrMessage_t TMM_StoreString (ToyMM *tm, int process, int addr, const char *str)
 Stores a string in a process' memory.

ErrMessage_t TMM_StoreHeapInteger (ToyMM *tm, int process, int addr, int value)
 Attempts to store an integer in the process' heap.

ErrMessage_t TMM_StoreHeapString (ToyMM *tm, int process, int addr, const char *str)
 Attempts to store a string in the process' heap.

ErrMessage_t TMM_PrintProcessTable (ToyMM *tm, int process)
 Prints process table - running processes w/segment sizes, positions.

ErrMessage_t TMM_PrintProcessMemory (ToyMM *tm, int process)
 Prints all memory contained in a process.

ErrMessage_t TMM_TerminateProcess (ToyMM *tmm, int ID)
 Terminates a process.

ErrMessage_t TMM_PrintAllMemory (ToyMM *tmm)
 Prints ALL used/modified memory. Only process 0 can do this.

ErrMessage_t TMM_AllocateHeap (ToyMM *tm, int process, int size)
 Allocates a variable in the heap.

ErrMessage_t TMM_ReallocateHeap (ToyMM *tm, int process, int addr, int size)
 Reallocates a variable in the heap.

ErrMessage_t TMM_FreeHeap (ToyMM *tm, int process, int addr)
 Frees a variable in the heap.

ErrMessage_t TMM_PrintHeap (ToyMM *tm, int process)
 Prints used portions of the heap.

ErrMessage_t TMM_PrintPages (ToyMM *tm, int process)
 Prints the process' page table, with status column.

ErrMessage_t TMM_PrintFrames (ToyMM *tmm)
 Prints the tmm's inverted page table, with status column.

ErrMessage_t TMM_WatchPaging (ToyMM *tmm, int process, int enable)
 Turns the TOYFLAG_WATCHPAGING flag on or off in the tmm.

ErrMessage_t TMM_PagedAllocateProcess (ToyMM *tmm, int ID, int nSegs, int sizes[])
 Attempts to allocat a process in paged mode.

ErrMessage_t TMM_PrintPageTable (ToyMM *tm, int process)
 Prints a process' page table, if any.

ErrMessage_t TMM_PrintInvertedPageTable (ToyMM *tmm, int process)
 Prints the Toy Memory Manager's i.p.t. in paged mode.

ErrMessage_t TMM_PagedTerminateProcess (ToyMM *tm, int process)
 Function used to terminate a process in paged mode.

ErrMessage_t TMM_EnablePaging (ToyMM *tm, int process, int pagesize)
 Attempts to switch into Paging Mode.


Variables

const char * ErrMessages []
 String table of error message strings to match ErrMessage_t.


Detailed Description

This module provides direct function-equivalents for Toy Memory commands like "LoadFile", "EnablePaging", "STORE", etc.

Define Documentation

#define ERR_PREFIX   "******* ERROR: "
 

Error message template.

Definition at line 29 of file ToyMem_Internal.h.

#define LINE_NUMBER_FORMAT   "%4d"
 

Format for printing line #s.

Definition at line 35 of file ToyMem_Internal.h.

#define LINE_PREFIX   "| "
 

Normal line prefix.

Definition at line 33 of file ToyMem_Internal.h.

#define LINE_RULE   "+--------------------------------------------------\n"
 

Line rule.

Definition at line 31 of file ToyMem_Internal.h.

#define PRINT_ERROR error       if(error!=ERR_UNKNOWN) printf(ERR_PREFIX"%s\n",ErrMessages[error])
 

Simple macro to print an error message to stdout.

Definition at line 37 of file ToyMem_Internal.h.

Referenced by TMM_ParseFilePtr().


Function Documentation

ErrMessage_t TMM_AllocateHeap ToyMM   tm,
int    process,
int    size
 

Allocates a variable in the heap.

Allocates a block of memory in the heap. Is the function called directly in response to a "AllocateHeap" command.

Definition at line 135 of file ToyMemHeap.c.

References ErrMessage_t, ToySegment::len, MAX_PROCESSES, ToySegment::pos, ToyMM::processList, SegList::seg, TMM_CreateSegList(), TMM_GetRealAddress(), TMM_OrderedInsert(), and Process::usedheap.

Referenced by TMM_ParseLine().

ErrMessage_t TMM_EnablePaging ToyMM   tm,
int    process,
int    pagesize
 

Attempts to switch into Paging Mode.

Definition at line 118 of file ToyMemPage.c.

References ErrMessage_t, InvPageTable::ID, ToyMM::invPageTable, MAX_PROCESSES, ToyMM::memFree, ToyMM::memSize, ToyMM::page, InvPageTable::page, ToyMM::pageSize, ToyMM::processList, InvPageTable::status, TMM_FreeSegList(), TMM_GetNumPages(), TMM_SwapCreate(), and TMM_TerminateProcess().

Referenced by TMM_ParseLine().

ErrMessage_t TMM_FreeHeap ToyMM   tm,
int    process,
int    addr
 

Frees a variable in the heap.

Frees a memory block in the heap. Is the function called directly in response to a "FreeHeap" command.

Definition at line 188 of file ToyMemHeap.c.

References ErrMessage_t, ToySegment::len, MAX_PROCESSES, SegList::next, ToySegment::pos, SegList::prev, ToyMM::processList, SegList::seg, TMM_RemoveFromList(), and Process::usedheap.

Referenced by TMM_ParseLine().

ErrMessage_t TMM_PagedAllocateProcess ToyMM   tmm,
int    ID,
int    nSegs,
int    sizes[]
 

Attempts to allocat a process in paged mode.

Definition at line 243 of file ToyMemPage.c.

References ErrMessage_t, PageTable::frame, Process::freeheap, Process::ID, ToySegment::len, MAX_PROCESSES, PageTable::paged, Process::pagetable, ToySegment::pos, ToyMM::processList, Process::ptr, SegList::seg, Process::segments, TMM_CreateSegList(), TMM_GetNumPages(), TMM_PagedTerminateProcess(), and Process::usedheap.

ErrMessage_t TMM_PagedTerminateProcess ToyMM   tm,
int    process
 

Function used to terminate a process in paged mode.

Definition at line 339 of file ToyMemPage.c.

References ErrMessage_t, PageTable::frame, Process::freeheap, PageTable::paged, Process::pagetable, ToyMM::processList, Process::segments, TMM_FreeFrame(), TMM_FreeSegList(), TMM_GetNumPages(), and Process::usedheap.

Referenced by TMM_Free(), TMM_PagedAllocateProcess(), and TMM_TerminateProcess().

ErrMessage_t TMM_PrintAllMemory ToyMM   tmm
 

Prints ALL used/modified memory. Only process 0 can do this.

Called directly in response to the "PrintAllMemory" command.

Definition at line 59 of file ToyMem.c.

References ErrMessage_t, and ToyMM::memSize.

Referenced by TMM_ParseLine().

ErrMessage_t TMM_PrintFrames ToyMM   tmm
 

Prints the tmm's inverted page table, with status column.

Definition at line 74 of file ToyMemPage.c.

References ErrMessage_t, TMM_GetNumPages(), and TMM_PagingEnabled().

Referenced by TMM_ParseLine().

ErrMessage_t TMM_PrintHeap ToyMM   tm,
int    process
 

Prints used portions of the heap.

Prints the list of free space, the list of used nodes, and the percentage of memory free in the specified process of the toy memory manager. Directly tied to the "PrintProcessHeap" command recognized by the Toy Memory Manager commandfile parser.

Definition at line 371 of file ToyMemHeap.c.

References ErrMessage_t, MAX_PROCESSES, ToyMM::processList, and Process::usedheap.

Referenced by TMM_ParseLine().

ErrMessage_t TMM_PrintInvertedPageTable ToyMM   tmm,
int    process
 

Prints the Toy Memory Manager's i.p.t. in paged mode.

Definition at line 172 of file ToyMemPage.c.

References ErrMessage_t, and TMM_GetNumPages().

Referenced by TMM_ParseLine().

ErrMessage_t TMM_PrintPages ToyMM   tm,
int    process
 

Prints the process' page table, with status column.

Definition at line 32 of file ToyMemPage.c.

References ErrMessage_t, PageTable::frame, MAX_PROCESSES, Process::pagetable, ToyMM::processList, TMM_GetNumPages(), TMM_PageFree(), TMM_PageSwappedOut(), and TMM_PagingEnabled().

Referenced by TMM_ParseLine().

ErrMessage_t TMM_PrintPageTable ToyMM   tm,
int    process
 

Prints a process' page table, if any.

Definition at line 307 of file ToyMemPage.c.

References ErrMessage_t, PageTable::frame, MAX_PROCESSES, Process::pagetable, ToyMM::processList, and TMM_GetNumPages().

Referenced by TMM_ParseLine().

ErrMessage_t TMM_PrintProcessMemory ToyMM   tm,
int    process
 

Prints all memory contained in a process.

Called directly in response to a "PrintProcessMemory" command.

Definition at line 127 of file ToyMem.c.

References ErrMessage_t, ToySegment::len, MAX_PROCESSES, SegList::next, ToySegment::pos, ToyMM::processList, SegList::seg, Process::segments, TMM_SeekSegListHead(), and Process::usedheap.

Referenced by TMM_ParseLine().

ErrMessage_t TMM_PrintProcessTable ToyMM   tm,
int    process
 

Prints process table - running processes w/segment sizes, positions.

Called directly in response to the "PrintProcessTable" command.

Definition at line 82 of file ToyMem.c.

References ErrMessage_t, ToySegment::len, MAX_PROCESSES, SegList::next, ToySegment::pos, ToyMM::processList, SegList::seg, Process::segments, and TMM_SeekSegListHead().

Referenced by TMM_ParseLine().

ErrMessage_t TMM_ReallocateHeap ToyMM   tm,
int    process,
int    addr,
int    size
 

Reallocates a variable in the heap.

Reallocates a memory block in the heap of specified process. Is the function directly called in response to a "ReallocateHeap" command.

Definition at line 238 of file ToyMemHeap.c.

References ErrMessage_t, Process::freeheap, ToySegment::len, MAX_PROCESSES, ToySegment::pos, SegList::prev, ToyMM::processList, SegList::seg, TMM_CreateSegList(), TMM_OrderedInsert(), TMM_RemoveFromList(), and Process::usedheap.

Referenced by TMM_ParseLine().

ErrMessage_t TMM_StoreHeapInteger ToyMM   tm,
int    process,
int    addr,
int    value
 

Attempts to store an integer in the process' heap.

Attempts to store an integer value at a specified position in the heap. Used by the STORE command when storing in the heap.

Definition at line 96 of file ToyMemHeap.c.

References ErrMessage_t, ToyMem::integer, ToySegment::len, MAX_PROCESSES, ToyMM::mem, SegList::next, ToySegment::pos, ToyMM::processList, SegList::seg, TMM_GetRealAddress(), ToyMem::type, Process::usedheap, and ToyMem_Integer::value.

Referenced by TMM_StoreInteger().

ErrMessage_t TMM_StoreHeapString ToyMM   tm,
int    process,
int    addr,
const char *    str
 

Attempts to store a string in the process' heap.

Attempts to store a string value at a specified position in the heap. Used by the STORE command when storing in the heap.

Definition at line 57 of file ToyMemHeap.c.

References ErrMessage_t, ToySegment::len, MAX_PROCESSES, ToyMM::mem, SegList::next, ToySegment::pos, ToyMM::processList, SegList::seg, ToyMem::string, TMM_GetRealAddress(), ToyMem::type, Process::usedheap, and ToyMem_String::value.

Referenced by TMM_StoreString().

ErrMessage_t TMM_StoreInteger ToyMM   tm,
int    process,
int    addr,
int    val
 

Stores an integer in a process' memory.

One of two variations on STORE; this one attempts to store an integer in the specified address in process memory.

Definition at line 181 of file ToyMem.c.

References ErrMessage_t, ToyMem::integer, ToySegment::len, ToyMM::mem, SegList::next, ToySegment::pos, ToyMM::processList, SegList::seg, Process::segments, TMM_GetRealAddress(), TMM_SeekSegListHead(), TMM_StoreHeapInteger(), ToyMem::type, and ToyMem_Integer::value.

Referenced by TMM_ParseLine().

ErrMessage_t TMM_StoreString ToyMM   tm,
int    process,
int    addr,
const char *    str
 

Stores a string in a process' memory.

The second variation on STORE; attempts to store a string.

Definition at line 225 of file ToyMem.c.

References ErrMessage_t, ToySegment::len, ToyMM::mem, SegList::next, ToySegment::pos, ToyMM::processList, SegList::seg, Process::segments, ToyMem::string, TMM_GetRealAddress(), TMM_SeekSegListHead(), TMM_StoreHeapString(), ToyMem::type, and ToyMem_String::value.

Referenced by TMM_ParseLine().

ErrMessage_t TMM_TerminateProcess ToyMM   tmm,
int    ID
 

Terminates a process.

Returns 0 on success, -1, on failure.

See also:
TMM_AllocateProcessAt()

Definition at line 277 of file ToyMem.c.

References ErrMessage_t, Process::freeheap, ToySegment::len, SegList::next, ToySegment::pos, ToyMM::processList, SegList::seg, Process::segments, TMM_FreeSegList(), TMM_PagedTerminateProcess(), TMM_PagingEnabled(), TMM_SeekSegListHead(), and Process::usedheap.

Referenced by TMM_EnablePaging(), TMM_Free(), and TMM_ParseLine().

ErrMessage_t TMM_WatchPaging ToyMM   tmm,
int    process,
int    enable
 

Turns the TOYFLAG_WATCHPAGING flag on or off in the tmm.

Definition at line 95 of file ToyMemPage.c.

References ErrMessage_t, and ToyMM::watchPaging.

Referenced by TMM_ParseLine().


Variable Documentation

const char* ErrMessages[]  
 

String table of error message strings to match ErrMessage_t.

ERR_UNKNOWN and ERR_NONE do not have strings in the table.

Definition at line 41 of file ToyMem_Internal.h.


Generated on Fri Apr 4 14:29:08 2003 for ToyMem by doxygen1.3-rc3