关键词 > EECS3221.3

EECS 3221.3 Processes, Signals and Interprocess Communication.

发布时间:2021-05-31

EECS 3221.3

Assignment 1.

Processes, Signals and Interprocess Communication.

Due Date: Wednesday Oct. 12 at 4:00pm.


1. Exploring Linux   Use the command strace to trace the system calls of the execu-tion of

wc <file>

and answer the following questions:

(1) Why does your process read files like ld.so* when it starts up?

(2) Why does it read files like *locale* immediately afterwards?

(3) Program wc reads the file one chunk at a time. How big is this chunk?

(4) Which system call does not return anything?

        You do not need to submit the answers to these questions, but do them before you start the programming part. Use this experience when you debug the program.


2. A Program for Performance Evaluation of Signals

        You will write a simple program called ring that creates a ring of N processes that send a signal round and round cnt times. The program is invoked with

./ring N leader cnt

where leader is 0 when you first invoke it. The program works as follows. If the leader parameter is 0 then it knows it is the leader. It then creates (with fork-exec)achild process that has parameters

N-1 leader cnt

where now leader is the PID of the true leader process. The child then will create an-other child process with parameters

N-2 leader cnt

where now leader is again the PID of the true leader process. The process that eventu-ally is created with N=1 is the last one and it does not create another child. Instead sends a SIGUSR1 to the leader to start everything. All the process suspend themselves waiting for a SIGUSR1 and then send a SIGUSR1 to the next one. At the end of the execution the leader (only) prints the cnt and the true time elapsed since the beginning of execu-tion as a floating point number. Also write a script ring_time.sh using a for loop that runs the ring program for N=20 processes and for cnt10, 100, 1000 and 10000 sig-nals and writes the results in the file timing.out. The format of the file tim-ing.out is the results of one run per line and each line contains the cnt and the time it took.


3. Skeleton Code

        Please download the skeleton code I provide and use it as starting point for the as-signment. It includes a Makefile with several useful targets to help you develop and debug your code. It also includes an empty C program (just prints its PID) and an empty shell program.


4. Style

        Your code should be properly commented, indented and readable. There should be a comment near the top of the file that includes a short description (3-4 lines), your name and date. Compilation should produce no warnings on the EECS Linux systems. All sys-tem calls that may return an error condition should be checked. Please keep in mind that style is very important.


5. Asking Questions

        Please e-mail assignment related questions to minas at cse.... The answer will be posted on the FAQ. Or join the office hours.


6. Reading

        Besides the code in the notes, you should read several man pages. Pages like kill(2), sigaction(2), fork(2), signal(7), errno(3), sigsuspend(2), clock_gettime(2) are good start-ing points.