Question: 1 . Given the following program, ( a ) how many processes will be created and what is the running result? Explain how the processes

1. Given the following program, (a) how many processes will be created and what is the running result? Explain how the processes are executed to print the result. (b) if the chunksize is set to 4 in line 17, what will be the program running result? Explain how the processes are created to print the result. (c) if the setting chunksize \(=6\) is removed from line 17, how many processes will be created? (d) if line 11 is removed, how many processes will be created by the program and what is the result? Explain the reason (NOTE: you may need to run the program several times to notice the program result change).(e) if the max_workers parameter is changed from 10 to 2 in line 15, and the chunksize is set to 4 in line 17, what will be the program running result? Explain how the processes are created to print the result. (f) if the ProcessPoolExecutor is changed to ThreadPoolExecutor in line 5 and line 15, how many processes will be created?
```
import time
import math
import os
import numpy as np
from concurrent.futures import ProcessPoolExecutor
def func(value):
result = math.sqrt(value)
pid = os.getpid()
print("[Pid:%s] The value %s and the root is %s"%(pid, value, result))
time.sleep(value)
return result
if __name__=='__main__':
with ProcessPoolexecutor(10) as executor:
data = np.array([10,3,6,1,4,5,2,9,7,3,4,6])
executor.map(func, data, chunksize=6)
print("END Program")
```
1 . Given the following program, ( a ) how many

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!