free: add a Linux like "free" command to see swap and memory usage
authorAlan Cox <alan@linux.intel.com>
Mon, 23 Oct 2017 14:50:01 +0000 (15:50 +0100)
committerAlan Cox <alan@linux.intel.com>
Mon, 23 Oct 2017 14:50:01 +0000 (15:50 +0100)
Applications/util/Makefile.6502
Applications/util/Makefile.68000
Applications/util/Makefile.6809
Applications/util/Makefile.z80
Applications/util/free.c [new file with mode: 0644]
Applications/util/fuzix-util.pkg

index 3a75674..c659cb8 100644 (file)
@@ -65,6 +65,7 @@ SRCS  = \
        factor.c \
        fdisk.c \
        fgrep.c \
+       free.c \
        grep.c \
        id.c \
        kbdrate.c \
index 1a55c68..35ae170 100644 (file)
@@ -72,6 +72,7 @@ SRCS  = \
        fdisk.c \
        fforth.c \
        fgrep.c \
+       free.c \
        fsck.c \
        grep.c \
        id.c \
index 3ce3b1e..db28d7d 100644 (file)
@@ -72,6 +72,7 @@ SRCS  = \
        fdisk.c \
        fforth.c \
        fgrep.c \
+       free.c \
        fsck.c \
        grep.c \
        id.c \
index 5191385..1519462 100644 (file)
@@ -66,6 +66,7 @@ SRCS  = banner.c \
        factor.c \
        fdisk.c \
        fgrep.c \
+       free.c \
        fsck.c \
        grep.c \
        id.c \
diff --git a/Applications/util/free.c b/Applications/util/free.c
new file mode 100644 (file)
index 0000000..570254b
--- /dev/null
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <syscalls.h>
+#include <time.h>
+
+int main(int argc, char *argv[])
+{
+       static struct {
+               struct _uzisysinfoblk i;
+               char buf[128];
+       } uts;
+       int bytes = _uname(&uts.i, sizeof(uts));
+       printf("         total         used         free\n");
+       printf("Mem:     %5d        %5d        %5d\n",
+               uts.i.memk, uts.i.usedk, uts.i.memk - uts.i.usedk);
+       printf("Swap:    %5d        %5d        %5d\n",
+               uts.i.swapk, uts.i.swapusedk, uts.i.swapk - uts.i.swapusedk);
+       return 0;
+}
+
index ce73fd8..36c047f 100644 (file)
@@ -65,6 +65,7 @@ f 0755 /bin/env         env
 f 0755 /bin/factor      factor
 f 0755 /bin/false       false
 f 0755 /bin/fdisk       fdisk
+f 0755 /bin/free        free
 f 0755 /bin/fsck        fsck
 f 0755 /bin/grep        grep
 f 0755 /bin/groups      groups