Question: 1 a ) ( 5 points ) As briefly illustrated in class, a Python application can have several threads. Is this consistent with the basic

1a)(5 points) As briefly illustrated in class, a Python application can have several threads. Is this
consistent with the basic notion of threads in an operating system? Explain.
1b)(10 points) Describe the steps the OS must perform to support the creation and execution of the
main program and the corresponding threads.
def task(id):
print(f'Starting Task ID: {id}...')
sleeptime = random.randrange(5,15,1)
print(f'Task: {id} sleeping for: {sleeptime}')
sleep(sleeptime)
print(f'Finished Task ID: {id}')
if __name__=='__main__':
start_time = perf_counter()
#create two threads
t1= Thread(target=task, args=(1,))
#start the threads
t1.start()
#wait for each thread to finish
t1.join()
end_time = perf_counter()
print(f'Total time to complete: {end_time-start_time} sec')
1c)(10 points) Alter the above code to create and start 2 more Thread instances for a total of 3. Add the
required code below:
2)(5 points) What is the PCB used for?

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 Databases Questions!