ICE2015: UNIX Programming (Fall 2015)

[Homework Assignments]

  • Web server programming assignment (mandatory) - Due: Dec. 12th
    • The goal of this assignment is to build a functioning concurrent web server.
    • A web server is fundamentally similar to the Echo server, which was introduced as an example for socket programming during our lecture.
    • After accepting a client connection, a web server waits for the web service request. A typical web service request is like GET /index.html HTTP/1.0\n.
    • When the web server receives the request, the web server retrieves the corresponding file from the predefined web file directory. For example, if the predefined directory is /home/euiseong/web/ and the requested file is /index.html, /home/euiseong/web/index.html will be read. The read file contents will be sent to the client, which is usually a web browser.
    • Your goal is to build a concurrent web server so that your web server can accept and serve other clients even while it is serving a large file to a client.
    • Use the I/O multiplexing concurrency model.
    • Submit the source code with the documentation, which describes the internal design of the server, via i-Campus by the due date. All files must be tarred and gzipped into a single file.
    • (Optional) Your web server can support PHP-based web contents. Simply, invoke the PHP interpreter (php) when the extension of the target file is .php, and read the output of the interpreter instead of directly reading the .php file.
  • Shell Lab (mandatory) - Due: Dec. 6th
    • PART V - Issued on Nov. 30
      • A good program must be accompanied with good documentation. This is the time to write the internal design guide of your visual shell as well as the manuals for it.
      • Your submission will be packed in a single compressed tar file (with the extension of "tgz or tar.gz").
      • The compressed file contains three directories; each for the source files, binary files, and documents.
      • The source files are supposed to be automatically compiled with the make tool.
      • Submit your homework file via i-Campus by the due date.
    • PART IV - Issued on Nov. 23
      • Now, your shell must handle pipelining and redirection of commands as bash does.
      • Arbitrary number of commands can be pipelined.
      • Redirection of standard input and output as well as standard error must be supported.
    • Part III - Issued on Nov. 22
      • Polish your shell with more built-in commands and the job control feature.
      • The following build-in commands should be implemented.
        1. time
        2. cd
        3. pwd
      • In order to support job controlling, following commands are also need to be implemented.
        1. bg
        2. fg
        3. jobs
      • The job control may require your shell to create a new process group for each command line input.
    • Part II - Issued on Nov. 16
      • Now your visual shell shows the directory list of the current working directory on the information area.
      • You can traverse the directories via the direction keys and enter key.
      • One of the directory item is highlighted, you can change the highlighted item with the direction keys.
      • If you hit the enter key on a highlighted executable file, the executable file will be executed. In this case, your shell should yield the entire terminal to the file to be executed.
      • If the highlighted item is a directory, then the current working directory will be changed to the highlighted directory.
      • After the execution, the shell should take the screen back and restore the information and command areas.
    • Logistics
      • All files must be in a single directory that are named after your student ID.
      • The directory has two sub-directories, docs and srcs.
      • Documents are in the directory docs. Source files are in the directory srcs.
      • The student ID directory will be zipped into a single tgz file.
      • The tgz file should be uploaded by the due date, which will be announced later.
    • Part I - Issued on Nov. 8
      1. Write the skeleton of your shell.
      2. Your shell must provide a visual interface based on the ncurses library.
      3. The shell interface is separated into two areas; the information are and command line area.
      4. The information area will display blank at this moment.
      5. Users put their commands on the command line area.
      6. The command line area also shows the results to the input commands.
      7. Implement the following built-in commands.
        • echo
        • whoami
        • export
        • date
  • Development of a game using nurses library (advisory) - Issued on Oct. 29
    • Before a graphic terminal was being popular, there were many text-based games, including the famous "Hangman" game.
    • You can figure out lots of fun games that only use ASCII characters to display, if you use your imagination.
    • Develop a fun game of your own, and show it to others!
    • If you think that yours is sufficiently good, send it to me before Nov. 13 via e-mail (
  • Utility programming assignment (advisory) - Issued on Oct. 10
    • top is a useful tool for monitoring system status on the fly. Your mission is to build a simplified version of top.
    • Your top will periodically show system information that includes the followings:
      • Load average of 1, 5 and 15 minutes. Number of existing processes.
      • Total memory and free memory.
    • The original top displays the information in good-looking form. This output is generated through the ncurses library. If you want to make a command line tool with user-friendly interface, learning how to use ncurses is highly recommended.
    • If you are interested in ncurses, please refer to nurses Programming Howto. Also, you can easily install ncurses to your system with the apt-get install ncurses-devel command.
  • System administration homework assignment (advisory) - Issued on Oct. 7
    • You want to make your system back up all temporary files in /tmp to a backup file, of which name is tmp-YYYY-MM-DD, in /backup/ after every boot up, how can you accomplish this? Write a shell script according to the rc shell script convention, and place the shell script in /etc/init.d and create a symbolic link in the proper rc directory. The backup file should be a tarred and gzipped file.
  • Shell scripting homework assignment (advisory) - Issued on Sep. 22
    1. Counting the number of files with the given name
      • Your shell script traverses a directory structure and counts the number of files with the given file name.
      • The file name will be given to the script as its first command line argument.
      • The second argument is the starting directory to traverse. If it is not given, by default, the current working directory will be used as the starting point.
      • The file name can be written in regular expression.
      • The output should be as follows:
        "(number of files) files have the file name (given name) under the directory (starting directory)."
    2. Logging the number of threads in a system
      • Your shell script periodically record the number of threads in execution.
      • Your shell script demands two command line arguments.
      • The first argument denotes the log file name, and the second argument determines the logging period.
      • The logging period is represented in seconds. For example, if the second argument is 60, the shell script will wake up every 1 min and log the number of existing threads on the log file.
      • The format of the log is as follows:
        "2015-09-22 16:26:20 - 124 threads exist." "2015-09-22 16:31:20 - 128 threads exist."