Introduction to Operating Systems
CS 3113, Fall 2018
Project 0
The goal of project 0 is to make sure that you are successfully
working with your virtual machine instance to create, compile and test
simple C programs. Your program will take as input a
set of ASCII characters, count the number of each character value and then
produce a printed report that indicates how many of each character
has been observed.
Proper Academic Conduct
The code solution to this project must be done individually. Do not
copy solutions to this problem from the network and do not look at or
copy solutions from others. However, you may use the net for
inspiration and you may discuss your general approach with others.
Specification
Program invocation
The command-line interface to your program is as follows:
./project0 [<UPPER> [<LOWER>]]
- Your program must accept 0, 1 or 2 arguments. (The brackets
indicate optional parameters and the less-than/greater than characters
indicate the symbols that we use in the documentation to refer to the
parameters.
- If no arguments are specified, then the report will include
characters from SPACE to ‘}’ (close curly bracket).
- If the UPPER argument is specified, then the report will range from
the first character of the UPPER string to ‘}’.
- If both the UPPER and LOWER arguments are specified, then the report
will range from the first character of UPPER to that of LOWER.
Example invocation
Assume that the following characters are input to your program (these characters happen to form a c
program):
#include <stdio.h>
int main(int argc, char** argv)
{
printf("Hello, World!\n");
}
And assume that the program is invoked in the following way (piping
the C file to STDIN):
Then the output must match the following:
Range: a-z
a: 4 ####
b: 0
c: 3 ###
d: 3 ###
e: 2 ##
f: 1 #
g: 2 ##
h: 2 ##
i: 6 ######
j: 0
k: 0
l: 4 ####
m: 1 #
n: 6 ######
o: 3 ###
p: 1 #
q: 0
r: 5 #####
s: 1 #
t: 4 ####
u: 1 #
v: 1 #
w: 0
x: 0
y: 0
z: 0
The input to the program is received through STDIN. Counting of
characters ends when the end-of-file is reached.
Output
The output of the program is routed to STDOUT.
The first line of the report is of the form:
where:
- A is replaced with the upper character.
- B is replaced with the lower character.
- B is followed by a newline character.
The remaining lines of the output report the character counts from the
UPPER character to the LOWER character (following ASCII order). Each
line contains:
- The character
- : (colon)
- SPACE
- Four characters encoding the count (this number is right-flushed)
- SPACE
- A sequence of ‘#’ characters; the number is equal to the count
- A newline
Testing
- This tar file contains a set of example inputs and outputs:
project0_examples.tar.gz.
- Our testing program will automatically compare the output of your program against
a known file. In order to receive credit for the correctness of your
program, your output must match ours exactly (down to the byte).
- You can compare two files at the command line using the diff
program. This will help you in your testing. (Use
man diff
for usage information)
- We strongly recommend performing tests above and beyond those that
are provided for you.
- Be sure to handle edge cases in your implementation.
What to Hand In
Your files are to be submitted to the Canvas Project 0 dropbox.
Submit a single project0.tar.gz file that contains:
- project0.c: the source code
- project0: the compiled program
- Makefile: the makefile that compiles your program
- README.txt: a text documentation file that contains the following
information:
- Title: Project 0
- Your name and email address
- The date
- A short description of your approach to solving the
programming problem
- A list of references, including online resources and
individuals that you communicated with
In addition, place these files in the /projects/0/ directory on your
virtual machine instance. Make sure that this directory and its
contents are readable by all users (don’t worry, this is all users on
your own instance, not the class and not the world).
To create this folder you can use the following commands:
sudo mkdir -p /projects/0/
sudo chgrp -R google-sudoers /projects
sudo chown -R <username> /projects
sudo chmod --recursive 777 /projects
This code creates the projects and 0 directory. Then it changes group ownership to ‘google-sudoers’. Next, it changes to own to ‘username’ and you should include your google user name. The last lines changes the permissions so it is readable and viewable by all. The last two steps are necessary to be able to edit the files in the /projects directory.
Deadline
Your submission is due on Tuesday, September 11th at
11:45pm. Submissions arriving between 11:45:01pm and 11:45pm on the
following day will receive a 10% penalty. Any other submissions will
receive a zero.
Grading
Grades will be assessed according to the following distribution:
- 50%: Correctness. This will be assessed by giving your code a range
of inputs and checking the output.
- 20%: Documentation.
- Function-level documentation: each function must be
documented with the following:
- A short description of what the function does for
the user of your function
- A list of the input parameter names and a
description of the meaning of the parameter. This should include
a description of the valid parameter values, where appropriate.
- A description of the meaning of the return value.
- In-line documentation: within your implementation, place
short explanations of the intuition behind each (small) logical group
of code lines.
- 20% Design and Readability. This category includes:
- Correct and efficient code implementation
- Appropriate choice of function and variable names
- 10% Virtual Machine. Your VM instance is configured such that the
cs3113 teaching staff can login to it.
Notes
- Case matters in the Linux file system. When we ask for a file
called “project.c”, do not give us a file named “Project.c”.
- Because we will be testing with some binary files, you should assume
that character values can range from 0 to 255. These values are listed
in the ASCII Table.
- Examine the documentation for the getchar() function to see what it
does when the end of the input is reached (i.e., the “End of File” is
reached).
- Examine the documentation for the printf() function. There, you
will find useful information about things like formatting numbers
nicely.
- See the tar man page for details about how to create tar.gz files.
- The website explainshell.com is helpful in understanding some combinations of command line programs.
Back to Project List