]> Devi Nivas Git - cs3210-lab0.git/commitdiff
Part 4 (Max Mem Size)
authorAdvaith Menon <noreply-git@bp4k.net>
Thu, 15 Jan 2026 13:47:42 +0000 (19:17 +0530)
committerAdvaith Menon <noreply-git@bp4k.net>
Thu, 15 Jan 2026 13:47:42 +0000 (19:17 +0530)
user/src/lab0/limits.c

index 38a918873a85dc7c4e15efdad08aebbfd15cba64..745f205b120d30547cc4c8dbe45b1ce2a6741fdf 100644 (file)
@@ -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();
+}