CSCI 310 Test 1 Spring 2015


  1. The POSIX standard provides a mechanism for passing environment variables.
    1. [2 points] Describe how such variables, along with their associated values are stored in C/C++.
    2. [2 points] What is the implication of this mechanism being part of the POSIX standard?
    3. [6 points] A library function char * getenv(char * name, char * envp[]) searches the environment list to find the environment variable name, and returns a pointer to the corresponding value string. Provide code to implement this routine.
  2. Program arguments and environment
    1. [2 points] In a code snippet show how command line arguments are presented to a C/C++ program. Explain your code.
    2. [2 point] Describe any command line arguments with special properties (from the point of view of the program)
    3. [3 points] Describe the system call(s) that transfer command line arguments to a new process.
    4. [3 points] Provide a code snippet that transfers the command line arguments "hello" and "world" to a process. Explain your code.
  3. Process ID
    1. [2 points] What is a process id and how is it assigned.
    2. [2 points] How can a process discover the process id it has been assigned? Give a code snippet.
    3. [5 points] Name and describe at least two ways a parent process uses the process id of a child process. Provide code snippets.
    4. [3 points] Draw the family tree for the processes in this output from ps -ef:
      UID        PID  PPID  C STIME TTY          TIME CMD
      root         1     0  0  2014 ?        00:00:01 /sbin/init
      root      1033     1  0  2014 ?        00:00:00 /usr/sbin/sshd
      root     24949  1033  0 09:19 ?        00:00:00 sshd: dbennett [priv]
      dbennett 24950 24949  0 09:19 pts/0    00:00:00 -bash
      dbennett 25676 24950  0 14:59 pts/0    00:00:00 ps -ef
      dbennett 25677 24950  0 14:59 pts/0    00:00:00 grep bennett
      	   
    5. [3 points] Give a plausible chain of events describing how the above set of processes were created.

    Over Please

     

     

  4. [3 points each] Define/describe or otherwise discuss each as it relates to this class:
  5. [4 points] Discuss at least two tasks performed by init
  6. [5 points ]The system call void abort(void) will cause a process to produce a core dump and exit. Assuming you can modify a program's source code, how could you get a core dump of a process at a given point in the program, while letting the process continue execution?