Advanced Unix Programming

Last updated on 24th March 2014

This course may have been last taught by me in 2008 in a deemed university in Andhra Pradesh, India. I may have taught this course for four or five batches/years. The class size was typically around 14 to 18 students.

This is a Lab course I taught for I. M.Tech. (Comp. Sc.). It teaches usage of Unix system calls. For example, writing a shell program is one of the assignments in the course where the student will have to use fork, exec and waitpid system calls. However the course does not get into implementation of these system calls itself (kernel programming).

Knowledge of Unix system calls (also referred to as functions) programming should enable the student to easily learn how to use corresponding system calls in other operating systems like Windows. For example once the student completes this course successfully he/she should be able to easily pick up how to programmatically create processes in Windows and how to programmatically navigate through the Windows file system.

Prerequisites for the Course
C Programming including debugging skills and User level knowledge of Unix (Unix commands like ls, chmod, mkdir, kill etc.)

Course Book
Advanced Programming in the Unix Environment, 2nd edition by W. Richard Stevens and Stephen A. Rago. Here’s the book support site: http://www.apuebook.com/apue2e.html. A 3rd edition is now available (dated 2013) but I have not read the book and so do not know its suitability for this course. I believe that the 2nd edition pdf version (and the 3rd edition pdf version – http://it-ebooks.info/book/3040/) is available for free download (legally).

Ideal Coverage (subject to time limitations)

  1. Building large programs with multiple source files, related compiler options, library archive files (.a files), using make to build programs.
  2. Quick overview of Unix system architecture, error handling, system calls and library functions.
  3. Self Study of Unix Standardization and implementations: IEEE POSIX, Single Unix Specification, POSIX limits, sysconf, pathconf.
  4. File I/O: open, lseek, read, write, dup, fcntl functions; atomic operations
  5. Files & Directories: stat, umask, chmod, chown, link, unlink symlink, readlink, mkdir, rmdir chdir, getcwd functions.
  6. Process Environment: Process termination, environment list, environment variables
  7. Process Control: fork, exit, wait, waitpid, exec, system; race conditions, synchronization
  8. Self Study of Process Relationships: Process groups, sessions, controlling terminal, job control, shell execution of programs.
  9. Signals: Signal concepts, signal function, unreliable signals, interrupted system calls, reentrant functions, kill, raise, alarm and pause functions; signal sets, sigprocmask, sigpending, sigaction, sigsuspend, abort, system functions.
  10. Self Study of Daemon processes: Daemon characteristics, coding rules, error logging
  11. Advanced I/O: select function and quick overview of record locking
  12. Interprocess Communication: pipe, popen, pclose, fifo functions, message queues, semaphores, shared memory related functions.

For all the topics excepting Self Study topics programming assignments are given to the students.

Note that in some years, due to paucity of time, topics 7 to 9 were covered in a rushed manner and topics 10 to 12 were skipped. For the 2004 batch there was enough time to cover all the topics mentioned above (including assignments).

Also note that MultiThreaded programming is not covered in this course due to lack of time. However another course, Network programming, covers Multi Threaded programming.

Index of Links to Chapter Wise Course Pages

The following two links have slides and some examples from US professors on the same subject and based partly on the same course book:
1) http://www.cs.stevens.edu/~jschauma/810/
2) http://www.cs.fsu.edu/~asriniva/courses/aup02/lectures.html

The above links were obtained via Google search and so presumed to be freely accessible to anybody on the net.

For those students who are not familiar with make, slides and examples of lectures 1 & 2 of the second link above (cs.fsu.edu) will be useful.

Intro.ppt

Please note that only three of the chapter links below have Powerpoint slides links (some of which have very few slides – topics only type). If I recall correctly I used slides from the above-mentioned US university links for some of the chapters – why reinvent the wheel? However the chapter links below clearly specify the sections covered/to be read as reading assignments and the assignments, most, if not all, of which were created by me specially for this course. So I think they give a good framework for students to learn Advanced Unix Programming in a semester in college/university environments.

Further, please note that, as a first step, I have focused on putting up the course content used by me to teach this course in the deemed university in Andhra Pradesh, India, suitably modified, on this blog. As part of the minor modifications for putting it up on this publicly accessible blog, some errors may have crept in. I have not checked all the modifications for accuracy (due to other demands on my time). If this course (on this blog) does get utilized by students then the errors in the modified part will come to light and will get fixed by me (or others). I think that is a better way of investing my (and others) time for fixing any errors in this course (on this blog).

Chapter 1 – Unix System Overview

Chapter 2 – Unix Standardization and Implementations (Reading Assignments only)

Chapter 3 – File I/O

Chapter 4 – Files and Directories

Chapter 5 – Standard I/O Library (Reading Assignments only)

Chapter 6 – System Data Files and Information (Reading Assignments only)

Chapter 7 – Process Environment

Chapter 8 – Process Control

Chapter 9 – Process Relationships

Chapter 10 – Signals

Chapter 14 – Advanced I/O

Chapter 13 – Daemon Processes

Chapter 15 – Interprocess Communication

Notes

man 1 intro: Gives introduction to section 1 of man pages

man x intro: Gives intro to section x of man pages (See intro for all sections (1 to 8) of man pages)

Former Student Feedback

A former student who had been taught these courses by me, wrote me on 22nd March 2014:

These courses (Advanced Unix Programming and Unix Network Programming) went a long way in helping me land my job at Alcatel-Lucent. I had a one-on-one interview with my hiring manager that was entirely on Unix. After joining the company I learned that this person(manager) was a big time ‘Unix fan’. It was very satisfying to have done well in that interview. On the job, we completely relied on Solaris Unix based servers and the concepts of processes and threads gained from these course(s), went a long way in helping me grasp the software.
Thank you Ravi Sir.

One thought on “Advanced Unix Programming

Leave a comment