Re-enable all diagnostic printfs
authorNick Downing <nick@ndcode.org>
Fri, 31 May 2019 13:13:10 +0000 (23:13 +1000)
committerNick Downing <nick@ndcode.org>
Fri, 31 May 2019 13:13:10 +0000 (23:13 +1000)
core.h
process.c
process_test_run.c

diff --git a/core.h b/core.h
index c0960be..7e2c1f6 100644 (file)
--- a/core.h
+++ b/core.h
@@ -1,7 +1,7 @@
 #ifndef _CORE_H
 #define _CORE_H 1
 
-//#define INDIRECT_CORE 1
+#define INDIRECT_CORE 1
 
 #include <stdint.h>
 #ifdef INDIRECT_CORE
index c893eb3..864fe7b 100644 (file)
--- a/process.c
+++ b/process.c
@@ -42,7 +42,7 @@ void process_init(int n, int spare) {
 #endif /* INDIRECT_CORE */
   if (process_avail > swap_table.avail)
     process_avail = swap_table.avail;
//printf("process_avail %d\n", process_avail);
+ printf("process_avail %d\n", process_avail);
 
   lru_head.prev = &lru_head;
   lru_head.next = &lru_head;
@@ -97,7 +97,7 @@ static bool do_swap_out(int swap_out) {
         blocks = victim_core_blocks;
 #endif /* INDIRECT_SWAP */
 #endif /* INDIRECT_CORE */
//printf("existing victim %d, swap out %d of %d\n", (int)(victim - processes), blocks, victim_core_blocks);
+ printf("existing victim %d, swap out %d of %d\n", (int)(victim - processes), blocks, victim_core_blocks);
 
       // increase swap allocation
       goto loop_entry;
@@ -123,7 +123,7 @@ static bool do_swap_out(int swap_out) {
       if (blocks > victim_core_blocks)
         blocks = victim_core_blocks;
 #endif /* INDIRECT_SWAP */
//printf("new victim %d, swap out %d of %d\n", (int)(victim - processes), blocks, victim_core_blocks);
+ printf("new victim %d, swap out %d of %d\n", (int)(victim - processes), blocks, victim_core_blocks);
 
       // add to swap pool
       victim_swap_blocks = 0;
@@ -152,7 +152,7 @@ static bool do_swap_out(int swap_out) {
       // transfer data to swap
 #ifndef INDIRECT_CORE
 #ifndef INDIRECT_SWAP
//printf("write core [%d,%d) to swap [%d,%d)\n", core_base, core_base + blocks, swap_base, swap_base + blocks);
+ printf("write core [%d,%d) to swap [%d,%d)\n", core_base, core_base + blocks, swap_base, swap_base + blocks);
       core_to_swap_copy(
         (long)core_base << BLOCK_SHIFT,
         (long)swap_base << BLOCK_SHIFT,
@@ -163,14 +163,14 @@ static bool do_swap_out(int swap_out) {
 #endif /* INDIRECT_SWAP */
       );
 #ifdef INDIRECT_SWAP
//printf("write core [%d,%d) to swap [%d,%d)\n", core_base, core_base + blocks, swap_base, swap_base + blocks);
+ printf("write core [%d,%d) to swap [%d,%d)\n", core_base, core_base + blocks, swap_base, swap_base + blocks);
       j = (int)(size >> BLOCK_SHIFT);
//printf("blocks");
+ printf("blocks");
       for (i = 0; i < j; ++i) {
         core_block = core_base + i;
         swap_block = swap_base + i;
         swap_block = swap_table_mem[swap_block];
//printf(" %d", swap_block);
+ printf(" %d", swap_block);
         core_to_swap_copy(
           (long)core_block << BLOCK_SHIFT,
           (long)swap_block << BLOCK_SHIFT,
@@ -182,7 +182,7 @@ static bool do_swap_out(int swap_out) {
         core_block = core_base + i;
         swap_block = swap_base + i;
         swap_block = swap_table_mem[swap_block];
//printf(" %d", swap_block);
+ printf(" %d", swap_block);
  //putchar('*');
         core_to_swap_copy(
           (long)core_block << BLOCK_SHIFT,
@@ -190,7 +190,7 @@ static bool do_swap_out(int swap_out) {
           j
         );
       }
//printf("\n");
+ printf("\n");
 #endif /* INDIRECT_SWAP */
 #else /* INDIRECT_CORE */
 #ifdef INDIRECT_SWAP
@@ -198,17 +198,17 @@ static bool do_swap_out(int swap_out) {
         block_pool_alloc(&swap_block_pool, swap_table_mem + swap_base, blocks)
       );
 #endif /* INDIRECT_SWAP */
//printf("write core [%d,%d) to swap [%d,%d)\n", core_base, core_base + blocks, swap_base, swap_base + blocks);
+ printf("write core [%d,%d) to swap [%d,%d)\n", core_base, core_base + blocks, swap_base, swap_base + blocks);
       j = (int)(size >> BLOCK_SHIFT);
//printf("blocks");
+ printf("blocks");
       for (i = 0; i < j; ++i) {
         core_block = core_base + i;
         core_block = core_table_mem[core_block];
//printf(" %d", core_block);
+ printf(" %d", core_block);
         swap_block = swap_base + i;
 #ifdef INDIRECT_SWAP
         swap_block = swap_table_mem[swap_block];
//printf(",%d", swap_block);
+ printf(",%d", swap_block);
 #endif /* INDIRECT_SWAP */
         core_to_swap_copy(
           (long)core_block << BLOCK_SHIFT,
@@ -220,11 +220,11 @@ static bool do_swap_out(int swap_out) {
       if (j) {
         core_block = core_base + i;
         core_block = core_table_mem[core_block];
//printf(" %d", core_block);
+ printf(" %d", core_block);
         swap_block = swap_base + i;
 #ifdef INDIRECT_SWAP
         swap_block = swap_table_mem[swap_block];
//printf(",%d", swap_block);
+ printf(",%d", swap_block);
 #endif /* INDIRECT_SWAP */
  //putchar('*');
         core_to_swap_copy(
@@ -233,7 +233,7 @@ static bool do_swap_out(int swap_out) {
           j
         );
       }
//printf("\n");
+ printf("\n");
       block_pool_free(&core_block_pool, core_table_mem + core_base, blocks);
 #endif /* INDIRECT_CORE */
       victim_swap_blocks += blocks;
@@ -258,7 +258,7 @@ static bool do_swap_out(int swap_out) {
         // report whether aborted due to swap space or user request
         return swap_out == blocks;
       }
//printf("victimized %d\n", (int)(victim - processes));
+ printf("victimized %d\n", (int)(victim - processes));
 
 #ifndef INDIRECT_CORE
       // remove from core pool
@@ -559,7 +559,7 @@ void process_run(struct process *process) {
 #ifdef INDIRECT_CORE
       block_pool_alloc(&core_block_pool, core_table_mem + core_base, blocks);
 #endif /* INDIRECT_CORE */
//printf("read swap [%d,%d) to core [%d,%d)\n", swap_base, swap_base + blocks, core_base, core_base + blocks);
+ printf("read swap [%d,%d) to core [%d,%d)\n", swap_base, swap_base + blocks, core_base, core_base + blocks);
 #ifndef INDIRECT_CORE
 #ifndef INDIRECT_SWAP
       swap_to_core_copy(
@@ -569,12 +569,12 @@ void process_run(struct process *process) {
       );
 #else /* INDIRECT_SWAP */
       j = (int)(size >> BLOCK_SHIFT);
//printf("blocks");
+ printf("blocks");
       for (i = 0; i < j; ++i) {
         int core_block = core_base + i;
         int swap_block = swap_base + i;
         swap_block = swap_table_mem[swap_block];
//printf(",%d", swap_block);
+ printf(",%d", swap_block);
         swap_to_core_copy(
           (long)swap_block << BLOCK_SHIFT,
           (long)core_block << BLOCK_SHIFT,
@@ -586,27 +586,27 @@ void process_run(struct process *process) {
         int core_block = core_base + i;
         int swap_block = swap_base + i;
         swap_block = swap_table_mem[swap_block];
//printf(",%d", swap_block);
+ printf(",%d", swap_block);
         swap_to_core_copy(
           (long)swap_block << BLOCK_SHIFT,
           (long)core_block << BLOCK_SHIFT,
           j
         );
       }
//printf("\n");
+ printf("\n");
       block_pool_free(&swap_block_pool, swap_table_mem + swap_base, blocks);
 #endif /* INDIRECT_SWAP */
 #else /* INDIRECT_CORE */
       j = (int)(size >> BLOCK_SHIFT);
//printf("blocks");
+ printf("blocks");
       for (i = 0; i < j; ++i) {
         int core_block = core_base + i;
         core_block = core_table_mem[core_block];
//printf(" %d", core_block);
+ printf(" %d", core_block);
         int swap_block = swap_base + i;
 #ifdef INDIRECT_SWAP
         swap_block = swap_table_mem[swap_block];
//printf(",%d", swap_block);
+ printf(",%d", swap_block);
 #endif /* INDIRECT_SWAP */
         swap_to_core_copy(
           (long)swap_block << BLOCK_SHIFT,
@@ -618,11 +618,11 @@ void process_run(struct process *process) {
       if (j) {
         int core_block = core_base + i;
         core_block = core_table_mem[core_block];
//printf(" %d", core_block);
+ printf(" %d", core_block);
         int swap_block = swap_base + i;
 #ifdef INDIRECT_SWAP
         swap_block = swap_table_mem[swap_block];
//printf(",%d", swap_block);
+ printf(",%d", swap_block);
 #endif /* INDIRECT_SWAP */
         swap_to_core_copy(
           (long)swap_block << BLOCK_SHIFT,
@@ -630,7 +630,7 @@ void process_run(struct process *process) {
           j
         );
       }
//printf("\n");
+ printf("\n");
 #ifdef INDIRECT_SWAP
       block_pool_free(&swap_block_pool, swap_table_mem + swap_base, blocks);
 #endif /* INDIRECT_SWAP */
index bff1c5f..f9e9b8f 100644 (file)
@@ -19,7 +19,7 @@ void core_hash_init(int process, long base, long size, long offset) {
   long i, addr;
   long long hash;
 
//printf("core_hash_init %d %ld(%d) %ld(%d) %ld(%d)\n", process, base, (int)(base >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT), offset, (int)(offset >> BLOCK_SHIFT));
+ printf("core_hash_init %d %ld(%d) %ld(%d) %ld(%d)\n", process, base, (int)(base >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT), offset, (int)(offset >> BLOCK_SHIFT));
   for (i = 0L; i < size; ++i) {
     addr = base + i;
 #ifdef INDIRECT_CORE
@@ -41,7 +41,7 @@ void core_hash_verify(int process, long base, long size, long offset) {
   long i, addr;
   long long hash;
 
//printf("core_hash_verify %d %ld(%d) %ld(%d) %ld(%d)\n", process, base, (int)(base >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT), offset, (int)(offset >> BLOCK_SHIFT));
+ printf("core_hash_verify %d %ld(%d) %ld(%d) %ld(%d)\n", process, base, (int)(base >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT), offset, (int)(offset >> BLOCK_SHIFT));
   for (i = 0L; i < size; ++i) {
     addr = base + i;
 #ifdef INDIRECT_CORE
@@ -63,7 +63,7 @@ void swap_hash_verify(int process, long base, long size) {
   long i, addr;
   long long hash;
 
//printf("swap_hash_verify %d %ld(%d) %ld(%d)\n", process, base, (int)(base >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT));
+ printf("swap_hash_verify %d %ld(%d) %ld(%d)\n", process, base, (int)(base >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT));
   for (i = 0L; i < size; ++i) {
     addr = base + i;
 #ifdef INDIRECT_SWAP
@@ -85,7 +85,7 @@ void swap_hash_verify(int process, long base, long size) {
 void core_copy(long src_base, long dest_base, long size) {
   long i;
 
//printf("core_copy %ld(%d) %ld(%d) %ld(%d)\n", src_base, (int)(src_base >> BLOCK_SHIFT), dest_base, (int)(dest_base >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT));
+ printf("core_copy %ld(%d) %ld(%d) %ld(%d)\n", src_base, (int)(src_base >> BLOCK_SHIFT), dest_base, (int)(dest_base >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT));
   for (i = 0L; i < size; ++i) {
     core_block_mem[dest_base + i] = core_block_mem[src_base + i];
     core_block_mem[src_base + i] = 0xaa;
@@ -95,7 +95,7 @@ void core_copy(long src_base, long dest_base, long size) {
 void core_copy_up(long src_limit, long dest_limit, long size) {
   long i;
 
//printf("core_copy_up %ld(%d) %ld(%d) %ld(%d)\n", src_limit, (int)(src_limit >> BLOCK_SHIFT), dest_limit, (int)(dest_limit >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT));
+ printf("core_copy_up %ld(%d) %ld(%d) %ld(%d)\n", src_limit, (int)(src_limit >> BLOCK_SHIFT), dest_limit, (int)(dest_limit >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT));
   size = -size;
   for (i = -1L; i >= size; --i) {
     core_block_mem[dest_limit + i] = core_block_mem[src_limit + i];
@@ -108,7 +108,7 @@ void core_copy_up(long src_limit, long dest_limit, long size) {
 void swap_copy(long src_base, long dest_base, long size) {
   long i;
 
//printf("swap_copy %ld(%d) %ld(%d) %ld(%d)\n", src_base, (int)(src_base >> BLOCK_SHIFT), dest_base, (int)(dest_base >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT));
+ printf("swap_copy %ld(%d) %ld(%d) %ld(%d)\n", src_base, (int)(src_base >> BLOCK_SHIFT), dest_base, (int)(dest_base >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT));
   for (i = 0; i < size; ++i) {
     swap_block_mem[dest_base + i] = swap_block_mem[src_base + i];
     swap_block_mem[src_base + i] = 0xaa;
@@ -118,7 +118,7 @@ void swap_copy(long src_base, long dest_base, long size) {
 void swap_copy_up(long src_limit, long dest_limit, long size) {
   long i;
 
//printf("swap_copy_up %ld(%d) %ld(%d) %ld(%d)\n", src_limit, (int)(src_limit >> BLOCK_SHIFT), dest_limit, (int)(dest_limit >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT));
+ printf("swap_copy_up %ld(%d) %ld(%d) %ld(%d)\n", src_limit, (int)(src_limit >> BLOCK_SHIFT), dest_limit, (int)(dest_limit >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT));
   size = -size;
   for (i = -1; i >= size; --i) {
     swap_block_mem[dest_limit + i] = swap_block_mem[src_limit + i];
@@ -130,7 +130,7 @@ void swap_copy_up(long src_limit, long dest_limit, long size) {
 void core_to_swap_copy(long src_base, long dest_base, long size) {
   long i;
 
//printf("core_to_swap_copy %ld(%d) %ld(%d) %ld(%d)\n", src_base, (int)(src_base >> BLOCK_SHIFT), dest_base, (int)(dest_base >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT));
+ printf("core_to_swap_copy %ld(%d) %ld(%d) %ld(%d)\n", src_base, (int)(src_base >> BLOCK_SHIFT), dest_base, (int)(dest_base >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT));
   for (i = 0; i < size; ++i)
     rassert(swap_block_mem[dest_base + i] == 0xaa);
   memcpy(swap_block_mem + dest_base, core_block_mem + src_base, size);
@@ -140,7 +140,7 @@ void core_to_swap_copy(long src_base, long dest_base, long size) {
 void swap_to_core_copy(long src_base, long dest_base, long size) {
   long i;
 
//printf("swap_to_core_copy %ld(%d) %ld(%d) %ld(%d)\n", src_base, (int)(src_base >> BLOCK_SHIFT), dest_base, (int)(dest_base >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT));
+ printf("swap_to_core_copy %ld(%d) %ld(%d) %ld(%d)\n", src_base, (int)(src_base >> BLOCK_SHIFT), dest_base, (int)(dest_base >> BLOCK_SHIFT), size, (int)((size + (BLOCK_SIZE - 1)) >> BLOCK_SHIFT));
   for (i = 0; i < size; ++i)
     rassert(core_block_mem[dest_base + i] == 0xaa);
   memcpy(core_block_mem + dest_base, swap_block_mem + src_base, size);
@@ -326,14 +326,14 @@ int main(int argc, char **argv) {
             processes[test.process].core_item.limit ==
               core_base + blocks
           );
//printf("new core [%d,%d)\n", core_base, core_base + blocks);
+ printf("new core [%d,%d)\n", core_base, core_base + blocks);
           core_hash_init(
             test.process,
             (long)core_base << BLOCK_SHIFT,
             test.size,
             0L
           );
//printf("new swap [%d,%d)\n", processes[test.process].swap_item.base, processes[test.process].swap_item.limit);
+ printf("new swap [%d,%d)\n", processes[test.process].swap_item.base, processes[test.process].swap_item.limit);
         }
       }
       break;
@@ -365,7 +365,7 @@ int main(int argc, char **argv) {
           );
           rassert(actual_old_blocks <= old_blocks);
         }
//printf("old core [%d,%d) swap [%d,%d)\n", core_base, core_base + actual_old_blocks, processes[test.process].swap_item.base, processes[test.process].swap_item.limit);
+ printf("old core [%d,%d) swap [%d,%d)\n", core_base, core_base + actual_old_blocks, processes[test.process].swap_item.base, processes[test.process].swap_item.limit);
         core_hash_verify(
           test.process,
           ((long)core_base << BLOCK_SHIFT) + test.size,
@@ -391,7 +391,7 @@ int main(int argc, char **argv) {
               processes[test.process].core_item.limit ==
                 core_base + blocks
             );
//printf("new core [%d,%d) swap [%d,%d)\n", core_base, core_base + blocks, processes[test.process].swap_item.base, processes[test.process].swap_item.limit);
+ printf("new core [%d,%d) swap [%d,%d)\n", core_base, core_base + blocks, processes[test.process].swap_item.base, processes[test.process].swap_item.limit);
             core_hash_init(
               test.process,
               ((long)core_base << BLOCK_SHIFT) + actual_old_size,
@@ -461,7 +461,7 @@ int main(int argc, char **argv) {
           }
         }
         rassert(core_blocks + swap_blocks == actual_old_blocks);
//printf("old core [%d,%d) swap [%d,%d)\n", core_base, core_base + core_blocks, swap_base, swap_base + swap_blocks);
+ printf("old core [%d,%d) swap [%d,%d)\n", core_base, core_base + core_blocks, swap_base, swap_base + swap_blocks);
  fflush(stdout);
         core_hash_verify(
           test.process,