Software Systems Project 1 solution


Original Work


5/5 - (1 vote)

Software Systems
Project 1 (8% credit)
Due: 4 Feb 2016 at 11:59pm(no late submissions accepted)
You can discuss high-level concepts with other students, but you are required to write your own code.
We will be running the MOSS analyzer to detect any form of copying, including those copying from
previous years
All offenders will receive zero for this assignment, get an automatic one grade downgrade, and be
referred to the Office of Student Conduct (OSC) for first time offence, regardless of severity of
violation. Offenders may be suspended for one semester by our university. In addition, if any solutions
or code were obtained from a student who has taken this class previously, that student will similarly be
referred to OSC and receive a similar set of points deductions, resulting in a change of grade. Students
who have graduated but are found out to have supplied code or solutions to this batch of students will
similarly be dealt with under our school’s academic integrity guidelines. If you are unsure whether you
can use an existing library or data structure, consult with the teaching staff.
1. Introduction
In this exercise, you will conduct some simple performance experiments and explore the POSIX
standard user level thread library. To submit your work, put your source and text files in a
directory and use the turnin command on the speclab cluster. All programs should be written in C
or C++ and compiled on the speclab machines especially the third part of the project. Follow the
submission guidelines for turnin given at the end of this document.
Important: Take the time to write and code your answers clearly and lucidly, whether the
language you are using is English or C.
VERY IMPORTANT: Submit only your source code and supporting text. Do not include compiled or
large output files (e.g, write.out or fprint.out) in your submission. Those files can be very large and
submitting them can have a disruptive effect on our shared computing resources.

2. Part 1 (15% credit):
One of the features of the Unix “standard I/O” library is the use of input and output
buffers” that aim to reduce the number of times the (expensive) read() and write()
system calls are invoked. Functions like fprintf() and fputc() don’t call write() each time
they’re used. Instead, they add their output to a buffer and call write() only when the
CIS 505 Spring 2016 Project 1 2
buffer becomes full. (Write() also gets called when the file is closed and when the
program explicitly requests that buffers be flushed). By avoiding excessive use of system
calls, programs that use the standard I/O library often have much better performance
than they would had they used read() and write() directly. For example, consider the
following two programs: The first uses the system call interface to write 50,000
characters (one at a time):
/* syscall_writer.c ‐ write 50,000 characters with write*/