From: Advaith Menon Date: Thu, 15 Jan 2026 13:47:42 +0000 (+0530) Subject: Part 4 (Max Mem Size) X-Git-Url: https://git.devinivas.org/?a=commitdiff_plain;h=126d04d182748348b56bec78c2903ade109ed239;p=cs3210-lab0.git Part 4 (Max Mem Size) --- diff --git a/user/src/lab0/limits.c b/user/src/lab0/limits.c index 38a9188..745f205 100644 --- a/user/src/lab0/limits.c +++ b/user/src/lab0/limits.c @@ -3,11 +3,24 @@ #include "user.h" #define PGSIZE 4096 // 4K Page size +#define CURRENTLY_OCCUPIED_MEM 0 +#define STDOUT_FD 1 int main(int argc, char *argv[]) { - // Student code goes here + // Student code goes here + int memsz; - exit(); -} \ No newline at end of file + /* initialize to current memory */ + /* TODO look at exec call and see if we care about stack memory */ + memsz = CURRENTLY_OCCUPIED_MEM; + + /* start allocating memory */ + while ((int) sbrk(PGSIZE) != -1) + memsz += PGSIZE; + + printf(STDOUT_FD, "Maximum Memory Size: 0x%x\n", memsz); + + exit(); +}