From 126d04d182748348b56bec78c2903ade109ed239 Mon Sep 17 00:00:00 2001 From: Advaith Menon Date: Thu, 15 Jan 2026 19:17:42 +0530 Subject: [PATCH] Part 4 (Max Mem Size) --- user/src/lab0/limits.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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(); +} -- 2.47.3