[30 points] Write two programs. The first is called “server1”, the other called “client1”. The two programs communicate via a named pipe (fifo).
When the server or the client starts, it will check if the fifo is already exist (hint: using the stat() function that we discussed in class). If not, create the fifo.
The client reads a line from the keyboard, change all the letters to UPCASES, and send the line to the server via the fifo.
The server reads the fifo and displays anything it receives from the fifo.
[30 points] Re-implement the above client/server programs using mmap() and signals. Change the name of server to “server2” and client to “client2”.
The client and server communicate via a shared memory region (1KB) created by mmap() the same file.
The client reads a line from the keyboard, convert all letters in the line to UPCASES, and write the results to the shared memory area.
The server can read the shared memory area and display the results.
How can the server find out when a new message arrives? The solution is to use signals. The client should send a USER1 signal after it finishing writing a new message in the shared memory area.
[40 points] Write a program that uses popen() to display the user names of each running process in the system
The unix “cut” command displays selected columns or fields from each line of a file. For example, if you have a file named “111”, the following command line display column 1-5 of each line of the file:
“cut -c 1-5 111”
and the following command line display the 2nd field of each line, each field is separated by the space. You can specify the separator-delimited via the -d option:
“cut -f2 -d ”
Check the following webpage for more information about cut.
http://www.softpanorama.org/Tools/cut.shtml
Your job is to write a program called “username_only” that utilizes popen() to find all the processes running in the system (hint: using ps aux command) and sends each line via another popen() to another process running cut. The cut process displays the first column (the user name) and skip the rest.
Put it in another way, if you run “ps aux”, you will see something like the following:
[pic 1]
then when you run username_only, the expected output of your program will be:
[pic 2]
What to submit:
1) All of your c source files.
2) A brief testing report showing the screen captures of each program.
We may randomly select some submissions and compile/run them. If the results do not agree with your report, we will expect an explanation from you.
Last Completed Projects
| topic title | academic level | Writer | delivered |
|---|
