the program should expect 2 cmd-line args.
The first arg will be an integer which will be the number of pages of memory
that the program should obtain via mmap.
The second arg will be a filename. The file will contain one cmd per line.
Each cmd should be interpreted by the program. Lines that begin with # are
comments and should be skipped; empty/blank lines should also be skipped.
Initialize the mmap’d space with a set of node structures:
struct node {
long int val;
struct node *next;
};
where val is initialized to -1, and next to NULL.
The commands to interpet are:
isrt val
place val into the next open node in the mmap’d space and also
hook it into the linked list sorted by increasing val’s
(for duplicate value, silently ignore the cmd)
(do NOT print anything if the cmd is successful)
(if out of space, give an error msg and exit(-1); )
delt val
remove the item from the linked list and then reset the node’s
val to -1 and next pointer to NULL
(if the val is not in list, silently ignore the cmd)
(do NOT print anything if the cmd is successful)
prtt some text
prints the text on a single line, e.g.:
prtt harry potter
would print:
harry potter
prtu
prints vals sequentially from the beginning of the mmap’d space;
they are NOT to printed in sorted order; skip those with val -1
print each val and its next pointer (using %p) on a single line
separated by two spaces
prts
prints sorted list by following the next pointers;
print each val and its next pointer (using %p) on a single line
separated by two spaces
blnk
prints blank line