ISP: Assignment 3

The assignment is due at the beginning of class on Monday, November 1, 5 pm. Please follow the instructions in submitting your assignment.

  1. Write a routine that allows a single-threaded program to register multiple events at distinct points in time, using the alarm() mechanism. For example, I should be able to write a program
    schedule(foo, v0, t0);
    some other code
    schedule(bar, v1, t1);
    where t0 and t1 are time_t values indicating an absolute time and foo and bar are functions that get called with arguments v0 and v1, respectively when their time comes.
  2. Write a test program that confirms the operating system properties that get inherited across fork and exec, respectively. Please test the following properties:
  3. Explore gettext() and related message database routines. Create a simple program that allows users to enter a date via the command line (in the format "day month year") and returns the day of the week. Check for various error conditions on each entry and use the message database to return specific error messages, e.g., "Months must be between 1 and 12, not 17". Your program should be bilingual. You may choose the other language, besides English. Klingon is not acceptable; if your second language skills are rusty, you can always ask Altavista for translations.

    Hints: xgettext extracts the messages into a message file, but does not create the message object, i.e., the database of messages. You will need to use the msgfmt command for this. The man pages for msgfmt point you toward putting the database in /usr/lib/locale/..., but you will need to put it in your own directory tree. The manpages for msgfmt and gettext(1) describe the environment variables to override these default directories when you are using gettext from the commandline. The manpages for gettext(3c) (the function) provide details on other functions which can be used from your program to get the same effect as setting the environment variables from the command line.

  4. Write a program that explores what happens if a signal arrives (same one or a different one) while the program is in the signal handler. Provide a command-line flag that enables code in your program that prevents any extra signals from being delivered during that time. Summarize your results for Solaris and Linux.
  5. Write a program that compares the latency of spawning a process with that of creating a (Posix) thread. Again, compare Solaris and Linux. (Latency refers to the time from creation to when the thread or process actually starts running.) If somebody has access to NT, I'd be interested in a comparison as well.
  6. Investigate the behavior of longjmp() and setjmp() as well as sigsetjmp() and siglongjmp. Confirm which parts of the program state get restored by the routines, including local automatic, local static, and external variables and signal masks.

Last updated by Henning Schulzrinne