recategorized by
5,957 views
18 votes
18 votes
  1. Draw a precedence graph for the following sequential code. The statements are numbered from $S_1$ to $S_6$
    $S_1$ read n
    $S_2$ i := 1
    $S_3$ if i > n next
    $S_4$ a(i) := i+1
    $S_5$ i := i+1
    $S_6$ next : write a(i)
  2. Can this graph be converted to a concurrent program using parbegin-parend construct only?

recategorized by

3 Answers

Best answer
21 votes
21 votes

Following must be the correct precedence graph, $S_1$ abd $S_2$ are independent, hence these can be executed in parallel.

For all those nodes which are independent we can execute them in parallel by creating a separate process for each node like $S_1$ and $S_2$. There is an edge from $S_3$ to $S_6$ it means, until the process which executes $S_3$ finishes its work, we can't start the process which will execute $S_6$.

For more understanding watch the following NPTEL lectures on process management:

 

edited by
6 votes
6 votes

precedence graph

0 votes
0 votes

The precedence graph is as follows

 precedence graph

i feel parbegin .parend can be used between s1 and s2 and then be serialized but some solutions are showing they cant be used.

someone please rectify me if  i am wrong  and please  make me understand my mistake

Related questions

34 votes
34 votes
4 answers
1
Kathleen asked Oct 5, 2014
19,575 views
Consider the resource allocation graph in the figure.Find if the system is in a deadlock stateOtherwise, find a safe sequence
3 votes
3 votes
1 answer
4
gatecse asked May 3, 2021
2,323 views
State whether the following statements are True or False with reasons for your answer:A two pass assembler uses its machine opcode table in the first pass of assembly.