CS318 - Pintos
Pintos source browser for JHU CS318 course
child-qsort-mm.c
Go to the documentation of this file.
1 /** Mmaps a 128 kB file "sorts" the bytes in it, using quick sort,
2  a multi-pass divide and conquer algorithm. */
3 
4 #include <debug.h>
5 #include <syscall.h>
6 #include "tests/lib.h"
7 #include "tests/main.h"
8 #include "tests/vm/qsort.h"
9 
10 const char *test_name = "child-qsort-mm";
11 
12 int
13 main (int argc UNUSED, char *argv[])
14 {
15  int handle;
16  unsigned char *p = (unsigned char *) 0x10000000;
17 
18  quiet = true;
19 
20  CHECK ((handle = open (argv[1])) > 1, "open \"%s\"", argv[1]);
21  CHECK (mmap (handle, p) != MAP_FAILED, "mmap \"%s\"", argv[1]);
22  qsort_bytes (p, 1024 * 128);
23 
24  return 80;
25 }
lib.h
CHECK
#define CHECK(SUCCESS,...)
Takes an expression to test for SUCCESS and a message, which may include printf-style arguments.
Definition: lib.h:29
UNUSED
#define UNUSED
GCC lets us add "attributes" to functions, function parameters, etc.
Definition: debug.h:7
MAP_FAILED
#define MAP_FAILED
Definition: syscall.h:13
open
int open(const char *file)
Definition: syscall.c:103
test_name
const char * test_name
Mmaps a 128 kB file "sorts" the bytes in it, using quick sort, a multi-pass divide and conquer algori...
Definition: child-qsort-mm.c:10
qsort.h
qsort_bytes
void qsort_bytes(unsigned char *buf, size_t size)
Sorts the SIZE bytes in BUF into nondecreasing order, using the quick-sort algorithm.
Definition: qsort.c:114
main.h
mmap
mapid_t mmap(int fd, void *addr)
Project 3 and optionally project 4.
Definition: syscall.c:145
main
int main(int argc UNUSED, char *argv[])
Definition: child-qsort-mm.c:13
quiet
bool quiet
Definition: lib.c:9
debug.h