PKUOS - Pintos
Pintos source browser for PKU Operating System 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
10const char *test_name = "child-qsort-mm";
11
12int
13main (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}
int main(int argc UNUSED, char *argv[])
const char * test_name
Mmaps a 128 kB file "sorts" the bytes in it, using quick sort, a multi-pass divide and conquer algori...
#define UNUSED
GCC lets us add "attributes" to functions, function parameters, etc.
Definition: debug.h:7
mapid_t mmap(int fd, void *addr)
Project 3 and optionally project 4.
Definition: syscall.c:145
int open(const char *file)
Definition: syscall.c:103
#define MAP_FAILED
Definition: syscall.h:13
bool quiet
Definition: lib.c:9
#define CHECK(SUCCESS,...)
Takes an expression to test for SUCCESS and a message, which may include printf-style arguments.
Definition: lib.h:29
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