|
|
发表于 2007-2-17 12:51:06| 字数 1,676| - 美国–德克萨斯州–卡梅伦–拉古纳维斯塔 Charter_Communications
|
显示全部楼层
|阅读模式
上课都听得懂...但是出来的题目就是不明白要我做什么...大家帮忙看看...
In this assignment, you will implement a program to handle con-
current processes which perform arithmetic operations.
This is especially applicable for execution in dual or quad-core
computer systems.
You will learn concepts from several computer science discip-
lines, including compilers, data flow architecture, parallel com-
putation, and, of course, operating systems. The input to your
program is illustrated by the following example:
main()
{ input_var a,b,c,d;
process_var p1,p2,p3,p4;
read(a,b,c,d);
cobegin
p1 = a + b;
p2 = c - d;
p3 = a + 2;
coend;
p4 = p1 * (p2 + p3);
write(a,b,c,d,p1,p2,p3,p4);
}
The syntax of the concurrent program follows that of C with the
following extensions.
input_var declares input variables to be read by your program
using "read". process_var declares process variables
whose values will be computed a process you create. There will
be a distinct process to handle the calculation for each process
variable. Statements within a cobegin-coend pair can be executed
concurrently. Therefore, processes which compute the process
variables in these concurrent statements can be executed con-
currently.
In the above example, processes to compute the values
of p1, p2, and p3 can be executed concurrently. However, these 3
processes must complete before the process for computing p4 can
start. There can be several levels of nesting cobegin-coend pairs
and your program should parse these statements correctly. There
may be one level of parantheses in one arithmetic operation, and
this also imposes precedence constraints on the processes'
arithmetic operations.
You may want to create an internal precedence graph to store the
dependencies among the processes. To synchronize these con-
current processes, you are to use Unix semaphores. The output of
your program consists of a printout of the values of all input
and process variables as specified by "write".
有任何idea都好哦!!! |
|