Back out change from commit f4338d0 to process_avail, as process_avail was already...
authorNick Downing <nick@ndcode.org>
Mon, 22 Apr 2019 06:23:04 +0000 (16:23 +1000)
committerNick Downing <nick@ndcode.org>
Mon, 22 Apr 2019 06:26:45 +0000 (16:26 +1000)
indirect_core_inode_swap/o.sh
moveable_core_inode_swap/o.sh
o.sh
process.c

index 5a42b5f..bbaadfd 100755 (executable)
@@ -5,8 +5,6 @@ echo "generate test script"
 
 echo "run test script"
 rm -f fs.bin
-# we need 1536 x 0.5 kbyte data blocks for 192 x 4 = 768 kbytes of swap data,
-# add 6 FULL indirect blocks, 32 partial indirect/double indirect, 1 root dir,
-# thus data part of volume will need 1575 blocks, so use 25 blocks of inodes
-../mkfs fs.bin 25 1600
+# need 1536 x 0.5 kbyte for 192 x 4 = 768 kbytes, plus 1 x 0.5 kbyte root dir
+../mkfs fs.bin 63 1600
 ./process_test_run 16 64 fs.bin 8 384 <process_test.txt
index c8d5d83..b356aee 100755 (executable)
@@ -5,8 +5,6 @@ echo "generate test script"
 
 echo "run test script"
 rm -f fs.bin
-# we need 1536 x 0.5 kbyte data blocks for 192 x 4 = 768 kbytes of swap data,
-# add 6 FULL indirect blocks, 32 partial indirect/double indirect, 1 root dir,
-# thus data part of volume will need 1575 blocks, so use 25 blocks of inodes
-../mkfs fs.bin 25 1600
+# need 1536 x 0.5 kbyte for 192 x 4 = 768 kbytes, plus 1 x 0.5 kbyte root dir
+../mkfs fs.bin 63 1600
 ./process_test_run 16 64 fs.bin 8 <process_test.txt
diff --git a/o.sh b/o.sh
index 0bde1b7..7635678 100755 (executable)
--- a/o.sh
+++ b/o.sh
@@ -6,8 +6,6 @@ echo "generate test script"
 echo "run test script"
 #./process_test_run 16 64 192 8 384 384 <process_test.txt
 rm -f fs.bin
-# we need 1536 x 0.5 kbyte data blocks for 192 x 4 = 768 kbytes of swap data,
-# add 6 FULL indirect blocks, 32 partial indirect/double indirect, 1 root dir,
-# thus data part of volume will need 1575 blocks, so use 25 blocks of inodes
-./mkfs fs.bin 25 1600
+# need 1536 x 0.5 kbyte for 192 x 4 = 768 kbytes, plus 1 x 0.5 kbyte root dir
+./mkfs fs.bin 63 1600
 ./process_test_run 16 64 fs.bin 8 384 384 <process_test.txt
index ea90df5..e11bb09 100644 (file)
--- a/process.c
+++ b/process.c
@@ -57,11 +57,11 @@ static long estimate_size(long size) {
 
 // basically the inverse of the above, estimates size of files that could be
 // created if space is divided into at most n files, but a bit conservatively
-static long estimate_free(int n) {
+static long estimate_free(/*int n*/) {
   int blocks;
 
   // at most one partial indirect and double indirect block per file
-  blocks = fs_tab[0].s_tfree - (n << 1);
+  blocks = fs_tab[0].s_tfree - 2/*(n << 1)*/;
   // max number of FULL indirect blocks (ignore the 18 direct blocks)
   blocks -= blocks / (DISK_INDIRECT_SIZE + 1);
   return (long)blocks << DISK_BLOCK_SHIFT;
@@ -87,7 +87,7 @@ void process_init(int n, int spare) {
 #ifdef INODE_SWAP
   process_avail =
     ((long)(CORE_AVAIL - spare) << BLOCK_SHIFT) +
-    estimate_free(n_processes);
+    ((long)fs_tab[0].s_tfree << DISK_BLOCK_SHIFT);
 #ifdef PREALLOCATE_CORE
   core_table_avail = (long)core_table.avail << BLOCK_SHIFT;
   if (process_avail > core_table_avail)
@@ -140,7 +140,7 @@ static bool do_swap_out(int swap_out) {
       // calculate amount to swap out
 #if !defined(PREALLOCATE_SWAP) || defined(INDIRECT_SWAP)
 #ifdef INODE_SWAP
-      blocks = (int)(estimate_free(1) >> BLOCK_SHIFT);
+      blocks = (int)(estimate_free(/*1*/) >> BLOCK_SHIFT);
 #else
       blocks = SWAP_AVAIL;
 #endif
@@ -183,7 +183,7 @@ static bool do_swap_out(int swap_out) {
       // calculate amount to swap out
 #if !defined(PREALLOCATE_SWAP) || defined(INDIRECT_SWAP)
 #ifdef INODE_SWAP
-      blocks = (int)(estimate_free(1) >> BLOCK_SHIFT);
+      blocks = (int)(estimate_free(/*1*/) >> BLOCK_SHIFT);
 #else
       blocks = SWAP_AVAIL;
 #endif