| CS318 - Pintos
    Pintos source browser for JHU CS318 course | 
#include "tests/vm/parallel-merge.h"#include <stdio.h>#include <syscall.h>#include "tests/arc4.h"#include "tests/lib.h"#include "tests/main.h"
Go to the source code of this file.
| Macros | |
| #define | CHUNK_SIZE (128 * 1024) | 
| Generates about 1 MB of random data that is then divided into 16 chunks.  More... | |
| #define | CHUNK_CNT 8 | 
| Number of chunks.  More... | |
| #define | DATA_SIZE (CHUNK_CNT * CHUNK_SIZE) | 
| Buffer size.  More... | |
| Functions | |
| static void | init (void) | 
| Initialize buf1 with random data, then count the number of instances of each value within it.  More... | |
| static void | sort_chunks (const char *subprocess, int exit_status) | 
| Sort each chunk of buf1 using SUBPROCESS, which is expected to return EXIT_STATUS.  More... | |
| static void | merge (void) | 
| Merge the sorted chunks in buf1 into a fully sorted buf2.  More... | |
| static void | verify (void) | 
| void | parallel_merge (const char *child_name, int exit_status) | 
| tests/vm/parallel-merge.h  More... | |
| Variables | |
| unsigned char | buf1 [DATA_SIZE] | 
| unsigned char | buf2 [DATA_SIZE] | 
| size_t | histogram [256] | 
| #define CHUNK_CNT 8 | 
Number of chunks.
Definition at line 14 of file parallel-merge.c.
| #define CHUNK_SIZE (128 * 1024) | 
Generates about 1 MB of random data that is then divided into 16 chunks.
A separate subprocess sorts each chunk; the subprocesses run in parallel. Then we merge the chunks and verify that the result is what it should be.
Definition at line 13 of file parallel-merge.c.
| #define DATA_SIZE (CHUNK_CNT * CHUNK_SIZE) | 
Buffer size.
Definition at line 15 of file parallel-merge.c.
| 
 | static | 
Initialize buf1 with random data, then count the number of instances of each value within it.
Definition at line 23 of file parallel-merge.c.
References arc4_crypt(), arc4_init(), buf1, histogram, arc4::i, and msg().
Referenced by parallel_merge().


| 
 | static | 
Merge the sorted chunks in buf1 into a fully sorted buf2.
Definition at line 85 of file parallel-merge.c.
References buf1, buf2, CHUNK_CNT, CHUNK_SIZE, arc4::i, and msg().
Referenced by parallel_merge().


| void parallel_merge | ( | const char * | child_name, | 
| int | exit_status | ||
| ) | 
Definition at line 143 of file parallel-merge.c.
References init(), merge(), sort_chunks(), and verify().
Referenced by test_main().


| 
 | static | 
Sort each chunk of buf1 using SUBPROCESS, which is expected to return EXIT_STATUS.
Definition at line 39 of file parallel-merge.c.
References buf1, CHECK, CHUNK_CNT, CHUNK_SIZE, close(), create(), exec(), arc4::i, msg(), open(), quiet, read(), snprintf(), wait(), and write().
Referenced by parallel_merge().


| 
 | static | 
Definition at line 120 of file parallel-merge.c.
References buf2, fail(), histogram, and msg().
Referenced by parallel_merge().


| unsigned char buf1[DATA_SIZE] | 
Definition at line 17 of file parallel-merge.c.
Referenced by init(), merge(), and sort_chunks().
| unsigned char buf2[DATA_SIZE] | 
Definition at line 17 of file parallel-merge.c.
| size_t histogram[256] | 
Definition at line 18 of file parallel-merge.c.
 1.8.16
 1.8.16