CS-384 Lab 1: Unix System Calls

Overview

The purpose of this lab is to review the C++ programming environment on the UNIX (Linux) operating system and to make use of some simple operating system calls.

Background

If you have not taken CS-321, you might not be familiar with building C++ programs in the UNIX/Linux environment. Using qmake to do this will be discussed during the first lab. If you are familiar with (or wish to investigate) writing Makefiles directly or using KDevelop (IDE, automatic "make" files, color-coded source editor, etc.), you may use one of those methods as well.

Preliminaries: Getting Set Up

Log into your Ubuntu image.

Part 1: Adding and updating packages

Run System | Administration | Snaptic Package Manager. Enter your password to confirm that you are the first system user (the default user with administrative privileges under Ubuntu).

Ensure that the following packages are selected: manpages, manpages-dev, libqt3-headers, libqt3-mt-dev (includes qmake), gedit. You might also want to search for and install the “kevelop” packages. This provides an IDE (integrated development environment) for C++ that you may wish to try, but the method supported in class will be using a text editor and the command line compiler tools.

Click “Mark All Upgrades” to bring your system up to date with the latest Ubuntu patches. We recommend using the “Smart Upgrade” option.

Click “Apply”.

Part 2: A sample program

Part 3: Man(ual) pages

        struct utsname myUname;
        int rv = uname(&myUname);

Lab activity

This is a team assignment. There are various ways that you can divide up the work and work in groups within the team. Regardless of your chosen structure, be sure that every module is reviewed by at least one team member who was not the primary author of that module. Review for documentation, correctness, etc.

First, implement the following C++ classes (each with separate ".cpp" and ".h" files):

Write a test program ("main" function, in a separate ".cpp" file) to call the functions and to output the data returned by each, and runs in a terminal window. Include sufficient exercise of the system command class to demonstrate all its methods. Create a make file, qmake file, or use KDevelop to build the test program.

Hint: While looking for information in the man pages you may have to specify the programmer’s version of the command. This would be done for ctime as man 3 ctime. If the item you are searching for is found in sections 1 or 2 of then you won’t get the necessary section 3 page.

Lab report (due by 11 P.M., the day prior to the week 2 lab)

Your lab report (one report per group) need not be self-contained. This means that it is not necessary to restate the entire specification in your report.


This lab was developed by Dr. Barnicki, Dr. Durant, Dr. Sebern, and Dr. Welch