首页 > > 详细

讲解留学生操作系统、讲解 Operating Systems

CSCI3000: Operating Systems
The goal of this homework is to get you familiar with system cals related to proceses in
the UNIX operating system. You wil write a program that uses multiple proceses to
compute the sum of a set of (smal) positive integers. This is a very strange method of
computing the sum of a set of numbers, but we wil use it to learn about proceses.
There are two kinds of proceses for this asignment:
• A set of “worker” proceses. Each worker proces gets two smal integers as
command line parameters (they wil be available in its argv), computes their sum
and returns the result using exit system cal. So, for every sum a worker proces is
created.
• A “coordinator” proces. It is responsible for creating the “worker” proceses,
and coordinating the computation. Note that al the computation is done by the
“worker” proceses. Al the numbers to be added are provided in the command
line for the coordinator proces.
Note that the coordinator may have to create multiple sets of proceses. For example, if
there are 8 numbers, the coordinator wil first create 4 workers and get the results from
them. At this point there are 4 numbers, and it creates 2 workers. Finaly one worker is
created to compute the overal sum. To make it simpler, if the number of integers to add
is odd, the coordinator adds a 0 to the list of numbers. Note that this may happen at any
step during the computation.
Use the thin clients in Room No. 208 or the PCs in Room No. 207 or your own computer
to get onto xlogin.cs.ecu.edu and work on your programing asignments. The xlogin
server runs SUSE LINUX. Remember that you first need to go through VPN (Virtual
Private Network) to remotely connect to xlogin.cs.ecu.edu. After going through VPN,
you need to use either ssh, putty or NX clients to remotely login.
Create a subdirectory caled cs3000 in your home directory. Create a subdirectory caled
assign1 in your cs3000 directory. Use that subdirectory to store al the files concerning
this asignment and nothing else. You need to follow these general guidelines for al your
future asignments as wel. Name the two source files worker.c and coordinator.c. The
code for worker proces should be compiled separately and its executable be caled
worker. It should also be possible to execute the “worker” program as a standalone
program. The executable for the coordinator proces should be caled coordinator. So, to
compute the sum of the numbers 1 . . . 7, the command line would look something like:
coordinator 1 2 3 4 5 6 7
Since the results are pased around by exit keep the numbers smal (single digit).
Note that this is not a good way for communication betwen proceses. Each worker
proces should print its proces id, its operands and their sum. Each time the
coordinator gets a result from a worker, it must print the pid of the worker, and the result
received from that worker. If you are not using makefile, please include the name of the
compiler you are using and any special options needed as comments (along with other
traditional comments) at the beginning of your source code.
System Calls In order to do this asignment, you should get familiar with several system
cals. The important ones are fork, execlp, exit, and wait system cals. You wil also need
getpid and peror system cals. You can find more information on them in the reference
books mentioned in the class. You can also find information about them directly from the
system by using the manual pages.
What to submit? Make sure to submit the complete set of files that you wish to submit
in the Blackboard (including the program worker.c and coordinator.c in this asignment,
testing results (including at least 4 different test cases, you may include couple of test
cases that would fail your program), “makefile” if any and “readme” file for building and
using the program).

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!